-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
tests.py
70 lines (53 loc) · 1.33 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from httpcat import httpcat, EOF, CRLF
class MockIO:
def __init__(self, input_lines):
self.input_lines = iter(input_lines)
self.output_lines = []
def readline(self):
return next(self.input_lines)
def write(self, line):
self.output_lines.append(line)
def flush(self):
pass
def process(input_lines):
io = MockIO(input_lines=input_lines)
httpcat(initial_lines=[], infile=io, outfile=io)
return io.output_lines
EXPECTED_OUTPUT_LINES = [
'GET / HTTP/1.1' + CRLF,
'Content-Type: text/plain' + CRLF,
CRLF,
'body',
]
def test_crlf_autocomplete():
assert EXPECTED_OUTPUT_LINES == process([
'GET / HTTP/1.1',
'Content-Type: text/plain',
'',
'body',
EOF,
])
def test_method_autocomplete():
assert EXPECTED_OUTPUT_LINES == process([
'/ HTTP/1.1',
'Content-Type: text/plain',
'',
'body',
EOF,
])
def test_http_version_autocomplete():
assert EXPECTED_OUTPUT_LINES == process([
'GET /',
'Content-Type: text/plain',
'',
'body',
EOF,
])
def test_method_and_http_version_autocomplete():
assert EXPECTED_OUTPUT_LINES == process([
'/',
'Content-Type: text/plain',
'',
'body',
EOF,
])