Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA challenge for Concrete Solutions - Arthur Wanderley #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Objetivo do Desafio

Verificar suas habilidades em conceber cenários de testes e em programação, necessárias para automatização dos testes.
Expand Down
60 changes: 60 additions & 0 deletions kata09/checkOut.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from kata09.item import Item


# Class responsible for Managing checkout
class CheckOut:
items = []
item_queue: dict = {}
total = 0

# Class Constructor
def __init__(self, pricing_rules):
for rule in pricing_rules:
item = Item(rule)
self.items.append(item)

self.total = 0
self.item_queue = {}

# Method responsible for scanning an item x
def scan(self, item):
# If item has not been included before, add to dict
if item not in self.item_queue.keys():
self.item_queue.update({item: 1})
# else, increase item x count by 1
else:
self.item_queue.update({item: self.item_queue[item] + 1})

# then, calculate new total after this scanning
self.calculate_total()

# Method responsible for calculating price total using a list of scanned products
def calculate_total(self):
total = 0
# for each group of items (A, B, C or D)
for key in self.item_queue.keys():

# Get item rule and special price rules for it
rule = [x for x in self.items if x.name == key]
key_special_prices = rule[0].special_price

# If there's a special rule for the item X, get max_amount (if there's more than one rule available -
# flexibility)
try:
max_amount = max([int(s) for s in key_special_prices.keys()])
# If not, max_amount is set as 0
except ValueError as e:
max_amount = 0

# If there's a special rule and the amount of items of an item X is equal or greater than max_amount,
# apply special rule for the groups of items and the others (mod) to be applied by unit_price
if 0 < max_amount <= self.item_queue[key]:
special_total = (self.item_queue[key] // max_amount * key_special_prices[max_amount])
unit_total = (self.item_queue[key] % max_amount) * rule[0].unit_price
total = total + unit_total + special_total

# If not, just apply unit_price for the amount of items
else:
total = total + (self.item_queue[key] * rule[0].unit_price)

self.total = total
12 changes: 12 additions & 0 deletions kata09/item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Domain class to manage items and prices (unit and special)
class Item:
name = ""
unit_price = 0
special_price: dict = {}

def __init__(self, price_rule):
self.name = price_rule[0]
self.unit_price = price_rule[1]
self.special_price = {}
for price in price_rule[2]:
self.special_price.update({price[0]: price[1]})
54 changes: 54 additions & 0 deletions kata09/test/testPrice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import unittest

from kata09.checkOut import CheckOut


# Test Class (Structure copied from Kata09.md)
class TestPrice(unittest.TestCase):
PRICING_RULES = [
("A", 50, [(3, 130)]),
("B", 30, [(2, 45)]),
("C", 20, []),
("D", 15, [])
]

def price(self, goods):
co = CheckOut(self.PRICING_RULES)
if goods == "":
return 0
else:
for item in goods:
co.scan(item)

# print(co.total)
return co.total

def test_totals(self):
self.assertEqual(0, self.price(""))
self.assertEqual(50, self.price("A"))
self.assertEqual(80, self.price("AB"))
self.assertEqual(115, self.price("CDBA"))
self.assertEqual(100, self.price("AA"))
self.assertEqual(130, self.price("AAA"))
self.assertEqual(180, self.price("AAAA"))
self.assertEqual(230, self.price("AAAAA"))
self.assertEqual(260, self.price("AAAAAA"))

self.assertEqual(160, self.price("AAAB"))
self.assertEqual(175, self.price("AAABB"))
self.assertEqual(190, self.price("AAABBD"))
self.assertEqual(190, self.price("DABABA"))

def test_incremental(self):
co = CheckOut(self.PRICING_RULES)
self.assertEqual(0, co.total)
co.scan("A")
self.assertEqual(50, co.total)
co.scan("B")
self.assertEqual(80, co.total)
co.scan("A")
self.assertEqual(130, co.total)
co.scan("A")
self.assertEqual(160, co.total)
co.scan("B")
self.assertEqual(175, co.total)
41 changes: 41 additions & 0 deletions whatsApp/features/location.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Feature: Location Sharing

Scenario: Send Current Location
Given User is at a chat screen
When User touches on paper clip icon
And Selects location option
And Chooses to send current location
Then Location is sent on chat
And Location must be compliant with actual user location

Scenario: Share Live Location
Given User is at a chat screen
When User touches on paper clip icon
And Selects location option
And Chooses to share live location
And Selects 15 minutes option
And Selects send button
Then Location is shared on chat
And Location must be on for 15 minutes

Scenario: Refresh nearby places
Given User is at a chat screen
When User touches on paper clip icon
And Selects location option
And Selects refresh button
Then List of nearby places is updated

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
43 changes: 43 additions & 0 deletions whatsApp/features/userStatus.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Created by arthurw at 8/18/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
And User Status must be 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
And Status must contain "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: Mute an User status
Given User is at Status screen
And There is at least one status on Status screen
When User selects a status from user "x"
And Selects settings option at top right corner
And Selects "mute" option
And Selects "confirm" option
Then 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..."