Created
January 4, 2021 21:12
-
-
Save klement97/6a7743b0ceaa885f4312504358315a92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.mark.django_db | |
def test_pizza_price_with_toppings(): | |
# Preparation phase | |
pizza = create_pizza(number_of_toppings=2) | |
# Calculating results | |
actual_price = pizza.total_price | |
expected_price = sum([t.price for t in pizza.toppings.all()]) | |
# Assertion | |
assert actual_price == expected_price | |
@pytest.mark.django_db | |
def test_pizza_price_without_toppings(): | |
# Preparation phase | |
pizza = create_pizza(number_of_toppings=0) | |
# Calculating results | |
actual_price = pizza.total_price | |
expected_price = Decimal(0) | |
# Assertion | |
assert actual_price == expected_price |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment