コード例 #1
0
ファイル: test-timeouts.py プロジェクト: tier2003/aioftp
def test_wait_pasv_timeout_fail_short(loop, client, server, *, tmp_dir):

    f = tmp_dir / "foo.txt"
    b = b"foobar"

    yield from client.login()
    yield from client.command("STOR " + f.name)
    yield from asyncio.sleep(0.5, loop=loop)
    reader, writer = yield from client.get_passive_connection("I")

    with contextlib.closing(writer) as writer:

        writer.write(b)
        yield from writer.drain()

    yield from client.command(None, "2xx", "1xx")
    yield from client.quit()

    with f.open("rb") as fin:

        rb = fin.read()

    f.unlink()

    nose.tools.eq_(b, rb)
コード例 #2
0
ファイル: test-timeouts.py プロジェクト: tier2003/aioftp
def test_wait_pasv_timeout_ok_but_too_long(loop, client, server, *, tmp_dir):

    f = tmp_dir / "foo.txt"
    b = b"foobar"

    yield from client.login()
    yield from client.command("TYPE I", "200")
    code, info = yield from client.command("PASV", "227")
    ip, port = client.parse_address_response(info[-1])

    yield from client.command("STOR " + f.name)
    yield from asyncio.sleep(2, loop=loop)

    reader, writer = yield from aioftp.client.open_connection(ip, port, loop, client.create_connection)

    with contextlib.closing(writer) as writer:

        writer.write(b)
        yield from writer.drain()

    yield from client.command(None, "2xx", "1xx")
    yield from client.quit()

    with f.open("rb") as fin:

        rb = fin.read()

    f.unlink()

    nose.tools.eq_(b, rb)
コード例 #3
0
def test_wait_pasv_timeout_fail_short(loop, client, server, *, tmp_dir):

    f = tmp_dir / "foo.txt"
    b = b"foobar"

    yield from client.login()
    yield from client.command("STOR " + f.name)
    yield from asyncio.sleep(0.5, loop=loop)
    reader, writer = yield from client.get_passive_connection("I")

    with contextlib.closing(writer) as writer:

        writer.write(b)
        yield from writer.drain()

    yield from client.command(None, "2xx", "1xx")
    yield from client.quit()

    with f.open("rb") as fin:

        rb = fin.read()

    f.unlink()

    nose.tools.eq_(b, rb)
コード例 #4
0
def test_wait_pasv_timeout_ok_but_too_long(loop, client, server, *, tmp_dir):

    f = tmp_dir / "foo.txt"
    b = b"foobar"

    yield from client.login()
    yield from client.command("TYPE I", "200")
    code, info = yield from client.command("PASV", "227")
    ip, port = client.parse_address_response(info[-1])

    yield from client.command("STOR " + f.name)
    yield from asyncio.sleep(2, loop=loop)

    reader, writer = yield from aioftp.client.open_connection(
        ip,
        port,
        loop,
        client.create_connection,
    )

    with contextlib.closing(writer) as writer:

        writer.write(b)
        yield from writer.drain()

    yield from client.command(None, "2xx", "1xx")
    yield from client.quit()

    with f.open("rb") as fin:

        rb = fin.read()

    f.unlink()

    nose.tools.eq_(b, rb)
コード例 #5
0
ファイル: test-timeouts.py プロジェクト: tier2003/aioftp
    def coro():

        try:

            yield from server.start(None, 8888)
            yield from client.connect("127.0.0.1", 8888)
            yield from client.login()

        finally:

            server.close()
            yield from server.wait_closed()
コード例 #6
0
    def coro():

        try:

            yield from server.start(None, 8888)
            yield from client.connect("127.0.0.1", 8888)
            yield from client.login()

        finally:

            server.close()
            yield from server.wait_closed()
コード例 #7
0
ファイル: test-timeouts.py プロジェクト: tier2003/aioftp
def test_client_path_timeout(loop, client, server, *, tmp_dir):

    f = tmp_dir / "foo.txt"
    with f.open("wb") as fout:

        fout.write(b"-" * 1024)

    yield from client.login()
    try:

        yield from client.download("foo.txt", "/foo.txt", write_into=True)

    finally:

        f.unlink()
コード例 #8
0
def test_client_path_timeout(loop, client, server, *, tmp_dir):

    f = tmp_dir / "foo.txt"
    with f.open("wb") as fout:

        fout.write(b"-" * 1024)

    yield from client.login()
    try:

        yield from client.download("foo.txt", "/foo.txt", write_into=True)

    finally:

        f.unlink()
コード例 #9
0
ファイル: test-timeouts.py プロジェクト: tier2003/aioftp
def test_server_path_timeout(loop, client, server):

    yield from client.login()
    yield from client.make_directory("foo")
コード例 #10
0
ファイル: test-timeouts.py プロジェクト: tier2003/aioftp
def test_idle_timeout(loop, client, server):

    yield from asyncio.sleep(2, loop=loop)
    yield from client.login()
コード例 #11
0
def test_server_path_timeout(loop, client, server):

    yield from client.login()
    yield from client.make_directory("foo")
コード例 #12
0
def test_idle_timeout(loop, client, server):

    yield from asyncio.sleep(2, loop=loop)
    yield from client.login()