Skip to content

Commit

Permalink
server/checkout: add product and product_price to Checkout private sc…
Browse files Browse the repository at this point in the history
…hema
  • Loading branch information
frankie567 committed Oct 25, 2024
1 parent 6f5e856 commit a0922b3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/polar/checkout/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ class CheckoutBase(IDSchema, TimestampedSchema):
class Checkout(MetadataOutputMixin, CheckoutBase):
"""Checkout session data retrieved using an access token."""

product: Product
product_price: ProductPrice


class CheckoutPublic(CheckoutBase):
"""Checkout session data retrieved using the client secret."""
Expand Down
35 changes: 35 additions & 0 deletions server/tests/checkout/test_endpoints.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import uuid
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock

Expand Down Expand Up @@ -41,6 +42,40 @@ async def checkout_open(
return await create_checkout(save_fixture, price=product_one_time.prices[0])


@pytest.mark.asyncio
@pytest.mark.skip_db_asserts
class TestGet:
async def test_anonymous(
self, client: AsyncClient, checkout_open: Checkout
) -> None:
response = await client.get(f"{API_PREFIX}/{checkout_open.id}")

assert response.status_code == 401

@pytest.mark.auth(AuthSubjectFixture(scopes={Scope.checkouts_read}))
async def test_not_existing(self, client: AsyncClient) -> None:
response = await client.get(f"{API_PREFIX}/{uuid.uuid4()}")

assert response.status_code == 404

@pytest.mark.auth(AuthSubjectFixture(scopes={Scope.checkouts_read}))
async def test_valid(
self,
client: AsyncClient,
checkout_open: Checkout,
user_organization: UserOrganization,
) -> None:
response = await client.get(f"{API_PREFIX}/{checkout_open.id}")

assert response.status_code == 200

json = response.json()
assert json["id"] == str(checkout_open.id)
assert "metadata" in json
assert "product" in json
assert "product_price" in json


@pytest.mark.asyncio
@pytest.mark.skip_db_asserts
class TestCreateCheckout:
Expand Down

0 comments on commit a0922b3

Please sign in to comment.