From 1a9e698b56dc0af342c7c1dabeca88a3693d51cb Mon Sep 17 00:00:00 2001 From: Pedro de Oliveira Guedes Date: Tue, 11 Jan 2022 08:20:59 -0300 Subject: [PATCH] Minor tests improvements. --- api/excel/features/steps/steps.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/api/excel/features/steps/steps.py b/api/excel/features/steps/steps.py index 177f5da..f81fdb6 100644 --- a/api/excel/features/steps/steps.py +++ b/api/excel/features/steps/steps.py @@ -6,46 +6,40 @@ import os # ===================================== Excel New ===================================== @given(u'an Excel client') def step_impl(context): + context.path = os.getcwd() context.client = Excel() @when(u'the Excel New method is called') def step_impl(context): - path = os.getcwd() - context.new_return = context.client.new(path+"/test.xls", "") + context.new_return = context.client.new(context.path+"/test.xls", "") @then(u'a new Excel sheet must be created') def step_impl(context): - path = os.getcwd() - assert context.new_return == "ok" and "test.xls" in os.listdir(path), "The Excel sheet was not created as expected." + assert context.new_return == "ok" and "test.xls" in os.listdir(context.path), "The Excel sheet was not created as expected." # ===================================== Excel Write ===================================== @given(u'an Excel sheet') def step_impl(context): - path = os.getcwd() - context.new_return = context.client.new(path+"/test.xls", "") + context.new_return = context.client.new(context.path+"/test.xls", "") @when(u'the Excel Write method is called on this sheet to write') def step_impl(context): - path = os.getcwd() - context.write_return = context.client.write(path+"/test.xls", "Planilha1", "A1", "churros", "s") + context.write_return = context.client.write(context.path+"/test.xls", "Planilha1", "A1", "churros", "s") @then(u'the writing must be successful') def step_impl(context): - path = os.getcwd() - assert context.write_return == "ok" and context.client.read(path+"/test.xls", "Planilha1")[0][0] == "churros", "The Write method failed unexpectedly." + assert context.write_return == "ok" and context.client.read(context.path+"/test.xls", "Planilha1")[0][0] == "churros", "The Write method failed unexpectedly." # ===================================== Excel Read ===================================== @given(u'the text "churros" text written in the A1 cell') def step_impl(context): - path = os.getcwd() - context.write_return = context.client.write(path+"/test.xls", "Planilha1", "A1", "churros", "s") + context.write_return = context.client.write(context.path+"/test.xls", "Planilha1", "A1", "churros", "s") @when(u'the Excel Read method is called') def step_impl(context): - path = os.getcwd() - context.read_return = context.client.read(path+"/test.xls", "Planilha1") + context.read_return = context.client.read(context.path+"/test.xls", "Planilha1") @then(u'the word "churros" must be returned in the position [0][0]') def step_impl(context):