From 49d9a38d251f50b1e013fc00f7ce445cf7dac820 Mon Sep 17 00:00:00 2001 From: Ivo De Decker Date: Wed, 2 Jan 2019 00:30:00 +0000 Subject: [PATCH] Skip unimplemented policies in excuses Return PolicyVerdict.NOT_APPLICABLE, which means no data is added to policy_info in the excuse. Signed-off-by: Ivo De Decker --- britney2/policies/__init__.py | 4 ++++ britney2/policies/policy.py | 14 ++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/britney2/policies/__init__.py b/britney2/policies/__init__.py index 16e564d..cc9f4d9 100644 --- a/britney2/policies/__init__.py +++ b/britney2/policies/__init__.py @@ -4,6 +4,10 @@ from enum import Enum, unique class PolicyVerdict(Enum): """""" """ + The policy doesn't apply to this item. No test was done. + """ + NOT_APPLICABLE = 0 + """ The migration item passed the policy. """ PASS = 1 diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py index cc52517..aae9821 100644 --- a/britney2/policies/policy.py +++ b/britney2/policies/policy.py @@ -112,11 +112,12 @@ class BasePolicy(object): def apply_src_policy(self, general_policy_info, suite, source_name, source_data_tdist, source_data_srcdist, excuse): pinfo = {} - general_policy_info[self.policy_id] = pinfo verdict = self.apply_src_policy_impl(pinfo, suite, source_name, source_data_tdist, source_data_srcdist, excuse) # The base policy provides this field, so the subclass should leave it blank assert 'verdict' not in pinfo - pinfo['verdict'] = verdict.name + if verdict != PolicyVerdict.NOT_APPLICABLE: + general_policy_info[self.policy_id] = pinfo + pinfo['verdict'] = verdict.name return verdict def apply_src_policy_impl(self, policy_info, suite, source_name, source_data_tdist, source_data_srcdist, excuse): # pragma: no cover @@ -145,15 +146,16 @@ class BasePolicy(object): :return A Policy Verdict (e.g. PolicyVerdict.PASS) """ - return PolicyVerdict.PASS + return PolicyVerdict.NOT_APPLICABLE def apply_srcarch_policy(self, general_policy_info, suite, source_name, arch, source_data_tdist, source_data_srcdist, excuse): pinfo = {} - general_policy_info[self.policy_id] = pinfo verdict = self.apply_srcarch_policy_impl(pinfo, suite, source_name, arch, source_data_tdist, source_data_srcdist, excuse) # The base policy provides this field, so the subclass should leave it blank assert 'verdict' not in pinfo - pinfo['verdict'] = verdict.name + if verdict != PolicyVerdict.NOT_APPLICABLE: + general_policy_info[self.policy_id] = pinfo + pinfo['verdict'] = verdict.name return verdict def apply_srcarch_policy_impl(self, policy_info, suite, source_name, arch, source_data_tdist, source_data_srcdist, excuse): @@ -183,7 +185,7 @@ class BasePolicy(object): :return A Policy Verdict (e.g. PolicyVerdict.PASS) """ # if the policy doesn't implement this function, assume it's OK - return PolicyVerdict.PASS + return PolicyVerdict.NOT_APPLICABLE class SimplePolicyHint(Hint):