Skip to content

Commit

Permalink
Fix module tests
Browse files Browse the repository at this point in the history
- Replace some occurrences of `base.enable` with
  `base._moduleContainer.enable(_, _, False)` to not count as a module
  state modification.

- Don't test installing old versions of modules, this is not supported
  by DNF
  • Loading branch information
evan-goode committed Apr 30, 2024
1 parent 62f6735 commit 7fe063f
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions tests/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_enable_invalid(self):
self.module_base.enable(["httpd:invalid"])

def test_enable_different_stream(self):
self.module_base.enable(["httpd:2.4"])
self.base._moduleContainer.enable("httpd", "2.4", False)
self.assertEqual(self.base._moduleContainer.getModuleState("httpd"),
libdnf.module.ModulePackageContainer.ModuleState_ENABLED)
self.assertEqual(self.base._moduleContainer.getEnabledStream("httpd"), "2.4")
Expand All @@ -122,7 +122,7 @@ def test_enable_different_stream_missing_profile(self):
# dnf module disable

def test_disable_name(self):
self.module_base.enable(["httpd:2.4"])
self.base._moduleContainer.enable("httpd", "2.4", False)
self.assertEqual(self.base._moduleContainer.getModuleState("httpd"),
libdnf.module.ModulePackageContainer.ModuleState_ENABLED)
self.assertEqual(self.base._moduleContainer.getEnabledStream("httpd"), "2.4")
Expand All @@ -134,7 +134,7 @@ def test_disable_name(self):

def test_disable_name_stream(self):
# It should disable whole module not only stream (strem = "")
self.module_base.enable(["httpd:2.4"])
self.base._moduleContainer.enable("httpd", "2.4", False)
self.assertEqual(self.base._moduleContainer.getModuleState("httpd"),
libdnf.module.ModulePackageContainer.ModuleState_ENABLED)
self.assertEqual(self.base._moduleContainer.getEnabledStream("httpd"), "2.4")
Expand All @@ -146,7 +146,8 @@ def test_disable_name_stream(self):

def test_disable_pkgspec(self):
# It should disable whole module not only profile (strem = "")
self.module_base.enable(["httpd:2.4"])
self.base._moduleContainer.enable("httpd", "2.4", False)

self.assertEqual(self.base._moduleContainer.getModuleState("httpd"),
libdnf.module.ModulePackageContainer.ModuleState_ENABLED)
self.assertEqual(self.base._moduleContainer.getEnabledStream("httpd"), "2.4")
Expand All @@ -157,7 +158,7 @@ def test_disable_pkgspec(self):
self.assertEqual(self.base._moduleContainer.getEnabledStream("httpd"), "")

def test_disable_invalid(self):
self.module_base.enable(["httpd:2.4"])
self.base._moduleContainer.enable("httpd", "2.4", False)
self.assertEqual(self.base._moduleContainer.getModuleState("httpd"),
libdnf.module.ModulePackageContainer.ModuleState_ENABLED)
self.assertEqual(self.base._moduleContainer.getEnabledStream("httpd"), "2.4")
Expand Down Expand Up @@ -204,35 +205,36 @@ def test_install_profile_latest(self):

def test_install_profile(self):
self.test_enable_name_stream()
self.module_base.install(["httpd:2.4:1/default"])
self.module_base.install(["httpd:2.4:2/default"])
self.base.resolve()
expected = [
"basesystem-11-3.noarch",
"filesystem-3.2-40.x86_64",
"glibc-2.25.90-2.x86_64",
"glibc-common-2.25.90-2.x86_64",
"httpd-2.4.25-7.x86_64",
"httpd-2.4.25-8.x86_64",
"libnghttp2-1.21.1-1.x86_64", # expected behaviour, non-modular rpm pulled in
]
self.assertInstalls(expected)

def test_install_two_profiles(self):
self.test_enable_name_stream()

self.module_base.install(["httpd:2.4:1/default", "httpd:2.4:1/doc"])
self.module_base.install(["httpd:2.4:2/default", "httpd:2.4:2/doc"])
self.base.resolve()
expected = [
"basesystem-11-3.noarch",
"filesystem-3.2-40.x86_64",
"glibc-2.25.90-2.x86_64",
"glibc-common-2.25.90-2.x86_64",
"httpd-2.4.25-7.x86_64",
"httpd-doc-2.4.25-7.x86_64",
"httpd-2.4.25-8.x86_64",
"httpd-doc-2.4.25-8.x86_64",
"libnghttp2-1.21.1-1.x86_64", # expected behaviour, non-modular rpm pulled in
]
self.assertInstalls(expected)

def test_install_two_profiles_different_versions(self):
"""
self.test_enable_name_stream()
self.module_base.install(["httpd:2.4:2/default", "httpd:2.4:1/doc"])
self.base.resolve()
Expand All @@ -246,6 +248,7 @@ def test_install_two_profiles_different_versions(self):
"libnghttp2-1.21.1-1.x86_64", # expected behaviour, non-modular rpm pulled in
]
self.assertInstalls(expected)
"""

def test_install_profile_updated(self):
return
Expand Down

0 comments on commit 7fe063f

Please sign in to comment.