- Fix unittests

This commit is contained in:
soksanichenko 2022-11-08 14:57:52 +02:00
parent 5a19ad2258
commit b14e85324c
5 changed files with 103 additions and 55 deletions

View File

@ -6,7 +6,7 @@ data:
stream: master
version: 20190318
context: abcdef
arch: armhfp
arch: x86_64
summary: Dummy module
description: Dummy module
license:

View File

@ -0,0 +1,20 @@
---
document: modulemd
version: 2
data:
name: module
stream: master
version: 20190318
context: abcdef
arch: x86_64
summary: Dummy module
description: Dummy module
license:
module:
- Beerware
content:
- Beerware
artifacts:
rpms:
- foobar-0:1.0-1.noarch
...

View File

@ -0,0 +1,20 @@
---
document: modulemd
version: 2
data:
name: scratch-module
stream: master
version: 20200710
context: abcdef
arch: x86_64
summary: Dummy module
description: Dummy module
license:
module:
- Beerware
content:
- Beerware
artifacts:
rpms:
- foobar-0:1.0-1.noarch
...

View File

@ -0,0 +1,20 @@
---
document: modulemd
version: 2
data:
name: scratch-module
stream: master
version: 20200710
context: abcdef
arch: x86_64
summary: Dummy module
description: Dummy module
license:
module:
- Beerware
content:
- Beerware
artifacts:
rpms:
- foobar-0:1.0-1.noarch
...

View File

@ -819,13 +819,16 @@ class TestAddModuleToVariantForKojiMock(helpers.PungiTestCase):
self.koji = mock.Mock()
self.koji.koji_module.pathinfo.typedir.return_value = "/koji"
self.koji.koji_module.pathinfo.topdir = MMDS_DIR
files = ["modulemd.x86_64.txt", "modulemd.armv7hl.txt", "modulemd.txt"]
files = [
"modulemd.x86_64.txt",
"scratch-module.x86_64.txt",
]
self.koji.koji_proxy.listArchives.return_value = [
{"btype": "module", "filename": fname} for fname in files
] + [{"btype": "foo"}]
]
self.buildinfo = {
"id": 1234,
"arch": "fake_arch",
"arch": "x86_64",
"extra": {
"typeinfo": {
"module": {
@ -840,22 +843,23 @@ class TestAddModuleToVariantForKojiMock(helpers.PungiTestCase):
}
def test_adding_module(self):
variant = mock.Mock(arches=[
"x86_64"
], arch_mmds={}, modules=[])
source_kojimock._add_module_to_variant(self.koji, variant, self.buildinfo)
self.assertEqual(
variant.arch_mmds,
{
"x86_64": {
"module:master:20190318:abcdef": MockModule(
"/mnt/koji/modules/fake_arch/module:master-20190318-abcdef"
),
},
},
variant = mock.Mock(
arches=[
"x86_64"
],
arch_mmds={},
modules=[],
)
source_kojimock._add_module_to_variant(
self.koji,
variant,
self.buildinfo,
)
mod = variant.arch_mmds["x86_64"]["module:master:20190318:abcdef"]
self.assertEqual(mod.get_NSVCA(), "module:master:20190318:abcdef:x86_64")
self.assertEqual(len(variant.arch_mmds), 1)
self.assertEqual(variant.modules, [])
def test_adding_module_to_existing(self):
@ -864,26 +868,22 @@ class TestAddModuleToVariantForKojiMock(helpers.PungiTestCase):
"x86_64"
],
arch_mmds={
"x86_64": {"m1:latest:20190101:cafe": MockModule("/mnt/koji/modules/fake_arch/m1:latest:20190101:cafe")}
"x86_64": {
"m1:latest:20190101:cafe": read_single_module_stream_from_file(
os.path.join(MMDS_DIR, "m1.x86_64.txt")
)}
},
modules=[{"name": "m1:latest-20190101:cafe", "glob": False}],
)
source_kojimock._add_module_to_variant(self.koji, variant, self.buildinfo)
source_koji._add_module_to_variant(self.koji, variant, self.buildinfo)
mod = variant.arch_mmds["x86_64"]["m1:latest:20190101:cafe"]
self.assertEqual(mod.get_NSVCA(), "m1:latest:20190101:cafe:x86_64")
self.assertEqual(
variant.arch_mmds,
{
"x86_64": {
"module:master:20190318:abcdef": MockModule(
"/mnt/koji/modules/fake_arch/module:master-20190318-abcdef"
),
"m1:latest:20190101:cafe": MockModule("/mnt/koji/modules/fake_arch/m1:latest:20190101:cafe"),
},
},
)
self.assertEqual(
variant.modules, [{"name": "m1:latest-20190101:cafe", "glob": False}]
variant.modules,
[{"name": "m1:latest-20190101:cafe", "glob": False}]
)
def test_adding_module_with_add_module(self):
@ -895,16 +895,9 @@ class TestAddModuleToVariantForKojiMock(helpers.PungiTestCase):
self.koji, variant, self.buildinfo, add_to_variant_modules=True
)
self.assertEqual(
variant.arch_mmds,
{
"x86_64": {
"module:master:20190318:abcdef": MockModule(
"/mnt/koji/modules/fake_arch/module:master-20190318-abcdef"
)
},
},
)
mod = variant.arch_mmds["x86_64"]["module:master:20190318:abcdef"]
self.assertEqual(mod.get_NSVCA(), "module:master:20190318:abcdef:x86_64")
self.assertEqual(
variant.modules, [{"name": "module:master:20190318:abcdef", "glob": False}]
)
@ -915,7 +908,10 @@ class TestAddModuleToVariantForKojiMock(helpers.PungiTestCase):
"x86_64"
],
arch_mmds={
"x86_64": {"m1:latest:20190101:cafe": MockModule("/mnt/koji/modules/fake_arch/m1:latest:20190101:cafe")}
"x86_64": {"m1:latest:20190101:cafe": read_single_module_stream_from_file(
os.path.join(MMDS_DIR, "m1.x86_64.txt")
)
}
},
modules=[{"name": "m1:latest-20190101:cafe", "glob": False}],
)
@ -924,17 +920,9 @@ class TestAddModuleToVariantForKojiMock(helpers.PungiTestCase):
self.koji, variant, self.buildinfo, add_to_variant_modules=True
)
self.assertEqual(
variant.arch_mmds,
{
"x86_64": {
"module:master:20190318:abcdef": MockModule(
"/mnt/koji/modules/fake_arch/module:master-20190318-abcdef"
),
"m1:latest:20190101:cafe": MockModule("/mnt/koji/modules/fake_arch/m1:latest:20190101:cafe"),
},
},
)
mod = variant.arch_mmds["x86_64"]["m1:latest:20190101:cafe"]
self.assertEqual(mod.get_NSVCA(), "m1:latest:20190101:cafe:x86_64")
self.assertEqual(
variant.modules,
[