def test_error(self, app, celery, raven):
     wifi = WifiShardFactory.build()
     res = app.post_json(
         '/v1/submit',
         [{'lat': wifi.lat, 'lon': wifi.lon, 'cell': []}],
         status=400)
     assert res.json == ParseError.json_body()
示例#2
0
文件: tests.py 项目: cemoulto/ichnaea
 def test_error(self):
     wifi = WifiShardFactory.build()
     res = self.app.post_json(
         '/v1/submit',
         [{'lat': wifi.lat, 'lon': wifi.lon, 'cell': []}],
         status=400)
     self.assertEqual(res.json, ParseError.json_body())
     self.check_raven(['ParseError'])
示例#3
0
 def test_error(self, app, celery, raven):
     wifi = WifiShardFactory.build()
     res = app.post_json(
         '/v1/submit',
         [{'lat': wifi.lat, 'lon': wifi.lon, 'cell': []}],
         status=400)
     assert res.json == ParseError.json_body()
     raven.check(['ParseError'])
示例#4
0
 def test_error(self):
     wifi = WifiShardFactory.build()
     res = self.app.post_json(
         '/v1/submit',
         [{'lat': wifi.lat, 'lon': wifi.lon, 'cell': []}],
         status=400)
     self.assertEqual(res.json, ParseError.json_body())
     self.check_raven(['ParseError'])
示例#5
0
 def test_error(self, app, celery, raven):
     wifi = WifiShardFactory.build()
     res = app.post_json("/v1/submit", [{
         "lat": wifi.lat,
         "lon": wifi.lon,
         "cell": []
     }],
                         status=400)
     assert res.json == ParseError.json_body()
示例#6
0
 def check_response(self, response, status):
     self.assertEqual(response.content_type, 'application/json')
     self.assertEqual(response.charset, 'UTF-8')
     if status == 'ok':
         self.assertEqual(response.json, self.ip_response)
     elif status == 'invalid_key':
         self.assertEqual(response.json, InvalidAPIKey.json_body())
     elif status == 'not_found':
         self.assertEqual(response.json, self.not_found.json_body())
     elif status == 'parse_error':
         self.assertEqual(response.json, ParseError.json_body())
     elif status == 'limit_exceeded':
         self.assertEqual(response.json, DailyLimitExceeded.json_body())
示例#7
0
 def check_response(self, response, status):
     self.assertEqual(response.content_type, 'application/json')
     self.assertEqual(response.charset, 'UTF-8')
     self.assertEqual(response.headers['Access-Control-Allow-Origin'], '*')
     self.assertEqual(response.headers['Access-Control-Max-Age'], '2592000')
     if status == 'ok':
         self.assertEqual(response.json, self.ip_response)
     elif status == 'invalid_key':
         self.assertEqual(response.json, InvalidAPIKey.json_body())
     elif status == 'not_found':
         self.assertEqual(response.json, self.not_found.json_body())
     elif status == 'parse_error':
         self.assertEqual(response.json, ParseError.json_body())
     elif status == 'limit_exceeded':
         self.assertEqual(response.json, DailyLimitExceeded.json_body())
示例#8
0
文件: base.py 项目: mate1983/ichnaea
 def check_response(self, response, status):
     self.assertEqual(response.content_type, 'application/json')
     self.assertEqual(response.charset, 'UTF-8')
     self.assertEqual(response.headers['Access-Control-Allow-Origin'], '*')
     self.assertEqual(response.headers['Access-Control-Max-Age'], '2592000')
     if status == 'ok':
         self.assertEqual(response.json, self.ip_response)
     elif status == 'invalid_key':
         self.assertEqual(response.json, InvalidAPIKey.json_body())
     elif status == 'not_found':
         self.assertEqual(response.json, self.not_found.json_body())
     elif status == 'parse_error':
         self.assertEqual(response.json, ParseError.json_body())
     elif status == 'limit_exceeded':
         self.assertEqual(response.json, DailyLimitExceeded.json_body())
