@@ -28,7 +28,6 @@ def test_data(self):
28
28
except :
29
29
self .fail ("ISS API not a valid JSON responce" )
30
30
31
-
32
31
# Success message
33
32
self .assertEqual (data ['message' ], "success" , "ISS API Did not return 'sucess' message" )
34
33
@@ -39,3 +38,35 @@ def test_data(self):
39
38
self .assertTrue ('iss_position' in data )
40
39
self .assertTrue ('latitude' in data ['iss_position' ])
41
40
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