8
8
@pytest .mark .django_db
9
9
class TestCarItemUpdateView :
10
10
@pytest .fixture (autouse = True )
11
- def setup (self , api_client , available_food_product , user ):
11
+ def setup (self , api_client , available_food_product , user , cart ):
12
12
self .url = reverse ("carts:update-delete" , kwargs = {"product_uuid" : available_food_product .uuid })
13
13
self .client = api_client
14
+ self .cart = cart
14
15
self .user = user
15
16
self .product = available_food_product
16
17
@@ -20,12 +21,7 @@ def test_update_unauthorized_fails(self):
20
21
21
22
def test_update_with_maximum_quantity_fails (self ):
22
23
self .client .force_authenticate (user = self .user )
23
- CartService .add_item (self .user , self .product , 1 )
24
- response = self .client .put (
25
- self .url ,
26
- data = {"quantity" : 20 },
27
- format = "json" ,
28
- )
24
+ response = self .client .put (self .url , data = {"quantity" : 20 }, format = "json" )
29
25
assert response .status_code == status .HTTP_400_BAD_REQUEST
30
26
assert response .data ["error" ] == "Maximum quantity exceeded"
31
27
@@ -43,7 +39,6 @@ def test_update_with_product_not_in_cart_fails(self, available_drink_product):
43
39
44
40
def test_update_item (self ):
45
41
self .client .force_authenticate (user = self .user )
46
- CartService .add_item (self .user , self .product , 1 )
47
42
response = self .client .put (self .url , data = {"quantity" : 2 }, format = "json" )
48
43
assert response .status_code == status .HTTP_200_OK
49
44
assert response .data ["quantity" ] == 2
0 commit comments