forked from httpie/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
36 lines (25 loc) · 946 Bytes
/
Copy pathtests.py
File metadata and controls
36 lines (25 loc) · 946 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
35
36
import unittest
from StringIO import StringIO
from httpie import httpie
def http(*args, **kwargs):
stdout = StringIO()
httpie.main(args=args, stdout=stdout,
stdin_isatty=True,
stdout_isatty=False)
return stdout.getvalue()
# TODO: moar!
class TestHTTPie(unittest.TestCase):
def test_get(self):
http('GET', 'http://httpbin.org/get')
def test_json(self):
response = http('POST', 'http://httpbin.org/post', 'foo=bar')
self.assertIn('"foo": "bar"', response)
def test_form(self):
response = http('POST', '--form', 'http://httpbin.org/post', 'foo=bar')
self.assertIn('"foo": "bar"', response)
def test_headers(self):
response = http('GET', 'http://httpbin.org/headers', 'Foo:bar')
self.assertIn('"User-Agent": "HTTPie', response)
self.assertIn('"Foo": "bar"', response)
if __name__ == '__main__':
unittest.main()