repoclosure: Add test for repoclosure in test phase

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-01-26 09:44:45 +01:00
parent 56932f9067
commit 95fc0fa4ab
2 changed files with 48 additions and 9 deletions

View File

@ -30,6 +30,10 @@ class PungiTestCase(unittest.TestCase):
class MockVariant(mock.Mock):
def __init__(self, *args, **kwargs):
super(MockVariant, self).__init__(*args, **kwargs)
self.parent = kwargs.get('parent', None)
def __str__(self):
return self.uid

View File

@ -40,7 +40,7 @@ class TestCheckImageSanity(PungiTestCase):
try:
test_phase.check_image_sanity(compose)
except:
except Exception:
self.fail('Failable deliverable must not raise')
def test_correct_iso_does_not_raise(self):
@ -51,7 +51,7 @@ class TestCheckImageSanity(PungiTestCase):
try:
test_phase.check_image_sanity(compose)
except:
except Exception:
self.fail('Correct unbootable image must not raise')
def test_incorrect_iso_raises(self):
@ -87,7 +87,7 @@ class TestCheckImageSanity(PungiTestCase):
try:
test_phase.check_image_sanity(compose)
except:
except Exception:
self.fail('Failable deliverable must not raise')
def test_failable_bootable_iso_without_mbr_gpt_doesnt_raise(self):
@ -100,7 +100,7 @@ class TestCheckImageSanity(PungiTestCase):
try:
test_phase.check_image_sanity(compose)
except:
except Exception:
self.fail('Failable deliverable must not raise')
def test_bootable_iso_with_mbr_does_not_raise(self):
@ -111,7 +111,7 @@ class TestCheckImageSanity(PungiTestCase):
try:
test_phase.check_image_sanity(compose)
except:
except Exception:
self.fail('Bootable image with MBR must not raise')
def test_bootable_iso_with_gpt_does_not_raise(self):
@ -122,7 +122,7 @@ class TestCheckImageSanity(PungiTestCase):
try:
test_phase.check_image_sanity(compose)
except:
except Exception:
self.fail('Bootable image with GPT must not raise')
def test_bootable_iso_with_mbr_and_gpt_does_not_raise(self):
@ -133,7 +133,7 @@ class TestCheckImageSanity(PungiTestCase):
try:
test_phase.check_image_sanity(compose)
except:
except Exception:
self.fail('Bootable image with MBR and GPT must not raise')
def test_bootable_iso_with_el_torito_does_not_raise(self):
@ -144,7 +144,7 @@ class TestCheckImageSanity(PungiTestCase):
try:
test_phase.check_image_sanity(compose)
except:
except Exception:
self.fail('Bootable image with El Torito must not raise')
def test_checks_with_optional_variant(self):
@ -163,9 +163,44 @@ class TestCheckImageSanity(PungiTestCase):
try:
test_phase.check_image_sanity(compose)
except:
except Exception:
self.fail('Checking optional variant must not raise')
class TestRepoclosure(PungiTestCase):
def _get_repo(self, variant, arch, path=None):
path = path or arch + '/os'
return {
'repoclosure-%s.%s' % (variant, arch): self.topdir + '/compose/%s/%s' % (variant, path)
}
@mock.patch('pungi.wrappers.repoclosure.get_repoclosure_cmd')
@mock.patch('pungi.phases.test.run')
def test_calls_repoclosure(self, mock_run, mock_grc):
compose = DummyCompose(self.topdir, {})
test_phase.run_repoclosure(compose)
self.maxDiff = None
all_repos = {}
for variant in compose.variants.itervalues():
for arch in variant.arches:
all_repos.update(self._get_repo(variant.uid, arch))
all_repos.update(self._get_repo(variant.uid, 'src', 'source/tree'))
self.assertItemsEqual(
mock_grc.call_args_list,
[mock.call(arch=['amd64', 'x86_64', 'noarch'], lookaside={},
repos=self._get_repo('Everything', 'amd64')),
mock.call(arch=['amd64', 'x86_64', 'noarch'], lookaside={},
repos=self._get_repo('Client', 'amd64')),
mock.call(arch=['amd64', 'x86_64', 'noarch'], lookaside={},
repos=self._get_repo('Server', 'amd64')),
mock.call(arch=['x86_64', 'noarch'], lookaside={},
repos=self._get_repo('Server', 'x86_64')),
mock.call(arch=['x86_64', 'noarch'], lookaside={},
repos=self._get_repo('Everything', 'x86_64')),
mock.call(arch={'x86_64', 'amd64', 'noarch'}, builddeps=True, repos=all_repos)])
if __name__ == "__main__":
unittest.main()