mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-04-13 20:21:15 +00:00
Make it possible to test the email frequency for a package that is sometimes a valid candidate and sometimes not
This commit is contained in:
parent
27ef44e478
commit
6459977822
@ -225,8 +225,10 @@ class T(unittest.TestCase):
|
||||
|
||||
@patch('britney2.policies.email.EmailPolicy.lp_get_emails')
|
||||
@patch('britney2.policies.email.smtplib', autospec=True)
|
||||
def smtp_repetition(self, smtp, lp, valid=False, expected=None):
|
||||
def smtp_repetition(self, smtp, lp, valid, expected):
|
||||
"""Resend mails periodically, with decreasing frequency."""
|
||||
if not isinstance(valid,list):
|
||||
valid = [valid]*len(expected)
|
||||
FakeExcuse.is_valid = valid
|
||||
lp.return_value = ['email@address.com']
|
||||
sendmail = smtp.SMTP().sendmail
|
||||
@ -237,6 +239,11 @@ class T(unittest.TestCase):
|
||||
previous = sendmail.call_count
|
||||
age = hours / 24
|
||||
FakeExcuse.daysold = age
|
||||
try:
|
||||
FakeExcuse.is_valid = valid[len(called)]
|
||||
except IndexError:
|
||||
# we've already gotten all the mails we expect
|
||||
pass
|
||||
e.apply_policy_impl(None, None, 'unity8', None, FakeSourceData, FakeExcuse)
|
||||
if sendmail.call_count > previous:
|
||||
e.initialise(None) # Refill e.cache from disk
|
||||
|
Loading…
x
Reference in New Issue
Block a user