-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
34 lines (23 loc) · 701 Bytes
/
test.py
File metadata and controls
34 lines (23 loc) · 701 Bytes
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
from apitester import Schema, Runner, is_exactly, Generator
from requests import get
def httpbin(*suffix):
return "http://httpbin.org/" + '/'.join(suffix)
def one(v):
return is_exactly(v, "1")
def one_valid_test():
s = Schema([one])
s.add(one_gen.valid())
r = Runner(s, httpbin("post"))
r.run()
def one_invalid_test():
s = Schema([one])
s.add(one_gen.valid())
r = Runner(s, httpbin("post"), invalid={'One': one_gen.invalid()})
r.run()
if __name__ == '__main__':
r = get(httpbin("get"))
# Test that httpbin is up
assert r.status_code == 200
one_gen = Generator([one], shortest=1, longest=1)
one_valid_test()
one_invalid_test()