- 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 stream: master
version: 20190318 version: 20190318
context: abcdef context: abcdef
arch: armhfp arch: x86_64
summary: Dummy module summary: Dummy module
description: Dummy module description: Dummy module
license: 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 = mock.Mock()
self.koji.koji_module.pathinfo.typedir.return_value = "/koji" self.koji.koji_module.pathinfo.typedir.return_value = "/koji"
self.koji.koji_module.pathinfo.topdir = MMDS_DIR 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 = [ self.koji.koji_proxy.listArchives.return_value = [
{"btype": "module", "filename": fname} for fname in files {"btype": "module", "filename": fname} for fname in files
] + [{"btype": "foo"}] ]
self.buildinfo = { self.buildinfo = {
"id": 1234, "id": 1234,
"arch": "fake_arch", "arch": "x86_64",
"extra": { "extra": {
"typeinfo": { "typeinfo": {
"module": { "module": {
@ -840,22 +843,23 @@ class TestAddModuleToVariantForKojiMock(helpers.PungiTestCase):
} }
def test_adding_module(self): def test_adding_module(self):
variant = mock.Mock(arches=[ variant = mock.Mock(
"x86_64" arches=[
], arch_mmds={}, modules=[]) "x86_64"
],
source_kojimock._add_module_to_variant(self.koji, variant, self.buildinfo) arch_mmds={},
modules=[],
self.assertEqual(
variant.arch_mmds,
{
"x86_64": {
"module:master:20190318:abcdef": MockModule(
"/mnt/koji/modules/fake_arch/module:master-20190318-abcdef"
),
},
},
) )
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, []) self.assertEqual(variant.modules, [])
def test_adding_module_to_existing(self): def test_adding_module_to_existing(self):
@ -864,26 +868,22 @@ class TestAddModuleToVariantForKojiMock(helpers.PungiTestCase):
"x86_64" "x86_64"
], ],
arch_mmds={ 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}], 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( self.assertEqual(
variant.arch_mmds, variant.modules,
{ [{"name": "m1:latest-20190101:cafe", "glob": False}]
"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}]
) )
def test_adding_module_with_add_module(self): 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.koji, variant, self.buildinfo, add_to_variant_modules=True
) )
self.assertEqual( mod = variant.arch_mmds["x86_64"]["module:master:20190318:abcdef"]
variant.arch_mmds, self.assertEqual(mod.get_NSVCA(), "module:master:20190318:abcdef:x86_64")
{
"x86_64": {
"module:master:20190318:abcdef": MockModule(
"/mnt/koji/modules/fake_arch/module:master-20190318-abcdef"
)
},
},
)
self.assertEqual( self.assertEqual(
variant.modules, [{"name": "module:master:20190318:abcdef", "glob": False}] variant.modules, [{"name": "module:master:20190318:abcdef", "glob": False}]
) )
@ -915,7 +908,10 @@ class TestAddModuleToVariantForKojiMock(helpers.PungiTestCase):
"x86_64" "x86_64"
], ],
arch_mmds={ 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}], 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.koji, variant, self.buildinfo, add_to_variant_modules=True
) )
self.assertEqual( mod = variant.arch_mmds["x86_64"]["m1:latest:20190101:cafe"]
variant.arch_mmds, self.assertEqual(mod.get_NSVCA(), "m1:latest:20190101:cafe:x86_64")
{
"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( self.assertEqual(
variant.modules, variant.modules,
[ [