| |
@@ -1,222 +1,258 @@
|
| |
+ import copy
|
| |
import pytest
|
| |
import requests_mock
|
| |
|
| |
- from module_diff.pdc import PDC
|
| |
+ from module_diff.mbs import MBS
|
| |
+ from module_diff.module import Module
|
| |
|
| |
|
| |
- module1_url = ("https://pdc.fedoraproject.org/rest_api/v1"
|
| |
- "/unreleasedvariants/"
|
| |
- "?page_size=1&variant_uid=mariadb-10.2-20171019133930")
|
| |
+ module1_url = ("https://mbs.fedoraproject.org/module-build-service/1/module-builds/"
|
| |
+ "?verbose=true&name=mariadb&stream=10.2&version=20171019133930&context=00000000")
|
| |
|
| |
- module2_url = ("https://pdc.fedoraproject.org/rest_api/v1"
|
| |
- "/unreleasedvariants/"
|
| |
- "?page_size=1&variant_uid=mariadb-10.2-20171103103655")
|
| |
+ module2_url = ("https://mbs.fedoraproject.org/module-build-service/1/module-builds/"
|
| |
+ "?verbose=true&name=mariadb&stream=10.2&version=20171103103655&context=00000000")
|
| |
|
| |
- module_diff_ns_url = ("https://pdc.fedoraproject.org/rest_api/v1"
|
| |
- "/unreleasedvariants/"
|
| |
- "?page_size=1&variant_uid=platform-f27-20171011150016")
|
| |
+ module_diff_ns_url = (
|
| |
+ "https://mbs.fedoraproject.org/module-build-service/1/module-builds/"
|
| |
+ "?verbose=true&name=platform&stream=f27&version=20171011150016&context=00000000")
|
| |
|
| |
|
| |
- @pytest.mark.usefixtures("pdc_json_res")
|
| |
+ @pytest.mark.usefixtures("mbs_json_res")
|
| |
class TestModule(object):
|
| |
"""
|
| |
Tests for the Module Class
|
| |
"""
|
| |
|
| |
- def test_get_diff_no_diff(self, pdc_json_res):
|
| |
+ def test_get_diff_no_diff(self, mbs_json_res):
|
| |
""" Test if we dont have any diff between modules. """
|
| |
|
| |
- module1_res = pdc_json_res.get()
|
| |
- module2_res = pdc_json_res.get()
|
| |
- module2_res["results"][0]["koji_tag"] = "module-15d35d06c29b1848"
|
| |
+ module1_res = copy.deepcopy(mbs_json_res)
|
| |
+ module2_res = copy.deepcopy(mbs_json_res)
|
| |
+ module2_res["koji_tag"] = "module-15d35d06c29b1848"
|
| |
|
| |
with requests_mock.mock() as mock_http:
|
| |
mock_http.register_uri("GET", module1_url, json=module1_res)
|
| |
mock_http.register_uri("GET", module2_url, json=module2_res)
|
| |
- pdc = PDC()
|
| |
- module1 = pdc.get_module("mariadb-10.2-20171019133930")
|
| |
- module2 = pdc.get_module("mariadb-10.2-20171103103655")
|
| |
+ mbs = MBS()
|
| |
+ module1 = Module(mbs.get_module("mariadb-10.2-20171019133930-00000000"))
|
| |
+ module2 = Module(mbs.get_module("mariadb-10.2-20171103103655-00000000"))
|
| |
|
| |
- diff = module1.get_diff(module2, reused=True)
|
| |
+ module1.reused = True
|
| |
+ diff = module1.get_diff(module2)
|
| |
|
| |
assert diff["added_rpms"] == []
|
| |
assert diff["removed_rpms"] == []
|
| |
assert diff["upgraded_rpms"] == []
|
| |
assert diff["downgraded_rpms"] == []
|
| |
- assert len(diff["reused_rpms"]) == 7
|
| |
+ assert len(diff["reused_rpms"]) == 6
|
| |
|
| |
- def test_get_diff(self, pdc_json_res):
|
| |
+ def test_get_diff(self, mbs_json_res):
|
| |
""" Testing different kinds of changes in modules """
|
| |
|
| |
- module1_res = pdc_json_res.get()
|
| |
- module2_res = pdc_json_res.get()
|
| |
- module1_res["results"][0]["rpms"].remove(
|
| |
- "mariadb-connect-engine-3:10.2.9-3.module_629c669e.x86_64.rpm")
|
| |
- module2_res["results"][0]["koji_tag"] = "module-15d35d06c29b1848"
|
| |
- module2_res["results"][0]["rpms"] = [
|
| |
- "mariadb-debugsource-3:10.2.9-3.module_629c669e.x86_64.rpm",
|
| |
- "mariadb-connect-engine-debuginfo-3:10.2.9-3.module_629c669e.x86_64.rpm",
|
| |
- "mariadb-debuginfo-3:11.2.9-3.module_15d35d06.x86_64.rpm",
|
| |
- "mariadb-3:10.2.9-3.module_629c669e.x86_64.rpm",
|
| |
- "mariadb-devel-3:9.2.9-3.module_15d35d06.x86_64.rpm",
|
| |
- "mariadb-connect-engine-3:10.2.9-3.module_15d35d06.x86_64.rpm"
|
| |
- ]
|
| |
+ module1_res = copy.deepcopy(mbs_json_res)
|
| |
+ module2_res = copy.deepcopy(mbs_json_res)
|
| |
+ del module1_res["items"][0]["tasks"]["rpms"]["mariadb-connect-engine"]
|
| |
+ module2_res["items"][0]["koji_tag"] = "module-15d35d06c29b1848"
|
| |
+ module2_res["items"][0]["tasks"]["rpms"] = {
|
| |
+ "mariadb-debugsource": {
|
| |
+ "nvr": "mariadb-debugsource-3:10.2.9-3.module_629c669e",
|
| |
+ },
|
| |
+ "mariadb-connect-engine-debuginfo": {
|
| |
+ "nvr": "mariadb-connect-engine-debuginfo-3:10.2.9-3.module_629c669e",
|
| |
+ },
|
| |
+ "mariadb-debuginfo": {
|
| |
+ "nvr": "mariadb-debuginfo-3:11.2.9-3.module_15d35d06",
|
| |
+ },
|
| |
+ "mariadb-devel": {
|
| |
+ "nvr": "mariadb-devel-3:9.2.9-3.module_15d35d06",
|
| |
+ },
|
| |
+ "mariadb-connect-engine": {
|
| |
+ "nvr": "mariadb-connect-engine-3:10.2.9-3.module_15d35d06",
|
| |
+ },
|
| |
+ }
|
| |
|
| |
with requests_mock.mock() as mock_http:
|
| |
mock_http.register_uri("GET", module1_url, json=module1_res)
|
| |
mock_http.register_uri("GET", module2_url, json=module2_res)
|
| |
- pdc = PDC()
|
| |
- module1 = pdc.get_module("mariadb-10.2-20171019133930")
|
| |
- module2 = pdc.get_module("mariadb-10.2-20171103103655")
|
| |
+ mbs = MBS()
|
| |
+ module1 = Module(mbs.get_module("mariadb-10.2-20171019133930-00000000"))
|
| |
+ module2 = Module(mbs.get_module("mariadb-10.2-20171103103655-00000000"))
|
| |
|
| |
- diff = module1.get_diff(module2, reused=True)
|
| |
+ module1.reused = True
|
| |
+ diff = module1.get_diff(module2)
|
| |
|
| |
assert diff["added_rpms"] == [
|
| |
- "mariadb-connect-engine-3:10.2.9-3.module_15d35d06.x86_64.rpm"]
|
| |
- assert diff["removed_rpms"] == ["mariadb-3:10.2.9-3.module_629c669e.src.rpm"]
|
| |
+ "mariadb-connect-engine-3:10.2.9-3.module_15d35d06"]
|
| |
+ assert diff["removed_rpms"] == ["mariadb-3:10.2.9-3.module_629c669e"]
|
| |
assert diff["upgraded_rpms"] == [
|
| |
- ('mariadb-debuginfo-3:10.2.9-3.module_629c669e.x86_64.rpm',
|
| |
- 'mariadb-debuginfo-3:11.2.9-3.module_15d35d06.x86_64.rpm')]
|
| |
+ ('mariadb-debuginfo-3:10.2.9-3.module_629c669e',
|
| |
+ 'mariadb-debuginfo-3:11.2.9-3.module_15d35d06')]
|
| |
assert diff["downgraded_rpms"] == [
|
| |
- ('mariadb-devel-3:10.2.9-3.module_629c669e.x86_64.rpm',
|
| |
- 'mariadb-devel-3:9.2.9-3.module_15d35d06.x86_64.rpm')]
|
| |
- assert len(diff["reused_rpms"]) == 3
|
| |
+ ('mariadb-devel-3:10.2.9-3.module_629c669e',
|
| |
+ 'mariadb-devel-3:9.2.9-3.module_15d35d06')]
|
| |
+ assert len(diff["reused_rpms"]) == 2
|
| |
|
| |
- def test_get_diff_rpm_version_change(self, pdc_json_res):
|
| |
+ def test_get_diff_rpm_version_change(self, mbs_json_res):
|
| |
""" Testing if a version changes """
|
| |
|
| |
- module1_res = pdc_json_res.get()
|
| |
- module2_res = pdc_json_res.get()
|
| |
- module2_res["results"][0]["koji_tag"] = "module-15d35d06c29b1848"
|
| |
- module2_res["results"][0]["rpms"] = [
|
| |
- "mariadb-3:10.2.9-3.module_629c669e.src.rpm",
|
| |
- "mariadb-debugsource-3:11.2.9-3.module_15d35d06.x86_64.rpm",
|
| |
- "mariadb-connect-engine-debuginfo-3:10.2.8-3.module_15d35d06.x86_64.rpm",
|
| |
- "mariadb-debuginfo-3:10.2.9-3.module_629c669e.x86_64.rpm",
|
| |
- "mariadb-3:10.2.9-3.module_629c669e.x86_64.rpm",
|
| |
- "mariadb-devel-3:10.2.9-3.module_629c669e.x86_64.rpm",
|
| |
- "mariadb-connect-engine-3:10.2.9-3.module_629c669e.x86_64.rpm"
|
| |
- ]
|
| |
+ module1_res = copy.deepcopy(mbs_json_res)
|
| |
+ module2_res = copy.deepcopy(mbs_json_res)
|
| |
+ module2_res["items"][0]["koji_tag"] = "module-15d35d06c29b1848"
|
| |
+ module2_res["items"][0]["tasks"]["rpms"] = {
|
| |
+ "mariadb": {
|
| |
+ "nvr": "mariadb-3:10.2.9-3.module_629c669e",
|
| |
+ },
|
| |
+ "mariadb-debugsource": {
|
| |
+ "nvr": "mariadb-debugsource-3:11.2.9-3.module_15d35d06",
|
| |
+ },
|
| |
+ "mariadb-connect-engine-debuginfo": {
|
| |
+ "nvr": "mariadb-connect-engine-debuginfo-3:10.2.8-3.module_15d35d06",
|
| |
+ },
|
| |
+ "mariadb-debuginfo": {
|
| |
+ "nvr": "mariadb-debuginfo-3:10.2.9-3.module_629c669e",
|
| |
+ },
|
| |
+ "mariadb-devel": {
|
| |
+ "nvr": "mariadb-devel-3:10.2.9-3.module_629c669e",
|
| |
+ },
|
| |
+ "mariadb-connect-engine": {
|
| |
+ "nvr": "mariadb-connect-engine-3:10.2.9-3.module_629c669e"
|
| |
+ },
|
| |
+ }
|
| |
|
| |
with requests_mock.mock() as mock_http:
|
| |
mock_http.register_uri("GET", module1_url, json=module1_res)
|
| |
mock_http.register_uri("GET", module2_url, json=module2_res)
|
| |
- pdc = PDC()
|
| |
- module1 = pdc.get_module("mariadb-10.2-20171019133930")
|
| |
- module2 = pdc.get_module("mariadb-10.2-20171103103655")
|
| |
+ mbs = MBS()
|
| |
+ module1 = Module(mbs.get_module("mariadb-10.2-20171019133930-00000000"))
|
| |
+ module2 = Module(mbs.get_module("mariadb-10.2-20171103103655-00000000"))
|
| |
|
| |
- diff = module1.get_diff(module2, reused=True)
|
| |
+ module1.reused = True
|
| |
+ diff = module1.get_diff(module2)
|
| |
|
| |
assert diff["added_rpms"] == []
|
| |
assert diff["removed_rpms"] == []
|
| |
assert diff["upgraded_rpms"] == [
|
| |
- ('mariadb-debugsource-3:10.2.9-3.module_629c669e.x86_64.rpm',
|
| |
- 'mariadb-debugsource-3:11.2.9-3.module_15d35d06.x86_64.rpm')]
|
| |
+ ('mariadb-debugsource-3:10.2.9-3.module_629c669e',
|
| |
+ 'mariadb-debugsource-3:11.2.9-3.module_15d35d06')]
|
| |
assert diff["downgraded_rpms"] == [
|
| |
- ('mariadb-connect-engine-debuginfo-3:10.2.9-3.module_629c669e.x86_64.rpm',
|
| |
- 'mariadb-connect-engine-debuginfo-3:10.2.8-3.module_15d35d06.x86_64.rpm')]
|
| |
- assert len(diff["reused_rpms"]) == 5
|
| |
+ ('mariadb-connect-engine-debuginfo-3:10.2.9-3.module_629c669e',
|
| |
+ 'mariadb-connect-engine-debuginfo-3:10.2.8-3.module_15d35d06')]
|
| |
+ assert len(diff["reused_rpms"]) == 4
|
| |
|
| |
- def test_get_diff_rpm_removed(self, pdc_json_res):
|
| |
+ def test_get_diff_rpm_removed(self, mbs_json_res):
|
| |
""" Testing if the module changes of an RPM """
|
| |
|
| |
- module1_res = pdc_json_res.get()
|
| |
- module2_res = pdc_json_res.get()
|
| |
- module2_res["results"][0]["koji_tag"] = "module-15d35d06c29b1848"
|
| |
- module2_res["results"][0]["rpms"].remove("mariadb-3:10.2.9-3.module_629c669e.src.rpm")
|
| |
+ module1_res = copy.deepcopy(mbs_json_res)
|
| |
+ module2_res = copy.deepcopy(mbs_json_res)
|
| |
+ module2_res["items"][0]["koji_tag"] = "module-15d35d06c29b1848"
|
| |
+ del module2_res["items"][0]["tasks"]["rpms"]["mariadb"]
|
| |
|
| |
with requests_mock.mock() as mock_http:
|
| |
mock_http.register_uri("GET", module1_url, json=module1_res)
|
| |
mock_http.register_uri("GET", module2_url, json=module2_res)
|
| |
- pdc = PDC()
|
| |
- module1 = pdc.get_module("mariadb-10.2-20171019133930")
|
| |
- module2 = pdc.get_module("mariadb-10.2-20171103103655")
|
| |
+ mbs = MBS()
|
| |
+ module1 = Module(mbs.get_module("mariadb-10.2-20171019133930-00000000"))
|
| |
+ module2 = Module(mbs.get_module("mariadb-10.2-20171103103655-00000000"))
|
| |
|
| |
- diff = module1.get_diff(module2, reused=True)
|
| |
+ module1.reused = True
|
| |
+ diff = module1.get_diff(module2)
|
| |
|
| |
assert diff["added_rpms"] == []
|
| |
- assert diff["removed_rpms"] == ["mariadb-3:10.2.9-3.module_629c669e.src.rpm"]
|
| |
+ assert diff["removed_rpms"] == ["mariadb-3:10.2.9-3.module_629c669e"]
|
| |
assert diff["upgraded_rpms"] == []
|
| |
assert diff["downgraded_rpms"] == []
|
| |
- assert len(diff["reused_rpms"]) == 6
|
| |
+ assert len(diff["reused_rpms"]) == 5
|
| |
|
| |
- def test_get_diff_different_ns(self, pdc_json_res):
|
| |
+ def test_get_diff_different_ns(self, mbs_json_res):
|
| |
"""
|
| |
- If we have different name and stream between compared modules an error should be raised
|
| |
+ If we have different name and stream between compared modules
|
| |
+ an error should be raised
|
| |
"""
|
| |
- module1_res = pdc_json_res.get()
|
| |
- module2_res = pdc_json_res.get()
|
| |
- module2_res["results"][0]["variant_uid"] = "platform-f27-20171011150016"
|
| |
- module2_res["results"][0]["variant_name"] = "platform"
|
| |
- module2_res["results"][0]["variant_version"] = "f27"
|
| |
+ module1_res = copy.deepcopy(mbs_json_res)
|
| |
+ module2_res = copy.deepcopy(mbs_json_res)
|
| |
+ module2_res["items"][0]["nsvc"] = "platform-f27-20171011150016"
|
| |
+ module2_res["items"][0]["name"] = "platform"
|
| |
+ module2_res["items"][0]["stream"] = "f27"
|
| |
|
| |
with requests_mock.mock() as mock_http:
|
| |
mock_http.register_uri("GET", module1_url, json=module1_res)
|
| |
mock_http.register_uri("GET", module_diff_ns_url, json=module2_res)
|
| |
- pdc = PDC()
|
| |
- module1 = pdc.get_module("mariadb-10.2-20171019133930")
|
| |
- module2 = pdc.get_module("platform-f27-20171011150016")
|
| |
+ mbs = MBS()
|
| |
+ module1 = Module(mbs.get_module("mariadb-10.2-20171019133930-00000000"))
|
| |
+ module2 = Module(mbs.get_module("platform-f27-20171011150016-00000000"))
|
| |
|
| |
with pytest.raises(ValueError):
|
| |
module1.get_diff(module2)
|
| |
|
| |
- def test_get_diff_change_dist_tag(self, pdc_json_res):
|
| |
+ def test_get_diff_change_dist_tag(self, mbs_json_res):
|
| |
"""
|
| |
Testing if a distag changes between modules
|
| |
"""
|
| |
- module1_res = pdc_json_res.get()
|
| |
- module2_res = pdc_json_res.get()
|
| |
- module2_res["results"][0]["koji_tag"] = "module-15d35d06c29b1848"
|
| |
- module2_res["results"][0]["rpms"] = [
|
| |
- "mariadb-3:10.2.9-3.module_629c669e.src.rpm",
|
| |
- "mariadb-debugsource-3:10.2.9-3.module_15d35d06.x86_64.rpm",
|
| |
- "mariadb-connect-engine-debuginfo-3:10.2.9-3.module_629c669e.x86_64.rpm",
|
| |
- "mariadb-debuginfo-3:10.2.9-3.module_629c669e.x86_64.rpm",
|
| |
- "mariadb-3:10.2.9-3.module_629c669e.x86_64.rpm",
|
| |
- "mariadb-devel-3:10.2.9-3.module_629c669e.x86_64.rpm",
|
| |
- "mariadb-connect-engine-3:10.2.9-3.module_629c669e.x86_64.rpm"
|
| |
- ]
|
| |
+ module1_res = copy.deepcopy(mbs_json_res)
|
| |
+ module2_res = copy.deepcopy(mbs_json_res)
|
| |
+ module2_res["items"][0]["koji_tag"] = "module-15d35d06c29b1848"
|
| |
+ module2_res["items"][0]["tasks"]["rpms"] = {
|
| |
+ "mariadb": {
|
| |
+ "nvr": "mariadb-3:10.2.9-3.module_629c669e",
|
| |
+ },
|
| |
+ "mariadb-debugsource": {
|
| |
+ "nvr": "mariadb-debugsource-3:10.2.9-3.module_15d35d06",
|
| |
+ },
|
| |
+ "mariadb-connect-engine-debuginfo": {
|
| |
+ "nvr": "mariadb-connect-engine-debuginfo-3:10.2.9-3.module_629c669e",
|
| |
+ },
|
| |
+ "mariadb-debuginfo": {
|
| |
+ "nvr": "mariadb-debuginfo-3:10.2.9-3.module_629c669e",
|
| |
+ },
|
| |
+ "mariadb-devel": {
|
| |
+ "nvr": "mariadb-devel-3:10.2.9-3.module_629c669e",
|
| |
+ },
|
| |
+ "mariadb-connect-engine": {
|
| |
+ "nvr": "mariadb-connect-engine-3:10.2.9-3.module_629c669e"
|
| |
+ },
|
| |
+ }
|
| |
|
| |
with requests_mock.mock() as mock_http:
|
| |
mock_http.register_uri("GET", module1_url, json=module1_res)
|
| |
mock_http.register_uri("GET", module2_url, json=module2_res)
|
| |
- pdc = PDC()
|
| |
- module1 = pdc.get_module("mariadb-10.2-20171019133930")
|
| |
- module2 = pdc.get_module("mariadb-10.2-20171103103655")
|
| |
+ mbs = MBS()
|
| |
+ module1 = Module(mbs.get_module("mariadb-10.2-20171019133930-00000000"))
|
| |
+ module2 = Module(mbs.get_module("mariadb-10.2-20171103103655-00000000"))
|
| |
|
| |
- diff = module1.get_diff(module2, reused=True, dist=True)
|
| |
+ module1.reused = True
|
| |
+ module1.dist = True
|
| |
+ diff = module1.get_diff(module2)
|
| |
|
| |
assert diff["added_rpms"] == []
|
| |
assert diff["removed_rpms"] == []
|
| |
assert diff["upgraded_rpms"] == []
|
| |
assert diff["downgraded_rpms"] == []
|
| |
- assert len(diff["reused_rpms"]) == 6
|
| |
+ assert len(diff["reused_rpms"]) == 5
|
| |
assert diff["changed_distag_rpms"] == [
|
| |
- ("mariadb-debugsource-3:10.2.9-3.module_629c669e.x86_64.rpm",
|
| |
- "mariadb-debugsource-3:10.2.9-3.module_15d35d06.x86_64.rpm")]
|
| |
+ ("mariadb-debugsource-3:10.2.9-3.module_629c669e",
|
| |
+ "mariadb-debugsource-3:10.2.9-3.module_15d35d06")]
|
| |
|
| |
- def test_get_rpm_md(self, pdc_json_res):
|
| |
+ def test_get_rpm_md(self, mbs_json_res):
|
| |
"""
|
| |
Testing to get correct metadata from name of a rpm file.
|
| |
"""
|
| |
- module1_res = pdc_json_res.get()
|
| |
+ module1_res = copy.deepcopy(mbs_json_res)
|
| |
|
| |
with requests_mock.mock() as mock_http:
|
| |
mock_http.register_uri("GET", module1_url, json=module1_res)
|
| |
- pdc = PDC()
|
| |
- module1 = pdc.get_module("mariadb-10.2-20171019133930")
|
| |
+ mbs = MBS()
|
| |
+ module1 = Module(mbs.get_module("mariadb-10.2-20171019133930-00000000"))
|
| |
|
| |
- rpm = "python3-hawkey-debuginfo-0:0.10.1-2.module_80d712e7.modularity.1.x86_64.rpm"
|
| |
+ rpm = "python3-hawkey-debuginfo-0:0.10.1-2.module_80d712e7"
|
| |
|
| |
md = module1.get_rpm_md(rpm)
|
| |
|
| |
- expected_md = {'arch': 'x86_64',
|
| |
- 'dist_tag': 'module_80d712e7',
|
| |
+ expected_md = {'dist_tag': 'module_80d712e7',
|
| |
'epoch': '0',
|
| |
'full_name': ('python3-hawkey-debuginfo-0:0.10.1-2'
|
| |
- '.module_80d712e7.modularity.1.x86_64.rpm'),
|
| |
+ '.module_80d712e7'),
|
| |
'name': 'python3-hawkey-debuginfo',
|
| |
- 'release': '2.module_80d712e7.modularityx86_64rpm',
|
| |
+ 'release': '2',
|
| |
'version': '0.10.1'}
|
| |
|
| |
assert md == expected_md
|
| |
do we need a try/except blog here? as if the res.json failed then there would more problems like only wrong request. You are checking the request above. Also when you reraise you are losing the original traceback. Removet the excetpiont.