def test_get_app_with_checks(self): self.add_heroku_response(responses.GET, '/account/rate-limits') happs = self.add_heroku_response(responses.GET, '/apps') app_id = happs[0]['id'] happ = self.add_heroku_response(responses.GET, '/apps/{}'.format(app_id)) with app.test_request_context(): url = api.url_for(App, app_id=app_id) dbapp = models.App(id=app_id, name=happ['name']) db.session.add(dbapp) check = models.Check(app_id=app_id, url='http://example.com', dynotype='test') db.session.add(check) response = self.client.get(url) data = json.loads(response.data) self.assertEquals( data, { 'name': dbapp.name, 'id': dbapp.id, 'checks': { check.dynotype: str(check.id) }, })
def test_get_list(self): self.add_heroku_response(responses.GET, '/account/rate-limits') happs = self.add_heroku_response(responses.GET, '/apps') with app.test_request_context(): url = api.url_for(AppList) response = self.client.get(url) data = json.loads(response.data) self.assertEquals(data, { happs[0]['name']: happs[0]['id'], })
def test_get_app_no_model(self): self.add_heroku_response(responses.GET, '/account/rate-limits') happs = self.add_heroku_response(responses.GET, '/apps') app_id = happs[0]['id'] happ = self.add_heroku_response(responses.GET, '/apps/{}'.format(app_id)) with app.test_request_context(): url = api.url_for(App, app_id=app_id) response = self.client.get(url) data = json.loads(response.data) self.assertEquals(data, { 'name': happ['name'], 'id': happ['id'], 'checks': {}, })
def test_get_app_with_checks(self): self.add_heroku_response(responses.GET, '/account/rate-limits') happs = self.add_heroku_response(responses.GET, '/apps') app_id = happs[0]['id'] happ = self.add_heroku_response(responses.GET, '/apps/{}'.format(app_id)) with app.test_request_context(): url = api.url_for(App, app_id=app_id) dbapp = models.App(id=app_id, name=happ['name']) db.session.add(dbapp) check = models.Check(app_id=app_id, url='http://example.com', dynotype='test') db.session.add(check) response = self.client.get(url) data = json.loads(response.data) self.assertEquals(data, { 'name': dbapp.name, 'id': dbapp.id, 'checks': {check.dynotype: str(check.id)}, })
def setUp(self): super(CheckTestCase, self).setUp() self.app = self.create_app() self.user = self.create_user() with app.test_request_context(): self.url = api.url_for(Check, app_id=self.app.id, dynotype='web')