示例#1
0
async def _():
    user = PastaportoUserInfo(id=1, email="*****@*****.**", is_staff=False)
    subscription = Subscription(id=1,
                                user_id=user.id,
                                status=SubscriptionStatus.CANCELED)
    payment = Payment(
        total=1000,
        subscription=subscription,
        idempotency_key="iv_abcabc",
        status=PaymentStatus.PAID,
        payment_date=datetime.now(timezone.utc),
        period_start=datetime.now(timezone.utc) + timedelta(days=0),
        period_end=datetime.now(timezone.utc) + timedelta(days=30),
    )
    StripeSubscriptionPayment(
        payment=payment,
        stripe_subscription_id="sub_abcabc",
        stripe_invoice_id="iv_abcabc",
        invoice_pdf="https://stripe.com/pdf/xxx",
    )

    checkout_session_id = await subscribe_user_to_association(
        user,
        association_repository=FakeAssociationMembershipRepository(
            [subscription]),
    )
    assert checkout_session_id == "cs_xxx"
示例#2
0
async def _():
    user = PastaportoUserInfo(id=1, email="*****@*****.**", is_staff=False)
    fake_repository = FakeAssociationMembershipRepository([], [])

    with raises(CustomerNotAvailable):
        await manage_user_association_subscription(
            user, association_repository=fake_repository)
示例#3
0
async def _():
    user = PastaportoUserInfo(id=1, email="*****@*****.**", is_staff=False)
    subscription = Subscription(id=1,
                                user_id=user.id,
                                status=SubscriptionStatus.CANCELED)
    payment = Payment(
        id=1,
        total=1000,
        idempotency_key="iv_abcabc",
        subscription=subscription,
        status=PaymentStatus.PAID,
        payment_date=datetime.now(timezone.utc),
        period_start=datetime.now(timezone.utc) + timedelta(days=0),
        period_end=datetime.now(timezone.utc) + timedelta(days=30),
    )
    StripeSubscriptionPayment(
        id=1,
        payment=payment,
        stripe_subscription_id="sub_abcabc",
        stripe_invoice_id="iv_abcabc",
        invoice_pdf="https://stripe.com/pdf/xxx",
    )
    stripe_customer = StripeCustomer(id=1,
                                     user_id=user.id,
                                     stripe_customer_id="cus_123")

    fake_repository = FakeAssociationMembershipRepository([subscription],
                                                          [stripe_customer])

    with raises(NoSubscriptionAvailable):
        await manage_user_association_subscription(
            user, association_repository=fake_repository)
示例#4
0
async def _():
    user = PastaportoUserInfo(id=1, email="*****@*****.**", is_staff=False)
    subscription = Subscription(id=1,
                                user_id=user.id,
                                status=SubscriptionStatus.ACTIVE)
    payment = Payment(
        id=1,
        total=1000,
        idempotency_key="iv_abcabc",
        subscription=subscription,
        status=PaymentStatus.PAID,
        payment_date=datetime.now(timezone.utc),
        period_start=datetime.now(timezone.utc) + timedelta(days=0),
        period_end=datetime.now(timezone.utc) + timedelta(days=30),
    )
    PretixPayment(
        id=1,
        payment=payment,
        order_code="ABC",
        event_organizer="local-test",
        event_id="pycon-demo",
    )

    fake_repository = FakeAssociationMembershipRepository([subscription], [])

    with raises(NotSubscribedViaStripe):
        await manage_user_association_subscription(
            user, association_repository=fake_repository)
示例#5
0
def _get_pastaporto(user) -> Pastaporto:
    return Pastaporto(
        PastaportoUserInfo.from_data({
            "id": user.id,
            "email": user.email,
            "isStaff": user.is_staff
        }))
示例#6
0
async def _():
    user = PastaportoUserInfo(id=1, email="*****@*****.**", is_staff=False)

    checkout_session_id = await subscribe_user_to_association(
        user,
        association_repository=FakeAssociationMembershipRepository(),
    )
    assert checkout_session_id == "cs_xxx"