def test_update_query_notify_without_flag():
    result, _ = list_queries(text="number_3")
    _id = result[0].uuid
    update_query_notify(_id, True)
    query = get_query(_id)
    assert query.send_notification
    update_query_notify(_id, None)
    query = get_query(_id)
    assert not 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_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"