diff --git a/britney.py b/britney.py index fe9af4b..de20218 100755 --- a/britney.py +++ b/britney.py @@ -1579,13 +1579,12 @@ class Britney(object): # the check fails and we set is_valid to False to block the update; consider # the age-days hint, if specified for the package policy_info = excuse.policy_info - policy_verdict = PolicyVerdict.PASS for policy in self.policies: if suite in policy.applicable_suites: v = policy.apply_policy(policy_info, suite, src, source_t, source_u, excuse) - if v > policy_verdict: - policy_verdict = v - if policy_verdict in [PolicyVerdict.REJECTED_PERMANENTLY, PolicyVerdict.REJECTED_TEMPORARILY]: + if v > excuse.current_policy_verdict: + excuse.current_policy_verdict = v + if excuse.current_policy_verdict in [PolicyVerdict.REJECTED_PERMANENTLY, PolicyVerdict.REJECTED_TEMPORARILY]: excuse.is_valid = False if suite in ('pu', 'tpu') and source_t: diff --git a/britney2/excuse.py b/britney2/excuse.py index 7d3f404..72cef0d 100644 --- a/britney2/excuse.py +++ b/britney2/excuse.py @@ -17,6 +17,8 @@ from collections import defaultdict import re +from britney2.policies.policy import PolicyVerdict + class Excuse(object): """Excuse class @@ -67,6 +69,7 @@ class Excuse(object): self.missing_builds_ood_arch = set() self.old_binaries = defaultdict(set) self.policy_info = {} + self.current_policy_verdict = PolicyVerdict.PASS def sortkey(self): if self.daysold == None: diff --git a/britney2/policies/email.py b/britney2/policies/email.py index d6aeed7..da8eb61 100644 --- a/britney2/policies/email.py +++ b/britney2/policies/email.py @@ -162,7 +162,13 @@ class EmailPolicy(BasePolicy, Rest): version = source_data_srcdist.version age = excuse.daysold or 0 rounded_age = int(age) - stuck = age >= 3 and 'block' not in excuse.reason + # an item is stuck if it's + # - old enough + # - not blocked + # - not temporarily rejected (e.g. by the autopkgtest policy when tests + # are still running) + stuck = age >= 3 and 'block' not in excuse.reason and \ + excuse.current_policy_verdict != PolicyVerdict.REJECTED_TEMPORARILY cached = self.cache.get(source_name, {}).get(version) try: diff --git a/tests/test_email.py b/tests/test_email.py index 415ad7c..1899d9c 100755 --- a/tests/test_email.py +++ b/tests/test_email.py @@ -376,6 +376,24 @@ class ET(TestBase): self.do_test([pkg], ['foo@bar.com']) + def test_email_not_sent_rejected_temporarily(self): + '''Test that an email is not sent if the package is REJECTED_TEMPORARILY''' + urgency_file = os.path.join(self.data.path, + 'data', + 'series', + 'Urgency') + with open(urgency_file, 'w') as f: + # we specified in setUp() that emergency has a 10 day delay, and + # age rejections are REJECTED_TEMPORARILY + f.write('libc6 2 emergency') + + pkg = ('libc6', {'Version': '2', + 'Depends': 'notavailable (>= 2)'}, + 6, # daysold + ['foo@bar.com']) + + self.do_test([pkg], []) + if __name__ == '__main__': unittest.main()