Skip to content

Commit

Permalink
clean stripe
Browse files Browse the repository at this point in the history
  • Loading branch information
mstur committed May 14, 2021
1 parent 04c24e6 commit c1b06f1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions main-webserver/tests/payment/test_stripe_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,20 @@


@pytest.mark.usefixtures("authorized")
def test_expired_subscription(client):
"""Handle expired subscription."""

def test_active_subscription(client):
"""Handle active subscription."""
# create test subscription
customer = stripe.Customer.create(
description="Test Customer",
)

stripe.Customer.create_source(customer["id"], source="tok_visa")

product = stripe.Product.create(name="Test Subscription")

price = stripe.Price.create(
unit_amount=50,
currency="usd",
recurring={"interval": "month"},
product=product["id"],
)

subscription = stripe.Subscription.create(
customer=customer["id"],
items=[
Expand All @@ -35,9 +31,16 @@ def test_expired_subscription(client):
trial_end="now",
)

# verify endpoint works
resp = client.post(
"/stripe/can_access_product",
json=dict(stripe_id=customer["id"]),
)

# delete test subscription
stripe.Subscription.delete(subscription["id"])
stripe.Price.modify(price["id"], active="False")
stripe.Product.modify(product["id"], active="False")
stripe.Customer.delete(customer["id"])

assert resp.json["subscribed"]

0 comments on commit c1b06f1

Please sign in to comment.