def test_valid_search_specs(flask_app, db): seed_database(db) create_views(db) # Check empty result is return headers = {'Content-type': 'application/json'} body_data = { "start": 1, "limit": 10, "search_specs": { "group": "reviewer", "request_type": 2, "user_id": "" }, "search_args": { "id": "10201112000" } } rv = flask_app.post(SEARCH_API, data=json.dumps(body_data), headers=headers) assert rv.status_code == 200 data = json.loads(rv.data.decode('utf-8')) assert data['requests'] == [] body_data['search_args'] = {} rv = flask_app.post(SEARCH_API, data=json.dumps(body_data), headers=headers) assert rv.status_code == 200 data = json.loads(rv.data.decode('utf-8')) assert data['requests'] == []
def db(app): """fixture to inject temp db instance into tests.""" # need to import this late it might cause problems from app import db # create and configure database db.app = app db.create_all() seed_database(db) create_views(db) yield db # teardown database db.engine.execute('DROP TABLE technologies CASCADE') db.engine.execute('DROP TABLE status CASCADE') db.engine.execute('DROP TABLE devicetype CASCADE') db.engine.execute('DROP TABLE documents CASCADE') db.session.close() db.drop_all()