示例#9
0
文件: base.py 项目: cemoulto/ichnaea
 def check_response(self, response, status):
     self.assertEqual(response.content_type, "application/json")
     self.assertEqual(response.charset, "UTF-8")
     self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*")
     self.assertEqual(response.headers["Access-Control-Max-Age"], "2592000")
     if status == "ok":
         self.assertEqual(response.json, self.ip_response)
     elif status == "invalid_key":
         self.assertEqual(response.json, InvalidAPIKey.json_body())
     elif status == "not_found":
         self.assertEqual(response.json, self.not_found.json_body())
     elif status == "parse_error":
         self.assertEqual(response.json, ParseError.json_body())
     elif status == "limit_exceeded":
         self.assertEqual(response.json, DailyLimitExceeded.json_body())
示例#10
0
文件: base.py 项目: amjadm61/ichnaea
 def check_response(self, data_queues, response, status):
     assert response.content_type == 'application/json'
     assert response.headers['Access-Control-Allow-Origin'] == '*'
     assert response.headers['Access-Control-Max-Age'] == '2592000'
     if status == 'ok':
         assert response.json == self.ip_response
     elif status == 'invalid_key':
         assert response.json == InvalidAPIKey.json_body()
     elif status == 'not_found':
         assert response.json == self.not_found.json_body()
     elif status == 'parse_error':
         assert response.json == ParseError.json_body()
     elif status == 'limit_exceeded':
         assert response.json == DailyLimitExceeded.json_body()
     if status != 'ok':
         self.check_queue(data_queues, 0)
示例#11
0
 def check_response(self, data_queues, response, status, fallback=None):
     assert response.content_type == 'application/json'
     assert response.headers['Access-Control-Allow-Origin'] == '*'
     assert response.headers['Access-Control-Max-Age'] == '2592000'
     if status == 'ok':
         body = dict(response.json)
         if fallback:
             assert body['fallback'] == fallback
             del body['fallback']
         assert body == self.ip_response
     elif status == 'invalid_key':
         assert response.json == InvalidAPIKey.json_body()
     elif status == 'not_found':
         assert response.json == self.not_found.json_body()
     elif status == 'parse_error':
         assert response.json == ParseError.json_body()
     elif status == 'limit_exceeded':
         assert response.json == DailyLimitExceeded.json_body()
     if status != 'ok':
         self.check_queue(data_queues, 0)
示例#12
0
 def check_response(self, data_queues, response, status, fallback=None):
     assert response.content_type == "application/json"
     assert response.headers["Access-Control-Allow-Origin"] == "*"
     assert response.headers["Access-Control-Max-Age"] == "2592000"
     if status == "ok":
         body = dict(response.json)
         if fallback:
             assert body["fallback"] == fallback
             del body["fallback"]
         assert body == self.ip_response
     elif status == "invalid_key":
         assert response.json == InvalidAPIKey.json_body()
     elif status == "not_found":
         assert response.json == self.not_found.json_body()
     elif status == "parse_error":
         assert response.json == ParseError.json_body()
     elif status == "limit_exceeded":
         assert response.json == DailyLimitExceeded.json_body()
     if status != "ok":
         self.check_queue(data_queues, 0)
示例#13
0
 def test_error_no_mapping(self, app, raven):
     res = app.post_json(self.url, [1], status=400)
     assert res.json == ParseError.json_body()
示例#14
0
 def test_error_no_json(self, app, raven):
     res = app.post(self.url, '\xae', status=400)
     assert res.json == ParseError.json_body()
示例#15
0
 def test_error_get(self, app, raven):
     res = app.get(self.url, status=400)
     assert res.json == ParseError.json_body()
示例#16
0
 def test_error_empty_body(self):
     res = self.app.post(self.url, '', status=400)
     self.assertEqual(res.json, ParseError.json_body())
     self.check_raven([('ParseError', 1)])
示例#17
0
 def test_parse_error(self):
     res = self.app.post('%s?key=test' % self.url, '\xae', status=400)
     self.assertEqual(res.content_type, 'application/json')
     self.assertEqual(res.json, ParseError.json_body())
     self.check_stats(counter=[self.metric + '.api_key.test'])
示例#18
0
文件: base.py 项目: ingle/ichnaea
 def test_error_empty_body(self):
     res = self.app.post(self.url, '', status=400)
     self.assertEqual(res.json, ParseError.json_body())
     self.check_raven([('ParseError', 1)])
示例#19
0
 def test_error_no_mapping(self):
     res = self.app.post_json('/v1/search?key=test', [1], status=400)
     self.assertEqual(res.content_type, 'application/json')
     self.assertEqual(res.json, ParseError.json_body())
