Fix pycodestyle issues in test_policy.py

ubuntu/rebased
Paul Gevers 6 years ago
parent e8b5f5e631
commit ccc1c25f61
No known key found for this signature in database
GPG Key ID: 9C5C99EB05BD750A

@ -36,16 +36,16 @@ def initialize_policy(test_name, policy_class, *args, **kwargs):
state_dir=test_dir, state_dir=test_dir,
verbose=0, verbose=0,
default_urgency=DEFAULT_URGENCY, default_urgency=DEFAULT_URGENCY,
dry_run = False, dry_run=False,
adt_shared_results_cache = False, adt_shared_results_cache=False,
series = target, series=target,
adt_arches = ARCH, adt_arches=ARCH,
architectures = ARCH, architectures=ARCH,
adt_swift_url = 'file://' + debci_data, adt_swift_url='file://' + debci_data,
adt_ci_url = '', adt_ci_url='',
adt_success_bounty = 3, adt_success_bounty=3,
adt_regression_penalty = False, adt_regression_penalty=False,
adt_retry_url_mech = 'run_id', adt_retry_url_mech='run_id',
**kwargs) **kwargs)
suite_info = Suites( suite_info = Suites(
Suite(SuiteClass.TARGET_SUITE, target, os.path.join(test_dir, target), ''), Suite(SuiteClass.TARGET_SUITE, target, os.path.join(test_dir, target), ''),
@ -146,7 +146,7 @@ def build_sources_from_universe_and_inst_tester(policy, pkg_universe, inst_teste
# We need to find the highest version of a package to add it to the # We need to find the highest version of a package to add it to the
# sources of the source suite # sources of the source suite
if pkg_name not in src_source or \ if pkg_name not in src_source or \
apt_pkg.version_compare(src_source[pkg_name].version, pkg_id.version) < 0: apt_pkg.version_compare(src_source[pkg_name].version, pkg_id.version) < 0:
src_source[pkg_name] = pkg_id src_source[pkg_name] = pkg_id
suite_info.target_suite.binaries = binaries_t suite_info.target_suite.binaries = binaries_t
for pkg_id in src_source.values(): for pkg_id in src_source.values():
@ -334,7 +334,7 @@ class TestPiupartsPolicy(unittest.TestCase):
pkg1 = BinaryPackageId('pkg', '1.0', ARCH) pkg1 = BinaryPackageId('pkg', '1.0', ARCH)
pkg2 = BinaryPackageId('pkg', '2.0', ARCH) pkg2 = BinaryPackageId('pkg', '2.0', ARCH)
inter = BinaryPackageId('inter', '1.0', ARCH) inter = BinaryPackageId('inter', '1.0', ARCH)
broken1 = BinaryPackageId('broken', '1.0', ARCH) broken1 = BinaryPackageId('broken', '1.0', ARCH)
broken2 = BinaryPackageId('broken', '2.0', ARCH) broken2 = BinaryPackageId('broken', '2.0', ARCH)
dummy = BinaryPackageId('dummy', '1', ARCH) dummy = BinaryPackageId('dummy', '1', ARCH)
@ -352,6 +352,7 @@ builder_breaks.new_package(pkg1).depends_on(inter).in_testing()
builder_breaks.new_package(pkg2).depends_on(inter).not_in_testing().conflicts_with(broken1) builder_breaks.new_package(pkg2).depends_on(inter).not_in_testing().conflicts_with(broken1)
breaks_universe, breaks_inst_tester = builder_breaks.build() breaks_universe, breaks_inst_tester = builder_breaks.build()
class TestAutopkgtestPolicy(unittest.TestCase): class TestAutopkgtestPolicy(unittest.TestCase):
import apt_pkg import apt_pkg
apt_pkg.init() apt_pkg.init()
@ -377,8 +378,10 @@ class TestAutopkgtestPolicy(unittest.TestCase):
inst_tester=simple_inst_tester) inst_tester=simple_inst_tester)
autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.PASS, src_name) autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.PASS, src_name)
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'PASS' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'PASS'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == \
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == 'packages/' + src_name[0] + '/' + src_name + '/testing/amd64' 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == \
'packages/' + src_name[0] + '/' + src_name + '/testing/amd64'
amqp = self.read_amqp() amqp = self.read_amqp()
assert len(amqp) == 0 assert len(amqp) == 0
@ -393,8 +396,10 @@ class TestAutopkgtestPolicy(unittest.TestCase):
inst_tester=simple_inst_tester) inst_tester=simple_inst_tester)
autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_PERMANENTLY, src_name) autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_PERMANENTLY, src_name)
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'REGRESSION' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'REGRESSION'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == \
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == 'packages/' + src_name[0] + '/' + src_name + '/testing/amd64' 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == \
'packages/' + src_name[0] + '/' + src_name + '/testing/amd64'
amqp = self.read_amqp() amqp = self.read_amqp()
assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0"]}' assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0"]}'
@ -409,8 +414,10 @@ class TestAutopkgtestPolicy(unittest.TestCase):
inst_tester=simple_inst_tester) inst_tester=simple_inst_tester)
autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_PERMANENTLY, src_name) autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_PERMANENTLY, src_name)
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'REGRESSION' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'REGRESSION'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == \
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == 'packages/' + src_name[0] + '/' + src_name + '/testing/amd64' 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == \
'packages/' + src_name[0] + '/' + src_name + '/testing/amd64'
amqp = self.read_amqp() amqp = self.read_amqp()
assert len(amqp) == 0 assert len(amqp) == 0
@ -424,8 +431,10 @@ class TestAutopkgtestPolicy(unittest.TestCase):
inst_tester=simple_inst_tester) inst_tester=simple_inst_tester)
autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.PASS, src_name) autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.PASS, src_name)
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'NEUTRAL' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'NEUTRAL'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == \
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == 'packages/' + src_name[0] + '/' + src_name + '/testing/amd64' 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == \
'packages/' + src_name[0] + '/' + src_name + '/testing/amd64'
amqp = self.read_amqp() amqp = self.read_amqp()
assert len(amqp) == 0 assert len(amqp) == 0
@ -444,7 +453,8 @@ class TestAutopkgtestPolicy(unittest.TestCase):
autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.PASS, src_name) autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.PASS, src_name)
assert autopkgtest_policy_info[src_name][ARCH][0] == 'RUNNING-ALWAYSFAIL' assert autopkgtest_policy_info[src_name][ARCH][0] == 'RUNNING-ALWAYSFAIL'
assert autopkgtest_policy_info[src_name][ARCH][1] == 'status/pending' assert autopkgtest_policy_info[src_name][ARCH][1] == 'status/pending'
assert autopkgtest_policy_info[src_name][ARCH][2] == 'packages/' + src_name[0] + '/' + src_name + '/testing/amd64' assert autopkgtest_policy_info[src_name][ARCH][2] == \
'packages/' + src_name[0] + '/' + src_name + '/testing/amd64'
amqp = self.read_amqp() amqp = self.read_amqp()
assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0"]}' assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0"]}'
@ -474,7 +484,8 @@ class TestAutopkgtestPolicy(unittest.TestCase):
autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.PASS, src_name) autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.PASS, src_name)
assert autopkgtest_policy_info[src_name][ARCH][0] == 'RUNNING-ALWAYSFAIL' assert autopkgtest_policy_info[src_name][ARCH][0] == 'RUNNING-ALWAYSFAIL'
assert autopkgtest_policy_info[src_name][ARCH][1] == 'status/pending' assert autopkgtest_policy_info[src_name][ARCH][1] == 'status/pending'
assert autopkgtest_policy_info[src_name][ARCH][2] == 'packages/' + src_name[0] + '/' + src_name + '/testing/amd64' assert autopkgtest_policy_info[src_name][ARCH][2] == \
'packages/' + src_name[0] + '/' + src_name + '/testing/amd64'
amqp = self.read_amqp() amqp = self.read_amqp()
assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0"]}' assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0"]}'
@ -489,7 +500,8 @@ class TestAutopkgtestPolicy(unittest.TestCase):
autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_TEMPORARILY, src_name) autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_TEMPORARILY, src_name)
assert autopkgtest_policy_info[src_name][ARCH][0] == 'RUNNING' assert autopkgtest_policy_info[src_name][ARCH][0] == 'RUNNING'
assert autopkgtest_policy_info[src_name][ARCH][1] == 'status/pending' assert autopkgtest_policy_info[src_name][ARCH][1] == 'status/pending'
assert autopkgtest_policy_info[src_name][ARCH][2] == 'packages/' + src_name[0] + '/' + src_name + '/testing/amd64' assert autopkgtest_policy_info[src_name][ARCH][2] == \
'packages/' + src_name[0] + '/' + src_name + '/testing/amd64'
amqp = self.read_amqp() amqp = self.read_amqp()
assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0"]}' assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0"]}'
@ -504,8 +516,10 @@ class TestAutopkgtestPolicy(unittest.TestCase):
inst_tester=simple_inst_tester) inst_tester=simple_inst_tester)
autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_PERMANENTLY, src_name) autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_PERMANENTLY, src_name)
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'REGRESSION' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'REGRESSION'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == \
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == 'packages/' + src_name[0] + '/' + src_name + '/testing/amd64' 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == \
'packages/' + src_name[0] + '/' + src_name + '/testing/amd64'
amqp = self.read_amqp() amqp = self.read_amqp()
assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0"]}' assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0"]}'
@ -520,8 +534,10 @@ class TestAutopkgtestPolicy(unittest.TestCase):
inst_tester=simple_inst_tester) inst_tester=simple_inst_tester)
autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_PERMANENTLY, src_name) autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_PERMANENTLY, src_name)
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'REGRESSION' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'REGRESSION'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == \
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == 'packages/' + src_name[0] + '/' + src_name + '/testing/amd64' 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == \
'packages/' + src_name[0] + '/' + src_name + '/testing/amd64'
amqp = self.read_amqp() amqp = self.read_amqp()
assert len(amqp) == 0 assert len(amqp) == 0
@ -536,7 +552,8 @@ class TestAutopkgtestPolicy(unittest.TestCase):
autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_TEMPORARILY, src_name) autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.REJECTED_TEMPORARILY, src_name)
assert autopkgtest_policy_info[src_name][ARCH][0] == 'RUNNING' assert autopkgtest_policy_info[src_name][ARCH][0] == 'RUNNING'
assert autopkgtest_policy_info[src_name][ARCH][1] == 'status/pending' assert autopkgtest_policy_info[src_name][ARCH][1] == 'status/pending'
assert autopkgtest_policy_info[src_name][ARCH][2] == 'packages/' + src_name[0] + '/' + src_name + '/testing/amd64' assert autopkgtest_policy_info[src_name][ARCH][2] == \
'packages/' + src_name[0] + '/' + src_name + '/testing/amd64'
amqp = self.read_amqp() amqp = self.read_amqp()
assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0 broken/2.0"]}' assert amqp[0:-1] == 'debci-testing-amd64:' + src_name + ' {"triggers": ["' + src_name + '/2.0 broken/2.0"]}'
@ -567,8 +584,10 @@ class TestAutopkgtestPolicy(unittest.TestCase):
inst_tester=simple_inst_tester) inst_tester=simple_inst_tester)
autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.PASS, src_name) autopkgtest_policy_info = apply_src_policy(policy, PolicyVerdict.PASS, src_name)
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'ALWAYSFAIL' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][0] == 'ALWAYSFAIL'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz' assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][1] == \
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == 'packages/' + src_name[0] + '/' + src_name + '/testing/amd64' 'data/autopkgtest/testing/amd64/' + src_name[0] + '/' + src_name + '/2/log.gz'
assert autopkgtest_policy_info[src_name + '/2.0'][ARCH][2] == \
'packages/' + src_name[0] + '/' + src_name + '/testing/amd64'
amqp = self.read_amqp() amqp = self.read_amqp()
assert len(amqp) == 0 assert len(amqp) == 0

@ -21,7 +21,6 @@ EXCEPTIONS_BY_FILE = {
'tests/mock_swift.py': 2, 'tests/mock_swift.py': 2,
'tests/__init__.py': 31, 'tests/__init__.py': 31,
'tests/test_autopkgtest.py': 2, 'tests/test_autopkgtest.py': 2,
'tests/test_policy.py': 31,
'tests/test_yaml.py': 1, 'tests/test_yaml.py': 1,
} }

Loading…
Cancel
Save