From 08161fd276edbd4461f4d48f39dc585792cc59a5 Mon Sep 17 00:00:00 2001 From: Pedro de Oliveira Guedes Date: Thu, 20 Jan 2022 10:42:57 -0300 Subject: [PATCH] Finishing the tests for the dataAPI client. --- api/dataapi/features/data_api.feature | 13 +++++++ api/dataapi/features/steps/steps.py | 53 +++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/api/dataapi/features/data_api.feature b/api/dataapi/features/data_api.feature index e69de29..ea22141 100644 --- a/api/dataapi/features/data_api.feature +++ b/api/dataapi/features/data_api.feature @@ -0,0 +1,13 @@ +Feature: The Data API Client + Scenario: Testing the data_API.do() method + Given a data_API client + When a new table is created with the value "Bond" for the query "the_name_is" + Then the value retrieved from the new table associated with the query "the_name_is" must be "Bond" + + + Scenario: Testing the data_API.registrar_exec method + Given a data_API client + When the registrar_exec method is called with True for check + And the registrar_exec method is called with False for check + And data is retrieved from the table + Then there must be at least 1 register for "exec" and "err" today \ No newline at end of file diff --git a/api/dataapi/features/steps/steps.py b/api/dataapi/features/steps/steps.py index e69de29..e48c885 100644 --- a/api/dataapi/features/steps/steps.py +++ b/api/dataapi/features/steps/steps.py @@ -0,0 +1,53 @@ +from behave import * +from cli import * + +# ============================= DATA_API DO ============================= +@given(u'a data_API client') +def step_impl(context): + context.client = DataAPI ("Insira aqui a chave de API. VocĂȘ pode obtĂȘ-la pedindo ao fornecedor deste client.") + +@when(u'a new table is created with the value "Bond" for the query "the_name_is"') +def step_impl(context): + context.client.do ({ + "Col": "newTestTable", + "Op": "C", + "Data": { + "the_name_is": "Bond", + "James": "Bond" + } + }) + +@then(u'the value retrieved from the new table associated with the query "the_name_is" must be "Bond"') +def step_impl(context): + context.retrieved_data = context.client.do({ + "Col": "newTestTable", + "Op": "R" + })["data"][0] + + context.query_value = context.retrieved_data["the_name_is"] + + assert context.query_value == "Bond", "Something went wrong with the method Do" + + +# ============================= DATA_API REGISTRAR_EXEC ============================= +@when(u'the registrar_exec method is called with True for check') +def step_impl(context): + context.client.registrar_exec("anotherNewTestTable", True) + +@when(u'the registrar_exec method is called with False for check') +def step_impl(context): + context.client.registrar_exec("anotherNewTestTable", False) + +@when(u'data is retrieved from the table') +def step_impl(context): + today_date = datetime.now().isoformat()[:10] + + context.retrieved_data = context.client.do({ + "Col": "anotherNewTestTable", + "Op": "R", + "Q": f"@[?date=='{today_date}']" + })["data"][0] + +@then(u'there must be at least 1 register for "exec" and "err" today') +def step_impl(context): + assert context.retrieved_data["exec"] > 0 and context.retrieved_data["err"] > 0, "Something went wrong with the method registrar_exec" \ No newline at end of file