~mvo/unattended-upgrades/timed-reboot

« back to all changes in this revision

Viewing changes to test/test_mail.py

  • Committer: Michael Vogt
  • Date: 2012-11-11 15:34:52 UTC
  • Revision ID: michael.vogt@ubuntu.com-20121111153452-mb6s0a4oleabrric
update tests for latest string change

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    EXPECTED_MAIL_CONTENT_STRINGS = [
18
18
        "logfile_dpkg text",
19
19
        "mem_log text",
20
 
        "Packages that are upgraded:\n 2vcard",
21
20
        ]
22
21
 
23
22
    def common_setup(self):
56
55
        mail_txt = open("mail.txt").read()
57
56
        self.assertTrue("[reboot required]" in mail_txt)
58
57
        self._verify_common_mail_content(mail_txt)
59
 
        
 
58
        self.assertTrue("Packages that were upgraded:\n 2vcard" in mail_txt)
 
59
 
60
60
    def test_summary_mail_no_reboot(self):
61
61
        send_summary_mail(*self._return_mock_data())
62
62
        mail_txt = open("mail.txt").read()
63
63
        self.assertFalse("[reboot required]" in mail_txt)
64
64
        self._verify_common_mail_content(mail_txt)
65
 
    
 
65
        self.assertTrue("Packages that were upgraded:\n 2vcard" in mail_txt)
 
66
 
66
67
    def test_summary_mail_only_on_error(self):
67
68
        # default is to always send mail, ensure this is correct
68
69
        # for both success and failure
83
84
        self._verify_common_mail_content(mail_txt)
84
85
        self.assertTrue("Unattended upgrade returned: False" in mail_txt)
85
86
        self.assertTrue(os.path.exists("mail.txt"))
 
87
        self.assertTrue(
 
88
            "Packages that attempted to upgrade:\n 2vcard" in mail_txt)
86
89
 
87
90
    def test_apt_listchanges(self):
88
91
        # test with sendmail available
120
123
        msg = Parser().parsestr(mail_txt)
121
124
        content_type = msg["Content-Type"]
122
125
        self.assertEqual(content_type, 'text/plain; charset="utf-8"')
123
 
    
 
126
 
124
127
 
125
128
class SendmailAndMailxTestCase(SendmailTestCase):
126
129
 
132
135
if __name__ == "__main__":
133
136
    #logging.basicConfig(level=logging.DEBUG)
134
137
    unittest.main()
135