Skip to content

Commit 278c57a

Browse files
committed
extend tests to astro api, add test to makefile
1 parent 745e777 commit 278c57a

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

Diff for: Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
test:
2+
python ./run_tests.py
3+
14
clean:
25
find . -name "*.pyc" -type f -delete
36

Diff for: run_tests.py

100755100644
File mode changed.

Diff for: testsuite/api.py

+32-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def test_data(self):
2828
except:
2929
self.fail("ISS API not a valid JSON responce")
3030

31-
3231
# Success message
3332
self.assertEqual(data['message'], "success", "ISS API Did not return 'sucess' message")
3433

@@ -39,3 +38,35 @@ def test_data(self):
3938
self.assertTrue('iss_position' in data)
4039
self.assertTrue('latitude' in data['iss_position'])
4140
self.assertTrue('longitude' in data['iss_position'])
41+
42+
43+
class AstrosTest(TestCase):
44+
"""Test the number of astros API"""
45+
46+
def setUp(self):
47+
self.app = app
48+
self.w = TestApp(self.app)
49+
50+
def test_load_astros(self):
51+
r = self.w.get('/astros.json')
52+
self.assertFalse(r.flashes)
53+
r = self.w.get('/astros/')
54+
self.assertFalse(r.flashes)
55+
r = self.w.get('/astros/v1')
56+
self.assertFalse(r.flashes)
57+
58+
def test_data(self):
59+
r = self.w.get('/astros.json')
60+
r.charset = 'utf8'
61+
try:
62+
data = json.loads(r.text)
63+
except:
64+
self.fail("ISS API not a valid JSON responce")
65+
66+
# Success message
67+
self.assertEqual(data['message'], "success", "ISS API Did not return 'sucess' message")
68+
69+
# data exists
70+
self.assertTrue('number' in data)
71+
self.assertEqual(type(data['number']), int)
72+
self.assertTrue('people' in data)

0 commit comments

Comments
 (0)