def test_db_invalid_read(env_setup, db_insert_test_data, db_read_test_data, response_test_data): """Function for testing invalid db read""" UserQueryTranslator( db_insert_test_data.get("valid")).process_data() # inserting data test_string = UserQueryTranslator( db_read_test_data.get("invalid1")).process_data() # testing assert test_string == response_test_data.get("invalid_read1")
def process_data(username): """End point for processing data""" _, token = request.headers["Authorization"].split() if AuthorizationManager().validate_token(username, token): if request.json: return UserQueryTranslator(request.json).process_data() else: return "No Payload", 403 else: return "Not Authorized", 403
def test_db_insert(env_setup, db_insert_test_data, response_test_data): """Function for DB insert""" test_string = UserQueryTranslator( db_insert_test_data.get("valid")).process_data() assert test_string == response_test_data.get("valid_insert")
def test_invalid_db_delete(env_setup, db_delete_test_data, response_test_data): """Function for DB invalid delete""" test_string = UserQueryTranslator( db_delete_test_data.get("invalid")).process_data() assert test_string == response_test_data.get("invalid_delete")
def test_db_cleanup(db_delete_test_data, response_test_data): """Function for DB cleanup""" test_string = UserQueryTranslator( db_delete_test_data.get("valid")).process_data() assert test_string == response_test_data.get("valid_delete")