def test_empty_user_add_product_to_cart_success(self):
"""빈 장바구니에 제품 추가, 제품 점수"""
# valid 제품 1개 추가
product_param = {
"user": self.user,
"brand": self.brand,
"product_status": self.product_status_6
}
sample_product = create_sample_product(**product_param)
payload = {"product_id": sample_product.id}
res = self.client.post(CART_CREATE_URL, payload)
num_of_cart = models.Cart.objects.filter(user=self.user).count()
product_point = sample_product.hit
self.assertEqual(res.status_code, 201)
self.assertEqual(res.data, None)
self.assertEqual(num_of_cart, 1)
self.assertEqual(product_point, 4)
결과
def test_empty_user_add_product_to_cart_success(self):
"""빈 장바구니에 제품 추가, 제품 점수"""
# valid 제품 1개 추가
product_param = {
"user": self.user,
"brand": self.brand,
"product_status": self.product_status_6
}
sample_product = create_sample_product(**product_param)
payload = {"product_id": sample_product.id}
res = self.client.post(CART_CREATE_URL, payload)
sample_product.refresh_from_db()
num_of_cart = models.Cart.objects.filter(user=self.user).count()
product_point = sample_product.hit
self.assertEqual(res.status_code, 201)
self.assertEqual(res.data, None)
self.assertEqual(num_of_cart, 1)
self.assertEqual(product_point, 4)