Exemplo n.º 1
0
    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({})
Exemplo n.º 2
0
    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())
Exemplo n.º 3
0
def test_invalid_get_database():
    with pytest.raises(SystemExit):
        app.get_database('https://hackernewsgraphs123.firebaseio.com/')
Exemplo n.º 4
0
def test_get_database():
    assert app.get_database(
        'https://hackernewsgraphs.firebaseio.com/') is not None
Exemplo n.º 5
0
 def tearDown(self):
     # clear out testing database
     with app.app.app_context():
         get_database().project.delete_many({})