@@ -72,31 +72,6 @@ def test_not_getting_token_providing_no_credentails(self):
7272 ############################################################
7373 ######################## GET TESTS #########################
7474 ############################################################
75- @mock .patch ("flask_jwt._jwt_required" )
76- def test_app_is_responding_on_get_cars (self , monkeypatch ):
77- monkeypatch = jwt_mock
78- response = self .client .get ("/v2/cars" )
79- valid_response = {
80- "description" : "Make an authenticated POST request for predicting the image. POST binary file with proper header or { 'image' : 'BASE64 image' }" ,
81- "accepted_content_type" : [
82- "image/jpeg" ,
83- "image/png" ,
84- "application/json"
85- ]
86- }
87- self .assertEquals (response .json , valid_response )
88-
89- @mock .patch ("flask_jwt._jwt_required" )
90- def test_app_is_responding_on_get_sentiment (self , monkeypatch ):
91- monkeypatch = jwt_mock
92- response = self .client .get ("/v2/sentiment" )
93- valid_response = {
94- "description" : "Make an authenticated POST request for predicting the text. { 'text' : 'Text to predict' }" ,
95- "accepted_content_type" : [
96- "application/json"
97- ]
98- }
99- self .assertEquals (response .json , valid_response )
10075
10176 @mock .patch ("flask_jwt._jwt_required" )
10277 def test_app_is_responding_on_get_root (self , monkeypatch ):
@@ -105,8 +80,7 @@ def test_app_is_responding_on_get_root(self, monkeypatch):
10580 valid_response = {
10681 'available_routes' : [
10782 "api.mlapi.io/v2/token - Check current token balance status [POST]" ,
108- "api.mlapi.io/v2/cars - Car recognition NN[GET, POST]" ,
109- "api.mlapi.io/v2/sentiment - Text Sentiment Analysis [GET, POST]" ,
83+ "api.mlapi.io/v2/test1 - Car recognition NN[GET, POST]" ,
11084 ]
11185 }
11286 self .assertEquals (response .json , valid_response )
@@ -119,40 +93,10 @@ def test_app_is_redirecting_from_slash(self, identity_mock, monkeypatch):
11993
12094 response = self .client .get ("/" )
12195 self .assertRedirects (response , '/v2/' )
122- # @mock.patch("flask_jwt._jwt_required")
123- # @mock.patch("flask_jwt.current_identity")
124- # def test_app_is_redirecting_from_get_cars_with_trailing_slash(self, identity_mock, monkeypatch):
125- # monkeypatch = jwt_mock
126- # identity_mock = { 'user_id' : 1 }
127-
128- # response = self.client.get("/v2/cars/")
129- # self.assertRedirects(response, '/v2/cars')
130-
131- # @mock.patch("flask_jwt._jwt_required")
132- # @mock.patch("flask_jwt.current_identity")
133- # def test_app_is_redirecting_from_get_sentiment_with_trailing_slash(self, identity_mock, monkeypatch):
134- # monkeypatch = jwt_mock
135- # identity_mock = { 'user_id' : 1 }
136-
137- # response = self.client.get("/v2/sentiment/")
138- # self.assertRedirects(response, '/v2/sentiment')
13996
14097 ############################################################
14198 ######################## POST TESTS ########################
14299 ############################################################
143- @mock .patch ("flask_jwt._jwt_required" )
144- @mock .patch ("flask_jwt.current_identity" )
145- def test_app_is_responding_on_post_sentiment (self , identity_mock , monkeypatch ):
146- monkeypatch = jwt_mock
147- identity_mock = { 'user_id' : 1 }
148-
149- response = self .client .post ("/v2/sentiment" ,
150- data = '{"text":"polecam"}' ,
151- headers = {'content-type' : 'application/json' }
152- )
153- valid_response = "{'prediction': ['Neutral: 0.11%', 'Positive: 99.52%', 'Negative: 0.34%']}" .split (":" )[1 ::2 ]
154- self .assert_200 (response , "Not returned 200 code." )
155- self .assertEquals (str (response .json ).split (":" )[1 ::2 ], valid_response )
156100
157101 @mock .patch ("flask_jwt._jwt_required" )
158102 @mock .patch ("flask_jwt.current_identity" )
@@ -170,7 +114,7 @@ def test_posted_binary_image_gets_saved(self, patch_uuid, identity_mock, patch_j
170114
171115 image_name = "{}.{}" .format (fake_uuid , "jpg" )
172116 response = self .client .post (
173- '/v2/cars ' ,
117+ '/v2/test1 ' ,
174118 data = fake_image_bytes ,
175119 headers = {'content-type' : 'image/jpeg' }
176120 )
@@ -183,7 +127,7 @@ def test_posted_binary_image_gets_saved(self, patch_uuid, identity_mock, patch_j
183127
184128 image_name = "{}.{}" .format (fake_uuid , "png" )
185129 response = self .client .post (
186- '/v2/cars ' ,
130+ '/v2/test1 ' ,
187131 data = fake_image_bytes ,
188132 headers = {'content-type' : 'image/png' }
189133 )
@@ -210,7 +154,7 @@ def test_posted_base64_image_gets_saved(self, patch_uuid, identity_mock, patch_j
210154 b = base64 .b64decode (fake_image_json ['image' ].split ("," )[1 ])
211155 image_name = "{}.{}" .format (fake_uuid , "png" )
212156 response = self .client .post (
213- '/v2/cars ' ,
157+ '/v2/test1 ' ,
214158 data = json .dumps (fake_image_json ),
215159 headers = {'content-type' : 'application/json' }
216160 )
0 commit comments