def test_list_all_queries(): result, total_size = list_queries() assert len(result) == 4 assert total_size == 4 assert result[0].name == 'number_1' assert result[1].name == 'number_2'
def test_list_queries_paginated(): result, total_size = list_queries(2, 2) assert len(result) == 2 assert total_size == 4 assert result[0].name == 'number_3' assert result[1].name == 'number_4'
def test_update_query_notify(): result, _ = list_queries(text="number_3") _id = result[0].uuid assert not result[0].send_notification update_query_notify(_id, True) query = get_query(_id) assert query.send_notification
def test_update_query(): result, _ = list_queries(text="number_3") _id = result[0].uuid query = get_query(_id) description = "test update query" query.description = description # needed because update_query expect dto instead of model update_query(from_model_to_query_dto(query)) query = get_query(_id) assert query.description == description
def test_update_last_execution(): result, _ = list_queries(text="number_4") _id = result[0].uuid query = from_model_to_query_dto(get_query(_id)) steps_results = {} steps_results[1] = {"status": "SUCCESS", "responseSize": 8} steps_results[2] = {"status": "SUCCESS", "responseSize": 4} execution_date = datetime.utcnow() update_last_execution(query, 10, steps_results, execution_date) query = get_query(_id) assert query.last_execution_result == 10 assert query.steps[0].last_execution_status == "SUCCESS" assert query.steps[0].last_execution_result == 8 assert query.steps[1].last_execution_status == "SUCCESS" assert query.steps[1].last_execution_result == 4
def test_list_queries_empty(): Step.delete().execute() Query.delete().execute() queries = list_queries() assert queries[0] == []
def test_step_saved(): result, _ = list_queries(text="number_4") _id = result[0].uuid query = get_query(_id) assert len(query.steps) == 2
def test_get_query(): result, _ = list_queries(text="number_2") query = get_query(result[0].uuid) assert query.name == "number_2"
def test_delete_query(): result, total_size = list_queries(text="number_1") _id = result[0].uuid delete_query(_id) result, total_size = list_queries(text="number_1") assert total_size == 0
def test_list_query_upper_case(): result, total_size = list_queries(text='LAST QUERY') assert len(result) == 1 assert total_size == 1 assert result[0].description == '4th is the last query that we have'
def test_list_query_searching_description(): result, total_size = list_queries(text='another') assert len(result) == 1 assert total_size == 1 assert result[0].description == 'another description, but for second'
def test_list_query_text_none_found(): result, total_size = list_queries(text='test') assert len(result) == 0 assert total_size == 0
def test_list_query_text_many_found(): result, total_size = list_queries(text='number') assert len(result) == 4 assert total_size == 4 assert result[0].name == 'number_1'