mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-01 09:50:33 +08:00
Fix tests in order to run with PostgreSQL
Most of the issues are caused by the use of SQLAlchemy database session. Some inline comments describe the issues in detail. Signed-off-by: Chenxiong Qi <cqi@redhat.com>
This commit is contained in:
@@ -51,28 +51,30 @@ class TestUtilsModuleStreamExpansion:
|
||||
]
|
||||
return nsvcs
|
||||
|
||||
def _generate_default_modules(self):
|
||||
def _generate_default_modules(self, db_session):
|
||||
"""
|
||||
Generates gtk:1, gtk:2, foo:1 and foo:2 modules requiring the
|
||||
platform:f28 and platform:f29 modules.
|
||||
"""
|
||||
platform_f28 = make_module("platform:f28:0:c10", {}, {})
|
||||
platform_f29 = make_module("platform:f29:0:c11", {}, {})
|
||||
make_module("gtk:1:0:c2", {"platform": ["f28"]}, {}, platform_f28)
|
||||
make_module("gtk:1:0:c3", {"platform": ["f29"]}, {}, platform_f29)
|
||||
make_module("gtk:2:0:c4", {"platform": ["f28"]}, {}, platform_f28)
|
||||
make_module("gtk:2:0:c5", {"platform": ["f29"]}, {}, platform_f29)
|
||||
make_module("foo:1:0:c2", {"platform": ["f28"]}, {}, platform_f28)
|
||||
make_module("foo:1:0:c3", {"platform": ["f29"]}, {}, platform_f29)
|
||||
make_module("foo:2:0:c4", {"platform": ["f28"]}, {}, platform_f28)
|
||||
make_module("foo:2:0:c5", {"platform": ["f29"]}, {}, platform_f29)
|
||||
make_module("app:1:0:c6", {"platform": ["f29"]}, {}, platform_f29)
|
||||
platform_f28 = make_module(db_session, "platform:f28:0:c10", {}, {})
|
||||
platform_f29 = make_module(db_session, "platform:f29:0:c11", {}, {})
|
||||
make_module(db_session, "gtk:1:0:c2", {"platform": ["f28"]}, {}, platform_f28)
|
||||
make_module(db_session, "gtk:1:0:c3", {"platform": ["f29"]}, {}, platform_f29)
|
||||
make_module(db_session, "gtk:2:0:c4", {"platform": ["f28"]}, {}, platform_f28)
|
||||
make_module(db_session, "gtk:2:0:c5", {"platform": ["f29"]}, {}, platform_f29)
|
||||
make_module(db_session, "foo:1:0:c2", {"platform": ["f28"]}, {}, platform_f28)
|
||||
make_module(db_session, "foo:1:0:c3", {"platform": ["f29"]}, {}, platform_f29)
|
||||
make_module(db_session, "foo:2:0:c4", {"platform": ["f28"]}, {}, platform_f28)
|
||||
make_module(db_session, "foo:2:0:c5", {"platform": ["f29"]}, {}, platform_f29)
|
||||
make_module(db_session, "app:1:0:c6", {"platform": ["f29"]}, {}, platform_f29)
|
||||
|
||||
def test_generate_expanded_mmds_context(self):
|
||||
self._generate_default_modules()
|
||||
def test_generate_expanded_mmds_context(self, db_session):
|
||||
self._generate_default_modules(db_session)
|
||||
module_build = make_module(
|
||||
"app:1:0:c1", {"gtk": ["1", "2"]}, {"platform": ["f28"], "gtk": ["1", "2"]})
|
||||
mmds = module_build_service.utils.generate_expanded_mmds(db.session, module_build.mmd())
|
||||
db_session, "app:1:0:c1", {"gtk": ["1", "2"]}, {"platform": ["f28"], "gtk": ["1", "2"]}
|
||||
)
|
||||
mmds = module_build_service.utils.generate_expanded_mmds(
|
||||
db_session, module_build.mmd())
|
||||
contexts = set([mmd.get_context() for mmd in mmds])
|
||||
assert set(["e1e005fb", "ce132a1e"]) == contexts
|
||||
|
||||
@@ -153,10 +155,11 @@ class TestUtilsModuleStreamExpansion:
|
||||
],
|
||||
)
|
||||
def test_generate_expanded_mmds_buildrequires(
|
||||
self, requires, build_requires, stream_ambigous, expected_xmd, expected_buildrequires
|
||||
self, requires, build_requires, stream_ambigous, expected_xmd, expected_buildrequires,
|
||||
db_session
|
||||
):
|
||||
self._generate_default_modules()
|
||||
module_build = make_module("app:1:0:c1", requires, build_requires)
|
||||
self._generate_default_modules(db_session)
|
||||
module_build = make_module(db_session, "app:1:0:c1", requires, build_requires)
|
||||
|
||||
# Check that generate_expanded_mmds raises an exception if stream is ambigous
|
||||
# and also that it does not raise an exception otherwise.
|
||||
@@ -236,10 +239,10 @@ class TestUtilsModuleStreamExpansion:
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_generate_expanded_mmds_requires(self, requires, build_requires, expected):
|
||||
self._generate_default_modules()
|
||||
module_build = make_module("app:1:0:c1", requires, build_requires)
|
||||
mmds = module_build_service.utils.generate_expanded_mmds(db.session, module_build.mmd())
|
||||
def test_generate_expanded_mmds_requires(self, requires, build_requires, expected, db_session):
|
||||
self._generate_default_modules(db_session)
|
||||
module_build = make_module(db_session, "app:1:0:c1", requires, build_requires)
|
||||
mmds = module_build_service.utils.generate_expanded_mmds(db_session, module_build.mmd())
|
||||
|
||||
requires_per_mmd = set()
|
||||
for mmd in mmds:
|
||||
@@ -318,28 +321,28 @@ class TestUtilsModuleStreamExpansion:
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_get_required_modules_simple(self, requires, build_requires, expected):
|
||||
module_build = make_module("app:1:0:c1", requires, build_requires)
|
||||
self._generate_default_modules()
|
||||
def test_get_required_modules_simple(self, requires, build_requires, expected, db_session):
|
||||
module_build = make_module(db_session, "app:1:0:c1", requires, build_requires)
|
||||
self._generate_default_modules(db_session)
|
||||
nsvcs = self._get_mmds_required_by_module_recursively(module_build)
|
||||
assert set(nsvcs) == set(expected)
|
||||
|
||||
def _generate_default_modules_recursion(self):
|
||||
def _generate_default_modules_recursion(self, db_session):
|
||||
"""
|
||||
Generates the gtk:1 module requiring foo:1 module requiring bar:1
|
||||
and lorem:1 modules which require base:f29 module requiring
|
||||
platform:f29 module :).
|
||||
"""
|
||||
base_module = make_module("platform:f29:0:c11", {}, {})
|
||||
make_module("gtk:1:0:c2", {"foo": ["unknown"]}, {}, base_module)
|
||||
make_module("gtk:1:1:c2", {"foo": ["1"]}, {}, base_module)
|
||||
make_module("foo:1:0:c2", {"bar": ["unknown"]}, {}, base_module)
|
||||
make_module("foo:1:1:c2", {"bar": ["1"], "lorem": ["1"]}, {}, base_module)
|
||||
make_module("bar:1:0:c2", {"base": ["unknown"]}, {}, base_module)
|
||||
make_module("bar:1:1:c2", {"base": ["f29"]}, {}, base_module)
|
||||
make_module("lorem:1:0:c2", {"base": ["unknown"]}, {}, base_module)
|
||||
make_module("lorem:1:1:c2", {"base": ["f29"]}, {}, base_module)
|
||||
make_module("base:f29:0:c3", {"platform": ["f29"]}, {}, base_module)
|
||||
base_module = make_module(db_session, "platform:f29:0:c11", {}, {})
|
||||
make_module(db_session, "gtk:1:0:c2", {"foo": ["unknown"]}, {}, base_module)
|
||||
make_module(db_session, "gtk:1:1:c2", {"foo": ["1"]}, {}, base_module)
|
||||
make_module(db_session, "foo:1:0:c2", {"bar": ["unknown"]}, {}, base_module)
|
||||
make_module(db_session, "foo:1:1:c2", {"bar": ["1"], "lorem": ["1"]}, {}, base_module)
|
||||
make_module(db_session, "bar:1:0:c2", {"base": ["unknown"]}, {}, base_module)
|
||||
make_module(db_session, "bar:1:1:c2", {"base": ["f29"]}, {}, base_module)
|
||||
make_module(db_session, "lorem:1:0:c2", {"base": ["unknown"]}, {}, base_module)
|
||||
make_module(db_session, "lorem:1:1:c2", {"base": ["f29"]}, {}, base_module)
|
||||
make_module(db_session, "base:f29:0:c3", {"platform": ["f29"]}, {}, base_module)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"requires,build_requires,expected",
|
||||
@@ -363,25 +366,25 @@ class TestUtilsModuleStreamExpansion:
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_get_required_modules_recursion(self, requires, build_requires, expected):
|
||||
module_build = make_module("app:1:0:c1", requires, build_requires)
|
||||
self._generate_default_modules_recursion()
|
||||
def test_get_required_modules_recursion(self, requires, build_requires, expected, db_session):
|
||||
module_build = make_module(db_session, "app:1:0:c1", requires, build_requires)
|
||||
self._generate_default_modules_recursion(db_session)
|
||||
nsvcs = self._get_mmds_required_by_module_recursively(module_build)
|
||||
assert set(nsvcs) == set(expected)
|
||||
|
||||
def _generate_default_modules_modules_multiple_stream_versions(self):
|
||||
def _generate_default_modules_modules_multiple_stream_versions(self, db_session):
|
||||
"""
|
||||
Generates the gtk:1 module requiring foo:1 module requiring bar:1
|
||||
and lorem:1 modules which require base:f29 module requiring
|
||||
platform:f29 module :).
|
||||
"""
|
||||
f290000 = make_module("platform:f29.0.0:0:c11", {}, {}, virtual_streams=["f29"])
|
||||
f290100 = make_module("platform:f29.1.0:0:c11", {}, {}, virtual_streams=["f29"])
|
||||
f290200 = make_module("platform:f29.2.0:0:c11", {}, {}, virtual_streams=["f29"])
|
||||
make_module("gtk:1:0:c2", {"platform": ["f29"]}, {}, f290000)
|
||||
make_module("gtk:1:1:c2", {"platform": ["f29"]}, {}, f290100)
|
||||
make_module("gtk:1:2:c2", {"platform": ["f29"]}, {}, f290100)
|
||||
make_module("gtk:1:3:c2", {"platform": ["f29"]}, {}, f290200)
|
||||
f290000 = make_module(db_session, "platform:f29.0.0:0:c11", {}, {}, virtual_streams=["f29"])
|
||||
f290100 = make_module(db_session, "platform:f29.1.0:0:c11", {}, {}, virtual_streams=["f29"])
|
||||
f290200 = make_module(db_session, "platform:f29.2.0:0:c11", {}, {}, virtual_streams=["f29"])
|
||||
make_module(db_session, "gtk:1:0:c2", {"platform": ["f29"]}, {}, f290000)
|
||||
make_module(db_session, "gtk:1:1:c2", {"platform": ["f29"]}, {}, f290100)
|
||||
make_module(db_session, "gtk:1:2:c2", {"platform": ["f29"]}, {}, f290100)
|
||||
make_module(db_session, "gtk:1:3:c2", {"platform": ["f29"]}, {}, f290200)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"requires,build_requires,expected",
|
||||
@@ -393,9 +396,11 @@ class TestUtilsModuleStreamExpansion:
|
||||
)
|
||||
],
|
||||
)
|
||||
def test_get_required_modules_stream_versions(self, requires, build_requires, expected):
|
||||
module_build = make_module("app:1:0:c1", requires, build_requires)
|
||||
self._generate_default_modules_modules_multiple_stream_versions()
|
||||
def test_get_required_modules_stream_versions(
|
||||
self, requires, build_requires, expected, db_session
|
||||
):
|
||||
module_build = make_module(db_session, "app:1:0:c1", requires, build_requires)
|
||||
self._generate_default_modules_modules_multiple_stream_versions(db_session)
|
||||
nsvcs = self._get_mmds_required_by_module_recursively(module_build)
|
||||
assert set(nsvcs) == set(expected)
|
||||
|
||||
@@ -424,7 +429,7 @@ class TestUtilsModuleStreamExpansion:
|
||||
assert actual == expected
|
||||
|
||||
@pytest.mark.parametrize("virtual_streams", (None, ["f29"], ["lp29"]))
|
||||
def test__get_base_module_mmds_virtual_streams(self, virtual_streams):
|
||||
def test__get_base_module_mmds_virtual_streams(self, virtual_streams, db_session):
|
||||
"""Ensure the correct results are returned without duplicates."""
|
||||
init_data(data_size=1, multiple_stream_versions=True)
|
||||
mmd = module_build_service.utils.load_mmd_file(
|
||||
@@ -437,7 +442,7 @@ class TestUtilsModuleStreamExpansion:
|
||||
mmd.remove_dependencies(deps)
|
||||
mmd.add_dependencies(new_deps)
|
||||
|
||||
make_module("platform:lp29.1.1:12:c11", {}, {}, virtual_streams=virtual_streams)
|
||||
make_module(db_session, "platform:lp29.1.1:12:c11", {}, {}, virtual_streams=virtual_streams)
|
||||
|
||||
mmds = module_build_service.utils.mse._get_base_module_mmds(mmd)
|
||||
if virtual_streams == ["f29"]:
|
||||
|
||||
Reference in New Issue
Block a user