Пример #1
0
 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")
Пример #2
0
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))
Пример #3
0
 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
Пример #4
0
 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")
Пример #6
0
 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,
         )
Пример #7
0
 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,
         )
Пример #8
0
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:])