From ce6e2e7340b4f3945da87473a806b332aff8de0b Mon Sep 17 00:00:00 2001 From: Chris Araujo Date: Sun, 21 Feb 2021 20:20:41 -0300 Subject: [PATCH] Desafio Concrete Solutions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scripts do desafio Kata 09 e arquivos .features contendo cenários de testes da aplicação whatsapp --- .../README.md | 9 +++ .../__init__.py | 0 .../checkOut.py | 59 +++++++++++++++++++ .../rulesprice.py | 19 ++++++ .../features/Sharing_and_location.feature | 37 ++++++++++++ .../features/UserStatus.feature | 33 +++++++++++ 6 files changed, 157 insertions(+) create mode 100644 Desafio QA Concrete - Ely Chris Araujo/README.md create mode 100644 Desafio QA Concrete - Ely Chris Araujo/__init__.py create mode 100644 Desafio QA Concrete - Ely Chris Araujo/checkOut.py create mode 100644 Desafio QA Concrete - Ely Chris Araujo/rulesprice.py create mode 100644 Desafio QA Concrete - Ely Chris Araujo/whatsapp_scenarios/features/Sharing_and_location.feature create mode 100644 Desafio QA Concrete - Ely Chris Araujo/whatsapp_scenarios/features/UserStatus.feature diff --git a/Desafio QA Concrete - Ely Chris Araujo/README.md b/Desafio QA Concrete - Ely Chris Araujo/README.md new file mode 100644 index 0000000..d822478 --- /dev/null +++ b/Desafio QA Concrete - Ely Chris Araujo/README.md @@ -0,0 +1,9 @@ +# Kata09: Back to the Checkout + +Script desenvolvido em python lingugem que estou estudando +Teste unitarios não desenvolvido por não conhecer ferramentas de testes unnitários, conforme conversado, com os enrevistadores eu não programo há mais de 8 anos + + + +## Notes +Cenarios de testes para a aplicação whatsapp baseados na ferramenta Gerkhin \ No newline at end of file diff --git a/Desafio QA Concrete - Ely Chris Araujo/__init__.py b/Desafio QA Concrete - Ely Chris Araujo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Desafio QA Concrete - Ely Chris Araujo/checkOut.py b/Desafio QA Concrete - Ely Chris Araujo/checkOut.py new file mode 100644 index 0000000..b9628ae --- /dev/null +++ b/Desafio QA Concrete - Ely Chris Araujo/checkOut.py @@ -0,0 +1,59 @@ +# Ely Chris Araujo +# Date: 21, february, 2021 + +import re +import rulesprice + +class Checkout(object): + + def __init__(self): + self.cart = {} + + def scan(self, codes): + """ + Lê uma string com a sequencia do produto e guarda no carrinho (cart). + :return none + """ + for code in codes: + if code in self.cart: + self.cart[code] += 1 + else: + self.cart[code] = 1 + + def calculate_total(self): + """ + Calcule o valor total considerando os itens do carrinho. + :return total: int + """ + total = 0 + + # Faz a iteração no dicionário que contém os códigos dos produtos e + # suas ocorrências (quantas vezes eles apareceram na string lida). + for code, occurence in self.cart.iteritems(): + counter = {} + product = code * occurence + prices_rules = list(reversed(sorted(rules.prices[code].keys()))) + + # Repite as regras de preços e pesquisa quantas vezes o produto aparece na sequência + # da regra, depois calcule os totais. Ele faz isso recursivamente com o "resto" + # até que a lista de regras de preços seja concluída. + for rule in prices_rules: + counter[rule] = 0 + ls = re.findall('.{1,' + str(rule) + '}', product) + for item in ls: + if len(item) != rule: + product = item + else: + product = "" + counter[rule] += 1 + + # Calcule a quantidade total em toda a iteração do dicionário a partir + # do arquivo rules.py. + for group, value in counter.iteritems(): + total += rules.prices[code][group] * value + + return total + + +if __name__ == '__main__': + pass diff --git a/Desafio QA Concrete - Ely Chris Araujo/rulesprice.py b/Desafio QA Concrete - Ely Chris Araujo/rulesprice.py new file mode 100644 index 0000000..7fa83c5 --- /dev/null +++ b/Desafio QA Concrete - Ely Chris Araujo/rulesprice.py @@ -0,0 +1,19 @@ +# Definição da regra de preço dos produtos. + + +prices = { + "A": { + 1: 50, + 3: 130 + }, + "B": { + 1: 30, + 2: 45 + }, + "C": { + 1: 20 + }, + "D": { + 1: 15 + } +} diff --git a/Desafio QA Concrete - Ely Chris Araujo/whatsapp_scenarios/features/Sharing_and_location.feature b/Desafio QA Concrete - Ely Chris Araujo/whatsapp_scenarios/features/Sharing_and_location.feature new file mode 100644 index 0000000..70d7640 --- /dev/null +++ b/Desafio QA Concrete - Ely Chris Araujo/whatsapp_scenarios/features/Sharing_and_location.feature @@ -0,0 +1,37 @@ +# Created using an Android phone by Ely_araujo at 2/20/2020 +Feature: Sharing and attach function + + Scenario: Open the camera + Given User is at a chat session + When User touches on paper clip icon + And Selects the camera option + Then The camera should be opened + + + Scenario: Send an emoticon icon + Given User is at a chat session + When User touches in a emoticon icon besides the clip paper + And Selects a smiley icon + Then The smiley icon should be sent to the chat + + + Scenario: Send an contact + Given User is at a chat screen + When User touches on paper clip icon + And Selects contact number + Then the contact selected should appear sent on the chat screen + + Scenario: Stop Live Location Sharing + Given User is at a chat screen + And User has shared location + When User selects to stop sharing + Then Location sharing stops + And Location should stop on last user position + + Scenario: Share a location + Given User is at a chat screen + And There is a location shared on conversation + When User selects forward message + And Chooses the receiver + And Confirm location forwarding + Then Location is shared with receiver \ No newline at end of file diff --git a/Desafio QA Concrete - Ely Chris Araujo/whatsapp_scenarios/features/UserStatus.feature b/Desafio QA Concrete - Ely Chris Araujo/whatsapp_scenarios/features/UserStatus.feature new file mode 100644 index 0000000..2b0693d --- /dev/null +++ b/Desafio QA Concrete - Ely Chris Araujo/whatsapp_scenarios/features/UserStatus.feature @@ -0,0 +1,33 @@ +# Created using an Android phone by Ely_araujo at 2/20/2020 +Feature: User Status + + Scenario: Add User status + Given User is at Status Screen + When User selects "My status" option + And Takes a photo or video + And Selects confirm option + Then User status is posted on Status screen + + Scenario: Create a text status + Given User is at Status Screen + When User selects pencil icon + And Insert "abc" on text field + And Selects confirm option + Then User status is posted with "abc" text + + + Scenario: View a recent update + Given User is at Status Screen + And There is at least one status on recent updates + When User selects a status from user "x" + Then User "x" status is shown + And User "x" status must be placed at viewed updates + + Scenario: Change User status privacy + Given User is at "privacy" screen + And There is at least one contact on user phone + When User selects "status" option + And Selects "Only share with..." option + And Selects at least one contact from phone + And Selects confirm option + Then User Status privacy is changed to "Only share with..." \ No newline at end of file