@@ -0,0 +1,1115 @@
+from pytest import fixture%0Afrom mock import Mock, call%0Afrom mailthon.middleware import TLS, Auth%0A%0A%0A@fixture%0Adef smtp():%0A    return Mock()%0A%0A%0Adef tls_started(conn):%0A    return conn.mock_calls%5B-2:%5D == %5B%0A        call.starttls(),%0A        call.ehlo(),%0A    %5D%0A%0A%0Aclass TestTlsSupported:%0A    @fixture%0A    def conn(self, smtp):%0A        smtp.has_extn.return_value = True%0A        return smtp%0A%0A    def test_no_force(self, conn):%0A        tls = TLS()%0A        tls(conn)%0A%0A        assert conn.mock_calls%5B0%5D == call.has_extn('STARTTLS')%0A        assert tls_started(conn)%0A%0A    def test_force(self, conn):%0A        tls = TLS(force=True)%0A        tls(conn)%0A%0A        assert tls_started(conn)%0A%0A%0Aclass TestTLSUnsupported:%0A    @fixture%0A    def conn(self, smtp):%0A        smtp.has_extn.return_value = False%0A        return smtp%0A%0A    def test_no_force(self, conn):%0A        tls = TLS()%0A        tls(conn)%0A%0A        assert not tls_started(conn)%0A%0A%0Aclass TestAuth:%0A    def test_auth(self, smtp):%0A        auth = Auth(username='user', password='pass')%0A        auth(smtp)%0A%0A        assert smtp.mock_calls == %5B%0A            call.login('user', 'pass')%0A        %5D%0A

test middleware