From ed58d6fed487fa8cf1a3663e10232a4d29897462 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Sep 24 2018 07:31:50 +0000 Subject: Omit not-applicable satisfied requirements in response Signed-off-by: Lukas Holecek --- diff --git a/greenwave/policies.py b/greenwave/policies.py index 5453aa3..f3782a1 100644 --- a/greenwave/policies.py +++ b/greenwave/policies.py @@ -205,24 +205,6 @@ class TestResultPassed(RuleSatisfied): } -class TestCaseNotApplicable(RuleSatisfied): - """ - A required test case is not applicable to given subject. - """ - def __init__(self, subject_type, subject_identifier, test_case_name): - self.subject_type = subject_type - self.subject_identifier = subject_identifier - self.test_case_name = test_case_name - - def to_json(self): - return { - 'type': 'test-case-not-applicable', - 'testcase': self.test_case_name, - 'subject_type': self.subject_type, - 'subject_identifier': self.subject_identifier, - } - - class BlacklistedInPolicy(RuleSatisfied): """ Package was blacklisted in policy. @@ -470,11 +452,11 @@ class PackageSpecificRule(Rule): """ if subject_type != 'koji_build': - return TestCaseNotApplicable(subject_type, subject_identifier, self.test_case_name) + return [] pkg_name = subject_identifier.rsplit('-', 2)[0] if not any(fnmatch(pkg_name, repo) for repo in self.repos): - return TestCaseNotApplicable(subject_type, subject_identifier, self.test_case_name) + return [] rule = PassingTestCaseRule() # pylint: disable=attribute-defined-outside-init diff --git a/greenwave/tests/test_policies.py b/greenwave/tests/test_policies.py index a871068..22dfbf0 100644 --- a/greenwave/tests/test_policies.py +++ b/greenwave/tests/test_policies.py @@ -226,14 +226,12 @@ rules: # That a non-matching passing result is ignored. results = DummyResultsRetriever('foobar-1.2.3-1.el9000', 'sometest') decision = policy.check('foobar-1.2.3-1.el9000', results, waivers) - assert len(decision) == 1 - assert isinstance(decision[0], RuleSatisfied) + assert decision == [] # That a non-matching failing result is ignored. results = DummyResultsRetriever('foobar-1.2.3-1.el9000', 'sometest', 'FAILED') decision = policy.check('foobar-1.2.3-1.el9000', results, waivers) - assert len(decision) == 1 - assert isinstance(decision[0], RuleSatisfied) # ooooh. + assert decision == [] # Ensure that fnmatch globs work in absence results, waivers = DummyResultsRetriever(), []