def test_with_password(self, smtp): self.settings['password'] = "******" action = actions.SendEmailAction( ACTION_TYPE, ACTION_NAME, self.params, self.settings) action.run() smtpmock = smtp.return_value calls = [call.ehlo(), call.starttls(), call.ehlo(), call.login(self.settings['from'], self.settings['password'])] smtpmock.assert_has_calls(calls) self.assertTrue(smtpmock.sendmail.called, "should call sendmail")
def tls_started(conn): calls = conn.mock_calls starttls = call.starttls() ehlo = call.ehlo() return (starttls in calls and ehlo in calls and calls.index(starttls) < calls.index(ehlo))
def test_connection(self, postman, smtp): with postman.connection() as conn: assert conn is smtp assert conn.mock_calls == [ call(self.host, self.port), call.ehlo(), ] assert conn.closed
def test_connection(self, postman, smtp): with postman.connection() as conn: assert conn is smtp assert conn.mock_calls == [ call(self.host, self.port), call.ehlo(), ] assert conn.closed
def test_with_password(self, smtp): self.settings['password'] = "******" action = std.SendEmailAction(self.params, self.settings) action.run() smtpmock = smtp.return_value calls = [ call.ehlo(), call.starttls(), call.ehlo(), call.login(self.settings['from'], self.settings['password']) ] smtpmock.assert_has_calls(calls) self.assertTrue(smtpmock.sendmail.called, "should call sendmail")
def test_deliver_mocked_calls(self, postman, envelope): with postman.connection() as conn: postman.deliver(conn, envelope) sendmail = call.sendmail( envelope.sender, envelope.receivers, envelope.string(), ) ehlo = call.ehlo() conn.assert_has_calls( [sendmail, ehlo], any_order=True, )
def test_deliver_mocked_calls(self, postman, envelope): with postman.connection() as conn: postman.deliver(conn, envelope) sendmail = call.sendmail( envelope.sender.encode(), [u.encode() for u in envelope.receivers], envelope.string(), ) ehlo = call.ehlo() conn.assert_has_calls( [sendmail, ehlo], any_order=True, )
def tls_started(conn): calls = conn.mock_calls starttls = call.starttls() ehlo = call.ehlo() return (starttls in calls and ehlo in calls[calls.index(starttls) + 1:])