示例#1
0
    def test_instantiates_with_ssl(self):
        conn = TcpConnection(host=LOCALHOST, port=PORT, ssl=True)

        assert 'conn' in locals()
        assert conn.host is LOCALHOST
        assert conn.port is PORT
        assert conn.ssl is True
示例#2
0
    async def test_open(self, *args):
        conn = TcpConnection(host=LOCALHOST, port=PORT, ssl=False)

        reader, writer = await conn.open()

        assert isinstance(reader, asyncio.StreamReader)
        assert isinstance(writer, asyncio.StreamWriter)
示例#3
0
async def test_open(address, open_connection):
    conn = TcpConnection(host=address[0], port=address[1])

    reader, writer = await conn.open()

    assert writer
    assert writer
示例#4
0
def test_instantiates_with_ssl(address, mocker):
    ssl_stub = mocker.stub()
    conn = TcpConnection(host=address[0], port=address[1], ssl=ssl_stub)

    assert conn.host is address[0]
    assert conn.port is address[1]
    assert conn.ssl is ssl_stub
示例#5
0
def test_repr(address):
    conn = TcpConnection(host=address[0], port=address[1])

    assert repr(conn) == 'TcpConnection(host={}, port={}, ssl={})'.format(
            repr(address[0]),
            repr(address[1]),
            repr(None)
    )
示例#6
0
def test_instantiates_with_loop(address, event_loop):
    conn = TcpConnection(host=address[0],
                         port=address[1],
                         loop=event_loop)

    assert conn.host is address[0]
    assert conn.port is address[1]
    assert conn.loop is event_loop
示例#7
0
    def test_instantiates_with_loop(self, event_loop):
        conn = TcpConnection(host=LOCALHOST,
                             port=PORT,
                             ssl=False,
                             loop=event_loop)

        assert 'conn' in locals()
        assert conn.host is LOCALHOST
        assert conn.port is PORT
        assert conn.loop is event_loop
示例#8
0
    def test_repr(self):
        conn = TcpConnection(host=LOCALHOST, port=PORT, ssl=False)

        assert repr(conn) == 'TcpConnection(host={}, port={}, ssl={})'.format(
            repr(LOCALHOST), repr(PORT), False)
示例#9
0
    def test_connection_string(self):
        conn = TcpConnection(host=LOCALHOST, port=PORT, ssl=False)

        assert conn.connection_string == '{}:{}'.format(LOCALHOST, PORT)
示例#10
0
    async def test_open_error(self, *args):
        conn = TcpConnection(host=LOCALHOST, port=PORT, ssl=False)

        with pytest.raises(AIOSpamcConnectionFailed):
            reader, writer = await conn.open()
示例#11
0
def test_instantiates_without_ssl(address):
    conn = TcpConnection(host=address[0], port=address[1])

    assert conn.host is address[0]
    assert conn.port is address[1]
    assert conn.ssl is None
示例#12
0
def test_connection_string(address):
    conn = TcpConnection(host=address[0], port=address[1])

    assert conn.connection_string == '{}:{}'.format(address[0], address[1])
示例#13
0
async def test_open_error(address, os_error):
    conn = TcpConnection(host=address[0], port=address[1])

    with pytest.raises(AIOSpamcConnectionFailed):
        reader, writer = await conn.open()