Skip to content

Commit

Permalink
Basic test for the create_with_products endpoint
Browse files Browse the repository at this point in the history
needs some additional tests, but need to switch gears for a bit
  • Loading branch information
jkachel committed Jan 10, 2025
1 parent 88b7e15 commit 36a9d47
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions payments/views/v0/v0_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""View tests for the v0 API."""

import pytest

from payments.factories import ProductFactory
from payments.models import Basket
from system_meta.factories import ActiveIntegratedSystemFactory

pytestmark = pytest.mark.django_db


def test_create_basket_with_products(mocker, user_client):
"""Test creating a basket with products."""

mocker.patch("payments.api.send_pre_sale_webhook")
system = ActiveIntegratedSystemFactory()
products = ProductFactory.create_batch(size=2, system=system)

url = "/api/v0/payments/baskets/create_with_products/"
response = user_client.post(
url,
data={
"system_slug": system.slug,
"skus": [{"sku": product.sku, "quantity": 1} for product in products],
},
)
assert response.status_code in (
200,
201,
)

basket_id = response.data["id"]
assert Basket.objects.get(id=basket_id).basket_items.count() == 2

0 comments on commit 36a9d47

Please sign in to comment.