Debian Codegraph @

tests/test_extra.py

raw symbols SCIP
1 import pytest
2
3 import aioftp
4
5
6 @pytest.mark.asyncio
7 async def test_stream_iter_by_line(pair_factory):
8 async with pair_factory() as pair:
9 await pair.client.make_directory("bar")
10 lines = []
11 async with pair.client.get_stream("list") as stream:
12 async for line in stream.iter_by_line():
13 lines.append(line)
14 assert len(lines) == 1
15 assert b"bar" in lines[0]
16
17
18 @pytest.mark.asyncio
19 async def test_stream_close_without_finish(pair_factory):
20 class CustomException(Exception):
21 pass
22
23 def fake_finish(*a, **kw):
24 raise Exception("Finished called")
25
26 async with pair_factory() as pair:
27 with pytest.raises(CustomException):
28 async with pair.client.get_stream():
29 raise CustomException()
30
31
32 @pytest.mark.asyncio
33 async def test_no_server(unused_tcp_port):
34 with pytest.raises(OSError):
35 async with aioftp.Client.context("127.0.0.1", unused_tcp_port):
36 pass
37
38
39 @pytest.mark.asyncio
40 async def test_syst_command(pair_factory):
41 async with pair_factory() as pair:
42 code, info = await pair.client.command("syst", "215")
43 assert info == [" UNIX Type: L8"]
44
45
46 @pytest.mark.asyncio
47 async def test_illegal_command(pair_factory):
48 async with pair_factory() as pair:
49 with pytest.raises(aioftp.errors.InvalidCommand):
50 await pair.client.command("LIST\r\nfoo")