-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
48 lines (34 loc) · 1.15 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
import json
import unittest
import sys
if sys.version_info[0] == 2:
from urllib import urlencode
else:
from urllib.parse import urlencode
from pyunio import pyunio
pyunio.use('httpbin')
params_get = {
'params': {
'name': 'James Bond'
}
}
params_body = {
'body': {
'name': 'James Bond'
}
}
class pyuniotTest(unittest.TestCase):
def test_get(self):
response = json.loads(pyunio.get('get', params_get).text)
self.assertEqual(response['args']['name'], 'James Bond')
def test_post(self):
response = json.loads(pyunio.post('post', params_body).text)
self.assertEqual(response['form']['name'],'James Bond')
def test_put(self):
response = json.loads(pyunio.put('put', params_body).text)
self.assertEqual(response['form']['name'], 'James Bond')
def test_delete(self):
response = json.loads(pyunio.delete('delete', params_body).text)
self.assertEqual(response['data'], urlencode({'name':'James Bond'}))
if __name__ == '__main__':
unittest.main()