Finishing the tests for Excel features.

anticaptcha
Pedro de Oliveira Guedes 2022-01-11 08:14:13 -03:00
parent c10ab05fc6
commit ba9dd6a951
2 changed files with 70 additions and 5 deletions

View File

@ -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.
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]

View File

@ -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."