def test_metric_exception(self): self.app = coral.create_app(**{'TESTING': False}) self.client = self.app.test_client() data = [ self._make_comment(n_replies=2, depth=1), self._make_comment(n_replies=2, depth=1), ] # munge the data to incorrect form for comment in data: del comment['_id'] resp = self._call_pipeline('comments/score', data) self.assertEquals(resp.status_code, 500) expected = { 'metric': str, 'type': str, 'message': str, 'data': list } resp_json = json.loads(resp.data.decode('utf-8')) for k, t in expected.items(): self.assertTrue(isinstance(resp_json[k], t))
from coral import coral app = coral.create_app() # for debugging # check /var/log/coral.log # app.config['DEBUG'] = True # app.config['PROPAGATE_EXCEPTIONS'] = True if __name__ == '__main__': app.run(debug=True, port=5001)
def setUp(self): self.app = coral.create_app(**test_config) self.client = self.app.test_client() self.counter = 0