diff --git a/britney2/policies/email.py b/britney2/policies/email.py index 385a7ed..60947c8 100644 --- a/britney2/policies/email.py +++ b/britney2/policies/email.py @@ -31,7 +31,7 @@ Hi, {source_name} {version} needs attention. -It has been stuck in {series}-proposed for {age:.0f} day{plural}. +It has been stuck in {series}-proposed for {age} day{plural}. You either sponsored or uploaded this package, please investigate why it hasn't been approved for migration. @@ -160,6 +160,7 @@ class EmailPolicy(BasePolicy, Rest): sent = self.cache.get(source_name, {}).get(version, False) age = excuse.daysold or 0 stuck = age >= max_age + age = int(age) plural = 's' if age != 1 else '' if self.dry_run: self.log("[email dry run] Considering: %s/%s: %s" % diff --git a/tests/test_email.py b/tests/test_email.py index fa398e4..cdaeca2 100755 --- a/tests/test_email.py +++ b/tests/test_email.py @@ -216,6 +216,25 @@ class T(unittest.TestCase): e.apply_policy_impl(None, None, 'chromium-browser', None, FakeSourceData, FakeExcuse) smtp.SMTP.assert_called_once_with('localhost') + @patch('britney2.policies.email.EmailPolicy.lp_get_emails') + @patch('britney2.policies.email.smtplib', autospec=True) + def test_smtp_days(self, smtp, lp): + """Pluralize correctly.""" + lp.return_value = ['email@address.com'] + e = EmailPolicy(FakeOptions, None) + FakeExcuse.is_valid = False + FakeExcuse.daysold = 1.01 + e.apply_policy_impl(None, None, 'chromium-browser', None, FakeSourceData, FakeExcuse) + smtp.SMTP.assert_called_once_with('localhost') + name, args, kwargs = smtp.SMTP().sendmail.mock_calls[0] + text = args[2] + self.assertIn(' 1 day.', text) + FakeExcuse.daysold = 4.9 + e.apply_policy_impl(None, None, 'chromium-browser', None, FakeSourceData, FakeExcuse) + name, args, kwargs = smtp.SMTP().sendmail.mock_calls[-1] + text = args[2] + self.assertIn(' 4 days.', text) + if __name__ == '__main__': unittest.main()