Skip to content

Commit

Permalink
improve price test
Browse files Browse the repository at this point in the history
  • Loading branch information
hhartwell committed Jan 11, 2024
1 parent 919c664 commit b0a187f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ckc/stripe/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ class Meta:
'unit_amount',
'currency',
'recurring',
'nickname',
)
read_only_fields = (
'id',
'unit_amount',
'currency',
'recurring',
'nickname',
)


Expand Down
2 changes: 1 addition & 1 deletion ckc/stripe/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from djstripe.models import PaymentMethod, Price, Plan, Customer
from djstripe.models import PaymentMethod, Price, Customer
from rest_framework import viewsets, mixins
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated, AllowAny
Expand Down
11 changes: 9 additions & 2 deletions tests/integration/test_payment_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import stripe
from django.urls import reverse
from djstripe.models import PaymentMethod, Customer
from djstripe.models import PaymentMethod, Customer, Price
from djstripe.sync import sync_subscriber
# from djstripe.core import Price
from rest_framework.test import APITestCase
Expand Down Expand Up @@ -117,9 +117,16 @@ def test_subscriptions(self):

def test_subscription_plan_list(self):
for i in range(3):
create_price(2000 + i, "month", product_name=f"Sample Product Name: {i}", currency="usd")
prod_name = f"Sample Product Name: {i}"
create_price(2000 + i, "month", product_name=prod_name, nickname=prod_name, currency="usd")

url = reverse('prices-list')
resp = self.client.get(url)
assert resp.status_code == 200
assert len(resp.data) == 3
from pprint import pprint
pprint(resp.data)

for i in range(3):
assert resp.data[i]['unit_amount'] / 100 == 2000 + i
assert resp.data[i]['nickname'] == f"Sample Product Name: {i}"

0 comments on commit b0a187f

Please sign in to comment.