From d83ff983658d943858af8e243282b504178023d0 Mon Sep 17 00:00:00 2001 From: Pedro de Oliveira Guedes Date: Mon, 17 Jan 2022 12:26:36 -0300 Subject: [PATCH] Adding tests to the new methods. --- api/replay/features/replay.feature | 11 +++++++++-- api/replay/features/steps/steps.py | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/api/replay/features/replay.feature b/api/replay/features/replay.feature index 05511a0..4de8370 100644 --- a/api/replay/features/replay.feature +++ b/api/replay/features/replay.feature @@ -1,6 +1,13 @@ -Feature: The environment variables getters +Feature: The Replay API client Scenario: Testing every environment variable getter Given the Replay client When each one of the getters is called - Then all of the returns must be either of the type string or the type None \ No newline at end of file + Then all of the returns must be either of the type string or the type None + + + Scenario: Testing the process of creating and registering a Log + Given the Replay client + And a Log created + When the log method is called + Then this new log must be registered in the Replay Data Base \ No newline at end of file diff --git a/api/replay/features/steps/steps.py b/api/replay/features/steps/steps.py index 71746a1..bf35cec 100644 --- a/api/replay/features/steps/steps.py +++ b/api/replay/features/steps/steps.py @@ -1,6 +1,8 @@ from behave import * from cli import Replay +from datetime import datetime + # ============================= ENVIRONMENT VARIABLES GETTERS ============================= @given(u'the Replay client') def step_impl (context): @@ -14,3 +16,19 @@ def step_impl(context): def step_impl(context): for ret in context.returns.keys(): assert ( type(ret) == type(None) or type(ret) == type("") ), f'Something went wrong with the {context.returns[ret]} variable getter.' + + + +# ============================= LOG REGISTERS ============================= +@given(u'a Log created') +def step_impl(context): + context.log = context.client.new_log() + +@when(u'the log method is called') +def step_impl(context): + context.dt_log_end = datetime.now().isoformat() + "Z" + context.log_return = context.client.log(context.log) + +@then(u'this new log must be registered in the Replay Data Base') +def step_impl(context): + assert (context.client.sql("select * from logs")["data"][-1]["dtlogend"] == context.dt_log_end and context.log_return == "ok") \ No newline at end of file