| |
@@ -3,7 +3,7 @@
|
| |
from __future__ import absolute_import
|
| |
|
| |
import pytest
|
| |
-
|
| |
+ from mock import patch, PropertyMock
|
| |
from module_build_service.common.errors import StreamAmbigous, ValidationError
|
| |
from module_build_service.scheduler.db_session import db_session
|
| |
from module_build_service.web.mse import (
|
| |
@@ -53,6 +53,24 @@
|
| |
make_module_in_db("foo:2:0:c5", f29_deps, base_module=platform_f29)
|
| |
make_module_in_db("app:1:0:c6", f29_deps, base_module=platform_f29)
|
| |
|
| |
+ def _generate_eln_modules(self):
|
| |
+ """
|
| |
+ Generates gtk:1, gtk:2, foo:1 and foo:2 modules requiring the
|
| |
+ platform:eln module.
|
| |
+ """
|
| |
+ platform_eln = make_module_in_db("platform:eln:0:c12")
|
| |
+
|
| |
+ eln_deps = [{
|
| |
+ "requires": {"platform": ["eln"]},
|
| |
+ "buildrequires": {"platform": ["eln"]}
|
| |
+ }]
|
| |
+
|
| |
+ make_module_in_db("gtk:1:0:c7", eln_deps, base_module=platform_eln)
|
| |
+ make_module_in_db("gtk:2:0:c8", eln_deps, base_module=platform_eln)
|
| |
+ make_module_in_db("foo:1:0:c7", eln_deps, base_module=platform_eln)
|
| |
+ make_module_in_db("foo:2:0:c8", eln_deps, base_module=platform_eln)
|
| |
+ make_module_in_db("app:1:0:c9", eln_deps, base_module=platform_eln)
|
| |
+
|
| |
def test_generate_expanded_mmds_context(self):
|
| |
self._generate_default_modules()
|
| |
module_build = make_module_in_db(
|
| |
@@ -273,9 +291,12 @@
|
| |
"platform:f29:0:c11",
|
| |
"gtk:2:0:c4",
|
| |
"gtk:2:0:c5",
|
| |
+ "gtk:2:0:c8",
|
| |
"platform:f28:0:c10",
|
| |
"gtk:1:0:c2",
|
| |
"gtk:1:0:c3",
|
| |
+ "gtk:1:0:c7",
|
| |
+ "platform:eln:0:c12",
|
| |
],
|
| |
),
|
| |
(
|
| |
@@ -287,9 +308,12 @@
|
| |
"platform:f28:0:c10",
|
| |
"gtk:1:0:c2",
|
| |
"gtk:1:0:c3",
|
| |
+ "gtk:1:0:c7",
|
| |
"foo:1:0:c2",
|
| |
"foo:1:0:c3",
|
| |
+ "foo:1:0:c7",
|
| |
"platform:f29:0:c11",
|
| |
+ "platform:eln:0:c12",
|
| |
],
|
| |
),
|
| |
(
|
| |
@@ -313,14 +337,19 @@
|
| |
[
|
| |
"foo:1:0:c2",
|
| |
"foo:1:0:c3",
|
| |
+ "foo:1:0:c7",
|
| |
"foo:2:0:c4",
|
| |
"foo:2:0:c5",
|
| |
+ "foo:2:0:c8",
|
| |
"platform:f28:0:c10",
|
| |
"platform:f29:0:c11",
|
| |
+ "platform:eln:0:c12",
|
| |
"gtk:1:0:c2",
|
| |
"gtk:1:0:c3",
|
| |
+ "gtk:1:0:c7",
|
| |
"gtk:2:0:c4",
|
| |
"gtk:2:0:c5",
|
| |
+ "gtk:2:0:c8",
|
| |
],
|
| |
),
|
| |
(
|
| |
@@ -331,17 +360,180 @@
|
| |
[
|
| |
"foo:1:0:c2",
|
| |
"foo:1:0:c3",
|
| |
+ "foo:1:0:c7",
|
| |
"platform:f29:0:c11",
|
| |
"platform:f28:0:c10",
|
| |
+ "platform:eln:0:c12",
|
| |
"gtk:1:0:c2",
|
| |
"gtk:1:0:c3",
|
| |
+ "gtk:1:0:c7",
|
| |
],
|
| |
),
|
| |
],
|
| |
)
|
| |
- def test_get_required_modules_simple(self, module_deps, expected):
|
| |
+ def test_get_required_modules_simple(
|
| |
+ self, module_deps, expected
|
| |
+ ):
|
| |
+ module_build = make_module_in_db("app:1:0:c1", module_deps)
|
| |
+ self._generate_default_modules()
|
| |
+ self._generate_eln_modules()
|
| |
+ nsvcs = self._get_mmds_required_by_module_recursively(module_build, db_session)
|
| |
+ assert set(nsvcs) == set(expected)
|
| |
+
|
| |
+ @patch(
|
| |
+ "module_build_service.common.config.Config.base_module_stream_exclusions",
|
| |
+ new_callable=PropertyMock,
|
| |
+ return_value=["eln"],
|
| |
+ )
|
| |
+ @pytest.mark.parametrize(
|
| |
+ "module_deps,expected",
|
| |
+ [
|
| |
+ (
|
| |
+ [{"requires": {}, "buildrequires": {"platform": [], "gtk": ["1", "2"]}}],
|
| |
+ [
|
| |
+ "platform:f29:0:c11",
|
| |
+ "gtk:2:0:c4",
|
| |
+ "gtk:2:0:c5",
|
| |
+ "platform:f28:0:c10",
|
| |
+ "gtk:1:0:c2",
|
| |
+ "gtk:1:0:c3",
|
| |
+ ],
|
| |
+ ),
|
| |
+ (
|
| |
+ [{
|
| |
+ "requires": {},
|
| |
+ "buildrequires": {"platform": [], "gtk": ["1"], "foo": ["1"]}
|
| |
+ }],
|
| |
+ [
|
| |
+ "platform:f28:0:c10",
|
| |
+ "gtk:1:0:c2",
|
| |
+ "gtk:1:0:c3",
|
| |
+ "foo:1:0:c2",
|
| |
+ "foo:1:0:c3",
|
| |
+ "platform:f29:0:c11",
|
| |
+ ],
|
| |
+ ),
|
| |
+ (
|
| |
+ [{
|
| |
+ "requires": {},
|
| |
+ "buildrequires": {"gtk": ["1"], "foo": ["1"], "platform": ["f28"]}
|
| |
+ }],
|
| |
+ ["platform:f28:0:c10", "gtk:1:0:c2", "foo:1:0:c2"],
|
| |
+ ),
|
| |
+ (
|
| |
+ [
|
| |
+ {
|
| |
+ "requires": {},
|
| |
+ "buildrequires": {"platform": [], "gtk": ["1"], "foo": ["1"]}
|
| |
+ },
|
| |
+ {
|
| |
+ "requires": {},
|
| |
+ "buildrequires": {"platform": [], "gtk": ["2"], "foo": ["2"]},
|
| |
+ }
|
| |
+ ],
|
| |
+ [
|
| |
+ "foo:1:0:c2",
|
| |
+ "foo:1:0:c3",
|
| |
+ "foo:2:0:c4",
|
| |
+ "foo:2:0:c5",
|
| |
+ "platform:f28:0:c10",
|
| |
+ "platform:f29:0:c11",
|
| |
+ "gtk:1:0:c2",
|
| |
+ "gtk:1:0:c3",
|
| |
+ "gtk:2:0:c4",
|
| |
+ "gtk:2:0:c5",
|
| |
+ ],
|
| |
+ ),
|
| |
+ (
|
| |
+ [{
|
| |
+ "requires": {},
|
| |
+ "buildrequires": {"platform": [], "gtk": ["-2"], "foo": ["-2"]},
|
| |
+ }],
|
| |
+ [
|
| |
+ "foo:1:0:c2",
|
| |
+ "foo:1:0:c3",
|
| |
+ "platform:f29:0:c11",
|
| |
+ "platform:f28:0:c10",
|
| |
+ "gtk:1:0:c2",
|
| |
+ "gtk:1:0:c3",
|
| |
+ ],
|
| |
+ ),
|
| |
+ ],
|
| |
+ )
|
| |
+ def test_get_required_modules_exclusion(
|
| |
+ self, mocked_base_module_stream_exclusions, module_deps, expected
|
| |
+ ):
|
| |
+ module_build = make_module_in_db("app:1:0:c1", module_deps)
|
| |
+ self._generate_default_modules()
|
| |
+ self._generate_eln_modules()
|
| |
+ nsvcs = self._get_mmds_required_by_module_recursively(module_build, db_session)
|
| |
+ assert set(nsvcs) == set(expected)
|
| |
+
|
| |
+ @patch(
|
| |
+ "module_build_service.common.config.Config.base_module_stream_exclusions",
|
| |
+ new_callable=PropertyMock,
|
| |
+ return_value=["eln"],
|
| |
+ )
|
| |
+ @pytest.mark.parametrize(
|
| |
+ "module_deps,expected",
|
| |
+ [
|
| |
+ (
|
| |
+ [{"requires": {}, "buildrequires": {"platform": ["eln"], "gtk": ["1", "2"]}}],
|
| |
+ [
|
| |
+ "platform:eln:0:c12",
|
| |
+ "gtk:1:0:c7",
|
| |
+ "gtk:2:0:c8",
|
| |
+ ],
|
| |
+ ),
|
| |
+ (
|
| |
+ [{
|
| |
+ "requires": {},
|
| |
+ "buildrequires": {"platform": ["eln"], "gtk": ["1"], "foo": ["1"]}
|
| |
+ }],
|
| |
+ [
|
| |
+ "platform:eln:0:c12",
|
| |
+ "gtk:1:0:c7",
|
| |
+ "foo:1:0:c7",
|
| |
+ ],
|
| |
+ ),
|
| |
+ (
|
| |
+ [
|
| |
+ {
|
| |
+ "requires": {},
|
| |
+ "buildrequires": {"platform": ["eln"], "gtk": ["1"], "foo": ["1"]}
|
| |
+ },
|
| |
+ {
|
| |
+ "requires": {},
|
| |
+ "buildrequires": {"platform": ["eln"], "gtk": ["2"], "foo": ["2"]},
|
| |
+ }
|
| |
+ ],
|
| |
+ [
|
| |
+ "foo:1:0:c7",
|
| |
+ "foo:2:0:c8",
|
| |
+ "gtk:1:0:c7",
|
| |
+ "gtk:2:0:c8",
|
| |
+ "platform:eln:0:c12",
|
| |
+ ],
|
| |
+ ),
|
| |
+ (
|
| |
+ [{
|
| |
+ "requires": {},
|
| |
+ "buildrequires": {"platform": ["eln"], "gtk": ["-2"], "foo": ["-2"]},
|
| |
+ }],
|
| |
+ [
|
| |
+ "platform:eln:0:c12",
|
| |
+ "foo:1:0:c7",
|
| |
+ "gtk:1:0:c7",
|
| |
+ ],
|
| |
+ ),
|
| |
+ ],
|
| |
+ )
|
| |
+ def test_get_required_modules_explicit_dep(
|
| |
+ self, mocked_base_module_stream_exclusions, module_deps, expected
|
| |
+ ):
|
| |
module_build = make_module_in_db("app:1:0:c1", module_deps)
|
| |
self._generate_default_modules()
|
| |
+ self._generate_eln_modules()
|
| |
nsvcs = self._get_mmds_required_by_module_recursively(module_build, db_session)
|
| |
assert set(nsvcs) == set(expected)
|
| |
|
| |
Fixes: #1639