aboutsummaryrefslogtreecommitdiffstats
path: root/pyblackbird_cc/payments
diff options
context:
space:
mode:
Diffstat (limited to 'pyblackbird_cc/payments')
-rw-r--r--pyblackbird_cc/payments/tests/test_models.py8
-rw-r--r--pyblackbird_cc/payments/views.py9
2 files changed, 11 insertions, 6 deletions
diff --git a/pyblackbird_cc/payments/tests/test_models.py b/pyblackbird_cc/payments/tests/test_models.py
index 467d6e4..65e7484 100644
--- a/pyblackbird_cc/payments/tests/test_models.py
+++ b/pyblackbird_cc/payments/tests/test_models.py
@@ -29,10 +29,10 @@ def test_subscription_user_unique():
# Create a new user
user_data = {"email": "testuser@example.com", "password": "testpassword123"}
- user = User.objects.create_user(**user_data)
+ user = User.objects.create_user(**user_data) # type: ignore
# Create a subscription for the user
- subscription = Subscription.objects.create(user=user, plan=free_plan)
+ Subscription.objects.create(user=user, plan=free_plan)
# Try to create another subscription for the same user
with pytest.raises(IntegrityError):
@@ -50,13 +50,13 @@ def test_user_signup_assigns_free_subscription(user_data):
"allowed_downloads": 10,
},
) # Create a new user
- user = User.objects.create_user(**user_data)
+ user = User.objects.create_user(**user_data) # type: ignore
# Manually trigger the user_signed_up signal
request = RequestFactory().get("/")
user_signed_up.send(sender=user.__class__, request=request, user=user)
# Check if a SubscriptionPlan was created for the user
- subscription = Subscription.objects.filter(user=user).first()
+ subscription = user.subscription
assert subscription is not None
# Check if the assigned plan is the free plan
diff --git a/pyblackbird_cc/payments/views.py b/pyblackbird_cc/payments/views.py
index 2e53af8..d02a2ab 100644
--- a/pyblackbird_cc/payments/views.py
+++ b/pyblackbird_cc/payments/views.py
@@ -2,12 +2,17 @@ import stripe
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404
-from django.shortcuts import render, redirect
+from django.shortcuts import redirect
+from django.shortcuts import render
from django.views import View
from django.views.generic import TemplateView
from pyblackbird_cc.resources.models import Resource
-from .models import ShoppingCart, CartItem, Price, Product
+
+from .models import CartItem
+from .models import Price
+from .models import Product
+from .models import ShoppingCart
stripe.api_key = settings.STRIPE_SECRET_KEY