Reduce duplication in tests
Set the dummy compose into non-debug mode in a single place, and only change it when needed. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
19a42792db
commit
7c5020e82d
@ -153,6 +153,8 @@ class DummyCompose(object):
|
||||
self.require_deliverable = mock.Mock()
|
||||
self.should_create_yum_database = True
|
||||
|
||||
self.DEBUG = False
|
||||
|
||||
def setup_optional(self):
|
||||
self.all_variants['Server-optional'] = MockVariant(
|
||||
uid='Server-optional', arches=['x86_64'], type='optional')
|
||||
|
@ -129,7 +129,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
compose = DummyCompose(self.topdir, {
|
||||
'createrepo_checksum': 'sha256',
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
|
||||
repo = CreaterepoWrapperCls.return_value
|
||||
@ -161,7 +160,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
})
|
||||
compose.should_create_yum_database = False
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
|
||||
repo = CreaterepoWrapperCls.return_value
|
||||
@ -192,7 +190,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
compose = DummyCompose(self.topdir, {
|
||||
'createrepo_checksum': 'sha256',
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
|
||||
repo = CreaterepoWrapperCls.return_value
|
||||
@ -225,7 +222,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
compose = DummyCompose(self.topdir, {
|
||||
'createrepo_checksum': 'sha256',
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
|
||||
repo = CreaterepoWrapperCls.return_value
|
||||
@ -258,7 +254,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_c': False,
|
||||
'createrepo_checksum': 'sha256',
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
|
||||
repo = CreaterepoWrapperCls.return_value
|
||||
@ -290,7 +285,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
'createrepo_num_workers': 10,
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
|
||||
repo = CreaterepoWrapperCls.return_value
|
||||
@ -324,7 +318,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
'createrepo_use_xz': True,
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
|
||||
repo = CreaterepoWrapperCls.return_value
|
||||
@ -356,7 +349,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
'createrepo_deltas': True,
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
compose.old_composes = [self.topdir + '/old']
|
||||
touch(os.path.join(self.topdir, 'old', 'test-1.0-20151203.0', 'STATUS'), 'FINISHED')
|
||||
@ -391,7 +383,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
'createrepo_deltas': [('^Server$', {'*': True})],
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
compose.old_composes = [self.topdir + '/old']
|
||||
touch(os.path.join(self.topdir, 'old', 'test-1.0-20151203.0', 'STATUS'), 'FINISHED')
|
||||
@ -426,7 +417,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
'createrepo_deltas': [('^Everything$', {'x86_64': True})],
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
compose.old_composes = [self.topdir + '/old']
|
||||
touch(os.path.join(self.topdir, 'old', 'test-1.0-20151203.0', 'STATUS'), 'FINISHED')
|
||||
@ -461,7 +451,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
'createrepo_deltas': [('^Server$', {'s390x': True})],
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
compose.old_composes = [self.topdir + '/old']
|
||||
touch(os.path.join(self.topdir, 'old', 'test-1.0-20151203.0', 'STATUS'), 'FINISHED')
|
||||
@ -496,7 +485,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_deltas': True,
|
||||
'hashed_directories': True,
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
compose.old_composes = [self.topdir + '/old']
|
||||
touch(os.path.join(self.topdir, 'old', 'test-1.0-20151203.0', 'STATUS'), 'FINISHED')
|
||||
@ -539,7 +527,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_deltas': True,
|
||||
'hashed_directories': True,
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
compose.old_composes = [self.topdir + '/old']
|
||||
touch(os.path.join(self.topdir, 'old', 'test-1.0-20151203.0', 'STATUS'), 'FINISHED')
|
||||
@ -576,7 +563,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
'createrepo_deltas': True,
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
compose.old_composes = [self.topdir + '/old']
|
||||
touch(os.path.join(self.topdir, 'old', 'test-1.0-20151203.0', 'STATUS'), 'FINISHED')
|
||||
@ -613,7 +599,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
'createrepo_deltas': True,
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
compose.old_composes = [self.topdir + '/old']
|
||||
touch(os.path.join(self.topdir, 'old', 'test-1.0-20151203.0', 'STATUS'), 'FINISHED')
|
||||
@ -647,7 +632,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
'product_id': 'yes', # Truthy value is enough for this test
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
product_id = compose.paths.work.product_id('x86_64', compose.variants['Server'])
|
||||
repodata_dir = os.path.join(
|
||||
@ -687,7 +671,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
'product_id': 'yes', # Truthy value is enough for this test
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
|
||||
repo = CreaterepoWrapperCls.return_value
|
||||
@ -719,7 +702,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
'createrepo_checksum': 'sha256',
|
||||
'product_id': 'yes', # Truthy value is enough for this test
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
|
||||
repo = CreaterepoWrapperCls.return_value
|
||||
@ -754,7 +736,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
compose = DummyCompose(self.topdir, {
|
||||
'createrepo_checksum': 'sha256',
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
|
||||
variant = compose.variants['Server']
|
||||
@ -798,7 +779,6 @@ class TestCreateVariantRepo(PungiTestCase):
|
||||
compose = DummyCompose(self.topdir, {
|
||||
'createrepo_checksum': 'sha256',
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.has_comps = False
|
||||
|
||||
variant = compose.variants['Server']
|
||||
|
@ -14,7 +14,6 @@ class TestWritePungiConfig(helpers.PungiTestCase):
|
||||
def setUp(self):
|
||||
super(TestWritePungiConfig, self).setUp()
|
||||
self.compose = helpers.DummyCompose(self.topdir, {})
|
||||
self.compose.DEBUG = False
|
||||
|
||||
def assertWritten(self, PungiWrapper, **kwargs):
|
||||
wrapper = PungiWrapper.return_value
|
||||
|
@ -16,7 +16,6 @@ class TestWritePungiConfig(helpers.PungiTestCase):
|
||||
def setUp(self):
|
||||
super(TestWritePungiConfig, self).setUp()
|
||||
self.compose = helpers.DummyCompose(self.topdir, {})
|
||||
self.compose.DEBUG = False
|
||||
self.compose.paths.work.comps = mock.Mock(return_value=COMPS_FILE)
|
||||
|
||||
def test_expand_group(self):
|
||||
|
@ -747,7 +747,6 @@ class TestWritePrepopulate(helpers.PungiTestCase):
|
||||
compose = helpers.DummyCompose(self.topdir, {
|
||||
'gather_prepopulate': 'input-prepopulate.json',
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.config_dir = self.topdir
|
||||
helpers.copy_fixture('prepopulate.json', os.path.join(self.topdir, 'input-prepopulate.json'))
|
||||
|
||||
@ -762,7 +761,6 @@ class TestWritePrepopulate(helpers.PungiTestCase):
|
||||
'repo': None,
|
||||
}
|
||||
})
|
||||
compose.DEBUG = False
|
||||
compose.config_dir = self.topdir
|
||||
helpers.copy_fixture('prepopulate.json', os.path.join(self.topdir, 'input-prepopulate.json'))
|
||||
|
||||
|
@ -22,7 +22,6 @@ class TestGatherSourceModule(helpers.PungiTestCase):
|
||||
super(TestGatherSourceModule, self).setUp()
|
||||
|
||||
self.compose = helpers.DummyCompose(self.topdir, {})
|
||||
self.compose.DEBUG = False
|
||||
self.mmd = self.compose.variants["Server"].add_fake_module(
|
||||
"testmodule:master:1:2017", rpm_nvrs=["pkg-0:1.0.0-1.x86_64", "pkg-0:1.0.0-1.i686"])
|
||||
|
||||
|
@ -171,7 +171,6 @@ class TestWriteArchComps(PungiTestCase):
|
||||
@mock.patch('pungi.phases.init.run')
|
||||
def test_run(self, run):
|
||||
compose = DummyCompose(self.topdir, {})
|
||||
compose.DEBUG = False
|
||||
|
||||
init.write_arch_comps(compose, 'x86_64')
|
||||
|
||||
@ -198,7 +197,6 @@ class TestCreateCompsRepo(PungiTestCase):
|
||||
compose = DummyCompose(self.topdir, {
|
||||
'createrepo_checksum': 'sha256',
|
||||
})
|
||||
compose.DEBUG = False
|
||||
|
||||
init.create_comps_repo(compose, 'x86_64', None)
|
||||
|
||||
@ -216,7 +214,6 @@ class TestCreateCompsRepo(PungiTestCase):
|
||||
compose = DummyCompose(self.topdir, {
|
||||
'createrepo_checksum': 'sha256',
|
||||
})
|
||||
compose.DEBUG = False
|
||||
|
||||
init.create_comps_repo(compose, 'x86_64', compose.variants['Server'])
|
||||
|
||||
@ -259,7 +256,6 @@ class TestWriteGlobalComps(PungiTestCase):
|
||||
@mock.patch('pungi.phases.init.get_file_from_scm')
|
||||
def test_run_local_file(self, get_file):
|
||||
compose = DummyCompose(self.topdir, {'comps_file': 'some-file.xml'})
|
||||
compose.DEBUG = False
|
||||
|
||||
def gen_file(src, dest, logger=None):
|
||||
self.assertEqual(src, '/home/releng/config/some-file.xml')
|
||||
@ -278,7 +274,6 @@ class TestWriteVariantComps(PungiTestCase):
|
||||
@mock.patch('pungi.phases.init.CompsWrapper')
|
||||
def test_run(self, CompsWrapper, run):
|
||||
compose = DummyCompose(self.topdir, {})
|
||||
compose.DEBUG = False
|
||||
variant = compose.variants['Server']
|
||||
comps = CompsWrapper.return_value
|
||||
comps.filter_groups.return_value = []
|
||||
@ -302,7 +297,6 @@ class TestWriteVariantComps(PungiTestCase):
|
||||
@mock.patch('pungi.phases.init.CompsWrapper')
|
||||
def test_run_no_filter_without_groups(self, CompsWrapper, run):
|
||||
compose = DummyCompose(self.topdir, {})
|
||||
compose.DEBUG = False
|
||||
variant = compose.variants['Server']
|
||||
variant.groups = []
|
||||
comps = CompsWrapper.return_value
|
||||
@ -327,7 +321,6 @@ class TestWriteVariantComps(PungiTestCase):
|
||||
@mock.patch('pungi.phases.init.CompsWrapper')
|
||||
def test_run_filter_for_modular(self, CompsWrapper, run):
|
||||
compose = DummyCompose(self.topdir, {})
|
||||
compose.DEBUG = False
|
||||
variant = compose.variants['Server']
|
||||
variant.groups = []
|
||||
variant.modules = ['testmodule:2.0']
|
||||
@ -353,7 +346,6 @@ class TestWriteVariantComps(PungiTestCase):
|
||||
@mock.patch('pungi.phases.init.CompsWrapper')
|
||||
def test_run_report_unmatched(self, CompsWrapper, run):
|
||||
compose = DummyCompose(self.topdir, {})
|
||||
compose.DEBUG = False
|
||||
variant = compose.variants['Server']
|
||||
comps = CompsWrapper.return_value
|
||||
comps.filter_groups.return_value = ['foo', 'bar']
|
||||
|
@ -44,7 +44,6 @@ class TestGetKojiEvent(helpers.PungiTestCase):
|
||||
def test_use_preconfigured_event(self):
|
||||
koji_wrapper = mock.Mock()
|
||||
self.compose.koji_event = 123456
|
||||
self.compose.DEBUG = False
|
||||
|
||||
koji_wrapper.koji_proxy.getEvent.return_value = EVENT_INFO
|
||||
|
||||
@ -58,7 +57,6 @@ class TestGetKojiEvent(helpers.PungiTestCase):
|
||||
self.assertEqual(json.load(f), EVENT_INFO)
|
||||
|
||||
def test_gets_last_event(self):
|
||||
self.compose.DEBUG = False
|
||||
self.compose.koji_event = None
|
||||
koji_wrapper = mock.Mock()
|
||||
|
||||
@ -94,7 +92,6 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
|
||||
'pkgset_koji_tag': 'f25',
|
||||
'sigkeys': mock.Mock(),
|
||||
})
|
||||
self.compose.DEBUG = False
|
||||
self.koji_wrapper = mock.Mock()
|
||||
self.pkgset_path = os.path.join(self.topdir, 'work', 'global', 'pkgset_global.pickle')
|
||||
self.koji_module_path = os.path.join(self.topdir, 'work', 'global', 'koji-module-Server.yaml')
|
||||
@ -213,7 +210,6 @@ data:
|
||||
'pkgset_koji_tag': ['f25', 'f25-extra'],
|
||||
'sigkeys': mock.Mock(),
|
||||
})
|
||||
self.compose.DEBUG = False
|
||||
|
||||
pickle_dumps.return_value = b'DATA'
|
||||
|
||||
@ -288,7 +284,6 @@ data:
|
||||
('.*', {'*': ['pkg', 'foo.x86_64']}),
|
||||
]
|
||||
})
|
||||
self.compose.DEBUG = False
|
||||
pickle_dumps.return_value = b'DATA'
|
||||
|
||||
pkgset = source_koji.populate_global_pkgset(
|
||||
@ -303,7 +298,6 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase):
|
||||
'pkgset_koji_tag': 'f25',
|
||||
})
|
||||
self.compose.koji_event = None
|
||||
self.compose.DEBUG = False
|
||||
self.koji_wrapper = mock.Mock()
|
||||
self.koji_wrapper.koji_proxy.getLastEvent.return_value = EVENT_INFO
|
||||
self.koji_wrapper.koji_proxy.getTag.return_value = TAG_INFO
|
||||
|
Loading…
Reference in New Issue
Block a user