-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
56 lines (37 loc) · 1.67 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import pytest
from carts.models import CartLine
pytestmark = pytest.mark.django_db
def test_returns_empty_cart(client):
response = client.get("/cart/")
assert response.status_code == 200
assert response.json() == {"lines": []}
def test_returns_cart_with_one_product(client):
CartLine.objects.create(reference="50776", quantity=5)
response = client.get("/cart/")
assert response.status_code == 200
assert response.json() == {"lines": [{"reference": "50776", "quantity": 5}]}
def test_adds_product_to_cart_when_product_not_in_cart(client):
# Arrange (?)
# Act (post a quantity to any reference)
# Assert (check status_code and response of the new cart state)
pass
def test_adds_product_units_to_existing_product_in_cart(client):
CartLine.objects.create(reference="50776", quantity=5)
# Act (post a quantity to the 50776 reference)
# Assert (check status_code and response of the new cart state)
pass
def test_substracts_quantity(client):
CartLine.objects.create(reference="50776", quantity=5)
# Act (post a quantity substraction to the 50776 reference)
# Assert (check status_code and response of the new cart state)
pass
def test_removes_product_when_substracting_greater_quantity_than_the_carts_has(client):
CartLine.objects.create(reference="50776", quantity=5)
# Act (substract more than 5 units to the 50776 reference)
# Assert (check status_code and response of the new cart state)
pass
def test_does_nothing_when_product_does_not_exists(client):
# Arrange (?)
# Act (substract any quantity to any reference)
# Assert (check status_code and response of the new cart state)
pass