feat: wishlist view
This commit is contained in:
@@ -38,10 +38,12 @@ class TestWishlist(TestCase, CreateProductsMixin):
|
||||
reverse("web:add_to_wishlist"),
|
||||
{
|
||||
"product": self.product.pk,
|
||||
}
|
||||
},
|
||||
)
|
||||
assert response.status_code == 201
|
||||
assert WishlistedProduct.objects.filter(user=self.user, product=self.product).exists()
|
||||
assert WishlistedProduct.objects.filter(
|
||||
user=self.user, product=self.product
|
||||
).exists()
|
||||
|
||||
def test_logged_user_delete_wishlisted_product(self):
|
||||
wishlisted = WishlistedProduct.objects.create(
|
||||
@@ -53,4 +55,27 @@ class TestWishlist(TestCase, CreateProductsMixin):
|
||||
reverse("web:delete_from_wishlist", kwargs={"pk": wishlisted.pk})
|
||||
)
|
||||
assert response.status_code == 204
|
||||
assert not WishlistedProduct.objects.filter(user=self.user, product=self.product).exists()
|
||||
assert not WishlistedProduct.objects.filter(
|
||||
user=self.user, product=self.product
|
||||
).exists()
|
||||
|
||||
def test_logged_user_wishlist(self):
|
||||
WishlistedProduct.objects.create(
|
||||
user=self.user,
|
||||
product=self.product,
|
||||
)
|
||||
self.client.force_login(self.user)
|
||||
response = self.client.get(
|
||||
reverse("web:wishlist")
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
def test_not_logged_user_wishlist(self):
|
||||
WishlistedProduct.objects.create(
|
||||
user=self.user,
|
||||
product=self.product,
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("web:wishlist")
|
||||
)
|
||||
assert response.status_code == 302
|
||||
|
||||
Reference in New Issue
Block a user