コード例 #1
0
    def _get_active_membership(self):
        """Get the currently active membership for the account."""
        acct_repository = AccountRepository(self.db)
        active_membership = acct_repository.get_active_account_membership(
            self.account.id)

        return active_membership
コード例 #2
0
    def _get_active_membership(self):
        acct_repository = AccountRepository(self.db)
        active_membership = acct_repository.get_active_account_membership(
            self.account.id
        )

        return active_membership
コード例 #3
0
def yearly_account(context):
    """Check that the yearly membership information for an account is accurate."""
    acct_repository = AccountRepository(context.db)
    membership = acct_repository.get_active_account_membership(
        context.accounts["foo"].id)
    assert_that(membership.type, equal_to(YEARLY_MEMBERSHIP))
    assert_that(membership.payment_account_id, starts_with("cus"))
コード例 #4
0
def account_deleted(context):
    """Ensure account no longer exists in database."""
    acct_repository = AccountRepository(context.db)
    membership = acct_repository.get_active_account_membership(
        context.accounts["foo"].id)
    context.accounts["foo"].membership = membership
    context.response = context.client.delete("/api/account")
コード例 #5
0
def validate_absence_of_membership(context):
    """Check for the absence of a membership on an account."""
    acct_repository = AccountRepository(context.db)
    membership = acct_repository.get_active_account_membership(
        context.accounts["foo"].id
    )
    assert_that(membership, none())
コード例 #6
0
def validate_monthly_account(context):
    acct_repository = AccountRepository(context.db)
    membership = acct_repository.get_active_account_membership(
        context.accounts['foo'].id)
    assert_that(membership.type, equal_to(MONTHLY_MEMBERSHIP))
    assert_that(membership.payment_account_id, starts_with('cus'))
    assert_that(membership.start_date, equal_to(date.today()))
    assert_that(membership.end_date, none())
コード例 #7
0
def validate_monthly_account(context):
    """Check that the monthly membership information for an account is accurate."""
    acct_repository = AccountRepository(context.db)
    membership = acct_repository.get_active_account_membership(
        context.accounts["foo"].id)
    assert_that(membership.type, equal_to(MONTHLY_MEMBERSHIP))
    assert_that(membership.payment_account_id, starts_with("cus"))
    assert_that(membership.start_date, equal_to(datetime.utcnow().date()))
    assert_that(membership.end_date, none())
コード例 #8
0
def add_membership_to_account(context):
    """Use the API to add a monthly membership on Stripe

    The API is used so that the Stripe API can be interacted with.
    """
    context.username = "******"
    context.access_token = generate_access_token(context)
    set_access_token_cookie(context)
    context.refresh_token = generate_refresh_token(context)
    set_refresh_token_cookie(context)
    _add_membership_via_api(context)
    acct_repository = AccountRepository(context.db)
    membership = acct_repository.get_active_account_membership(
        context.accounts["foo"].id)
    context.accounts["foo"].membership = membership
コード例 #9
0
def account_deleted(context):
    acct_repository = AccountRepository(context.db)
    membership = acct_repository.get_active_account_membership(
        context.accounts['foo'].id)
    context.accounts['foo'].membership = membership
    context.response = context.client.delete('/api/account')
コード例 #10
0
def yearly_account(context):
    acct_repository = AccountRepository(context.db)
    membership = acct_repository.get_active_account_membership(
        context.accounts['foo'].id)
    assert_that(membership.type, equal_to(YEARLY_MEMBERSHIP))
    assert_that(membership.payment_account_id, starts_with('cus'))
コード例 #11
0
def validate_absence_of_membership(context):
    acct_repository = AccountRepository(context.db)
    membership = acct_repository.get_active_account_membership(
        context.accounts['foo'].id)
    assert_that(membership, none())