diff --git a/api/excel/features/excel.feature b/api/excel/features/excel.feature index 9695413..56f2e18 100644 --- a/api/excel/features/excel.feature +++ b/api/excel/features/excel.feature @@ -1,8 +1,21 @@ Feature: The Excel API client -# ======================== Excel Read method ======================== - # Scenario: Using the Excel Read method - # It is not posible to test this method, because there is no way to know where will be an Excel sheet on the user's machine. +# ======================== Excel New method ======================== + Scenario: Using the Excel New method + Given an Excel client + When the Excel New method is called + Then a new Excel sheet must be created # ======================== Excel Write method ======================== - # Scenario: Using the Excel Write method - # It is not posible to test this method, because there is no way to know where will be an Excel sheet on the user's machine. \ No newline at end of file + Scenario: Using the Excel Write method + Given an Excel client + And an Excel sheet + When the Excel Write method is called on this sheet to write + Then the writing must be successful + +# ======================== Excel Read method ======================== + Scenario: Using the Excel Read method + Given an Excel client + And an Excel sheet + And the text "churros" text written in the A1 cell + When the Excel Read method is called + Then the word "churros" must be returned in the position [0][0] \ No newline at end of file diff --git a/api/excel/features/steps/steps.py b/api/excel/features/steps/steps.py index e69de29..177f5da 100644 --- a/api/excel/features/steps/steps.py +++ b/api/excel/features/steps/steps.py @@ -0,0 +1,52 @@ +from behave import * + +from cli import Excel +import os + +# ===================================== Excel New ===================================== +@given(u'an Excel client') +def step_impl(context): + 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", "") + +@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." + + +# ===================================== Excel Write ===================================== +@given(u'an Excel sheet') +def step_impl(context): + path = os.getcwd() + context.new_return = context.client.new(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") + +@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." + + +# ===================================== 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") + +@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") + +@then(u'the word "churros" must be returned in the position [0][0]') +def step_impl(context): + assert context.read_return[0][0] == "churros", "The Read method did not worked as axpected." \ No newline at end of file