示例#20
0
 def test_error_no_mapping(self, app):
     res = self._call(app, [1], method='post_json', status=400)
     assert res.json == ParseError.json_body()
示例#21
0
 def test_error_no_json(self, app):
     res = self._call(app, '\xae', method='post', status=400)
     assert res.json == ParseError.json_body()
示例#22
0
 def test_error_get(self, app):
     res = self._call(app, method='get', status=400)
     assert res.json == ParseError.json_body()
示例#23
0
 def test_error_empty_json(self, app, raven):
     res = app.post_json(self.url, {}, status=400)
     assert res.json == ParseError.json_body()
示例#24
0
 def test_error_no_mapping(self):
     res = self.app.post_json('/v1/submit', [1], status=400)
     self.assertEqual(res.json, ParseError.json_body())
示例#25
0
 def test_error_completely_empty(self):
     res = self.app.post_json(self.url, [], status=400)
     self.assertEqual(res.content_type, 'application/json')
     self.assertEqual(res.json, ParseError.json_body())
示例#26
0
文件: base.py 项目: SOFTowaha/ichnaea
 def test_error_empty_json(self):
     res = self.app.post_json(self.url, {}, status=400)
     self.assertEqual(res.json, ParseError.json_body())
示例#27
0
文件: base.py 项目: voolitels/ichnaea
 def test_error_get(self):
     res = self.app.get(self.url, status=400)
     self.assertEqual(res.json, ParseError.json_body())
     self.check_raven([("ParseError", 1)])
示例#28
0
文件: base.py 项目: SOFTowaha/ichnaea
 def test_error_no_json(self):
     res = self.app.post(self.url, '\xae', status=400)
     self.assertEqual(res.json, ParseError.json_body())
示例#29
0
 def test_error_get(self, app):
     res = self._call(app, method='get', status=400)
     assert res.json == ParseError.json_body()
示例#30
0
文件: base.py 项目: amjadm61/ichnaea
 def test_error_empty_body(self, app, raven):
     res = app.post(self.url, '', status=400)
     assert res.json == ParseError.json_body()
     raven.check([('ParseError', 1)])
示例#31
0
 def test_error_no_json(self, app):
     res = self._call(app, '\xae', method='post', status=400)
     assert res.json == ParseError.json_body()
示例#32
0
文件: base.py 项目: ingle/ichnaea
 def test_error_no_mapping(self):
     res = self.app.post_json(self.url, [1], status=400)
     self.assertEqual(res.json, ParseError.json_body())
     self.check_raven([('ParseError', 1)])
示例#33
0
 def test_error_no_mapping(self, app):
     res = self._call(app, [1], method='post_json', status=400)
     assert res.json == ParseError.json_body()
示例#34
0
文件: base.py 项目: voolitels/ichnaea
 def test_error_no_json(self):
     res = self.app.post(self.url, "\xae", status=400)
     self.assertEqual(res.json, ParseError.json_body())
     self.check_raven([("ParseError", 1)])
示例#35
0
 def test_error_get(self, app, raven):
     res = app.get(self.url, status=400)
     assert res.json == ParseError.json_body()
示例#36
0
 def test_error_no_mapping(self):
     res = self.app.post_json(self.url, [1], status=400)
     self.assertEqual(res.json, ParseError.json_body())
     self.check_raven([('ParseError', 1)])
示例#37
0
 def test_no_json(self):
     res = self.app.post('/v1/search?key=test', '\xae', status=400)
     self.assertEqual(res.json, ParseError.json_body())
     self.check_stats(counter=['search.api_key.test'])
示例#38
0
 def test_error_empty_json(self, app, raven):
     res = app.post_json(self.url, {}, status=400)
     assert res.json == ParseError.json_body()
示例#39
0
文件: base.py 项目: SOFTowaha/ichnaea
 def test_error_get(self):
     res = self.app.get(self.url, status=400)
     self.assertEqual(res.json, ParseError.json_body())
示例#40
0
 def test_error_no_mapping(self, app, raven):
     res = app.post_json(self.url, [1], status=400)
     assert res.json == ParseError.json_body()
示例#41
0
 def test_error_no_json(self, app, raven):
     res = app.post(self.url, '\xae', status=400)
     assert res.json == ParseError.json_body()