def test_mail_event(self): e = alarm_events.parse_event_code("987618140103001_") with mock.patch("subprocess.Popen") as mock_p: alarm_events.mail_event(e) mock_p.assert_called_once_with( ["/usr/bin/mail", "-S", "from=Alarm System <*****@*****.**>", "-s", str(e), "*****@*****.**"], stdin=subprocess.PIPE, ) mock_p.return_value.stdin.write.assert_called_once_with(e.dump()) mock_p.return_value.stdin.close.assert_called_once_with() mock_p.return_value.wait.assert_called_once_with()
def test_mail_nomail(self): e = alarm_events.Event() e.account = 9876 e.event_code = 570 with mock.patch("subprocess.Popen") as mock_p: alarm_events.mail_event(e) self.assertFalse(mock_p.called) e.event_code = 666 with mock.patch("subprocess.Popen") as mock_p: alarm_events.mail_event(e) self.assertFalse(mock_p.called)
def test_mail_nomail(self): e = alarm_events.Event() e.account = 9876 e.event_code = 570 with mock.patch('subprocess.Popen') as mock_p: alarm_events.mail_event(e) self.assertFalse(mock_p.called) e.event_code = 666 with mock.patch('subprocess.Popen') as mock_p: alarm_events.mail_event(e) self.assertFalse(mock_p.called)
def test_mail_event(self): e = alarm_events.parse_event_code('987618140103001_') with mock.patch('subprocess.Popen') as mock_p: alarm_events.mail_event(e) mock_p.assert_called_once_with([ '/usr/bin/mail', '-S', 'from=Alarm System <*****@*****.**>', '-s', str(e), '*****@*****.**' ], stdin=subprocess.PIPE) mock_p.return_value.stdin.write.assert_called_once_with(e.dump()) mock_p.return_value.stdin.close.assert_called_once_with() mock_p.return_value.wait.assert_called_once_with()