Exemple #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
Exemple #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
Exemple #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"))
Exemple #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")
Exemple #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())
Exemple #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())
Exemple #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())
Exemple #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
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')
Exemple #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'))
Exemple #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())