def setUp(self): self.app = app.app self.app.config.from_object('settings.TestingSettings') self.test_client = self.app.test_client(self) # clear out testing database, make sure we start anew with app.app.app_context(): get_database().project.delete_many({})
def test_get_project(self): # insert a project into testing database project_data = test_data_get_project with app.app.app_context(): project = Project(get_database()) project.Create(name=project_data['name'], created_on=project_data['created_on']) response = self.test_client.get(self.app.config['APP_ENDPOINT'] + '/projects/' + project.getId() + '/', content_type='application/json') data = json.loads(response.data.decode()) # We have to convert the json oid to an actual ObjectId to match Project class data['_id'] = ObjectId(data['_id']['$oid']) self.assertEqual(response.status_code, 200) self.assertEqual(data, project.Get())
def test_invalid_get_database(): with pytest.raises(SystemExit): app.get_database('https://hackernewsgraphs123.firebaseio.com/')
def test_get_database(): assert app.get_database( 'https://hackernewsgraphs.firebaseio.com/') is not None
def tearDown(self): # clear out testing database with app.app.app_context(): get_database().project.delete_many({})