forked from codeforamerica/bizfriendly-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
53 lines (45 loc) · 2.04 KB
/
Copy pathtests.py
File metadata and controls
53 lines (45 loc) · 2.04 KB
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
import unittest, requests
class howtocity_api_tester(unittest.TestCase):
def setUp(self):
self.api_url = 'http://howtocity.herokuapp.com/api'
def test_headers(self):
r = requests.get(self.api_url+'/v1/categories')
assert(r.headers['Access-Control-Allow-Origin']) == '*'
assert(r.headers['Content-Type']) == 'application/json'
def test_categories(self):
r = requests.get(self.api_url+'/v1/categories')
response = r.json()
assert isinstance(response, dict)
assert isinstance(response['objects'], list)
assert isinstance(response['objects'][0]['id'], int)
assert isinstance(response['objects'][0]['name'], unicode)
assert isinstance(response['objects'][0]['description'], unicode)
assert isinstance(response['objects'][0]['url'], unicode)
assert isinstance(response['objects'][0]['lessons'], list)
def test_lessons(self):
r = requests.get(self.api_url+'/v1/lessons')
response = r.json()
assert isinstance(response, dict)
assert isinstance(response['objects'], list)
assert isinstance(response['objects'][0]['id'], int)
assert isinstance(response['objects'][0]['name'], unicode)
assert isinstance(response['objects'][0]['description'], unicode)
assert isinstance(response['objects'][0]['url'], unicode)
assert isinstance(response['objects'][0]['category_id'], int)
assert isinstance(response['objects'][0]['category'], dict)
def test_steps(self):
r = requests.get(self.api_url+'/v1/steps')
response = r.json()
assert isinstance(response, dict)
assert isinstance(response['objects'], list)
assert isinstance(response['objects'][0]['id'], int)
assert isinstance(response['objects'][0]['name'], unicode)
assert isinstance(response['objects'][0]['step_type'], unicode)
assert isinstance(response['objects'][0]['url'], unicode)
assert isinstance(response['objects'][0]['lesson_id'], int)
assert isinstance(response['objects'][0]['lesson'], dict)
def test_admin(self):
r = requests.get(self.api_url+'/admin')
assert(r.headers['content-type']) == 'text/html; charset=utf-8'
if __name__ == '__main__':
unittest.main()