Skip to content

Commit

Permalink
Subscription tests works
Browse files Browse the repository at this point in the history
  • Loading branch information
BerglundDaniel committed Dec 15, 2023
1 parent 35eef54 commit cfd1ebb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions api/src/shop/test/subscriptions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def setUpClass(self) -> None:
name="test subscriptions access",
price=350.0,
unit="mån",
smallest_multiple=1,
smallest_multiple=2, # TODO need to test with multiple values
category_id=subscription_category.id,
product_metadata={
MakerspaceMetadataKeys.ALLOWED_PRICE_LEVELS.value: ["low_income_discount"],
Expand Down Expand Up @@ -160,7 +160,7 @@ def setUp(self) -> None:
self.seen_event_ids = set()
self.earliest_possible_event_time = datetime.now(timezone.utc)
self.clocks_to_destroy: List[FakeClock] = []
stripe_setup.set_stripe_key(True)
# stripe_setup.set_stripe_key(True)

disable_loggers = ["stripe"]

Expand Down Expand Up @@ -489,14 +489,15 @@ def test_subscriptions_member_deleted(self) -> None:

self.advance_clock(clock, now + time_delta(days=4))

membership.views.member_entity.delete(member, commit=True)
membership.views.member_entity.delete(member.member_id, commit=True)

self.advance_clock(clock, now + time_delta(days=6))
self.advance_clock(clock, now + time_delta(days=10))

assert member.deleted_at is not None
assert stripe.Customer.retrieve(stripe_customer_id).deleted

# TODO fix this test to work with new stripe setup and no binding period
def test_subscriptions_binding_period(self) -> None:
"""
Checks that a lab subscription is started with a binding period
Expand All @@ -508,7 +509,7 @@ def test_subscriptions_binding_period(self) -> None:
(now, clock, member) = self.setup_single_member()

stripe_subscriptions.start_subscription(
member.member_id,
member,
SubscriptionType.LAB,
earliest_start_at=now,
test_clock=clock.stripe_clock,
Expand Down Expand Up @@ -538,7 +539,7 @@ def test_subscriptions_resubscribe(self) -> None:
"""
Checks that a subscription can be cancelled, and the member can resubscribe immediately
"""
binding_period = BINDING_PERIOD[SubscriptionType.LAB]
binding_period = 2 # TODO fix this, split into two tests
if binding_period <= 0:
pytest.skip("No binding period for lab access")

Expand Down Expand Up @@ -696,7 +697,7 @@ def test_subscriptions_signed_agreement_immediate(self) -> None:
db_session.commit()
# Ship any orders related to the member. We exclude all other members
# because that might mess up other tests running in parallel.
ship_orders(True, current_time=clock.date, member_id=member)
ship_orders(True, current_time=clock.date, member_id=member.member_id)
sub_start = clock.date.date()

self.advance_clock(clock, noon(sub_start + time_delta(days=5)))
Expand Down

0 comments on commit cfd1ebb

Please sign in to comment.