diff --git a/britney2/policies/email.py b/britney2/policies/email.py index 9e11fd9..d6aeed7 100644 --- a/britney2/policies/email.py +++ b/britney2/policies/email.py @@ -162,7 +162,8 @@ class EmailPolicy(BasePolicy, Rest): version = source_data_srcdist.version age = excuse.daysold or 0 rounded_age = int(age) - stuck = age >= 3 + stuck = age >= 3 and 'block' not in excuse.reason + cached = self.cache.get(source_name, {}).get(version) try: emails, sent_age = cached diff --git a/tests/test_email.py b/tests/test_email.py index 6618e64..415ad7c 100755 --- a/tests/test_email.py +++ b/tests/test_email.py @@ -346,6 +346,36 @@ class ET(TestBase): self.do_test([pkg], ["foo@bar.com"]) + def test_email_not_sent_block_all_source(self): + '''Test that an email is not sent if the package is blocked by a + block-all source hint''' + self.create_hint('freeze', 'block-all source') + pkg = ('libc6', {'Version': '2'}, + 6, # daysold + ['foo@bar.com']) + + self.do_test([pkg], []) + + def test_email_not_sent_blocked(self): + '''Test that an email is not sent if the package is blocked by a block hint''' + self.create_hint('freeze', 'block libc6') + pkg = ('libc6', {'Version': '2'}, + 6, # daysold + ['foo@bar.com']) + + self.do_test([pkg], []) + + def test_email_sent_unblocked(self): + '''Test that an email is sent if the package is unblocked''' + self.create_hint('freeze', 'block libc6') + self.create_hint('laney', 'unblock libc6/2') + pkg = ('libc6', {'Version': '2', + 'Depends': 'notavailable (>= 2)'}, + 6, # daysold + ['foo@bar.com']) + + self.do_test([pkg], ['foo@bar.com']) + if __name__ == '__main__': unittest.main()