Beispiel #1
0
    def test_subscription_billing_details(self, subscriptions, mock_stripe):
        """ Subscription billing history should render successfully. """
        self.login(identity='*****@*****.**')
        response = self.client.get(url_for('billing.billing_details'))

        assert_status_with_message(200, response,
                                   'Billing details and history')
Beispiel #2
0
    def test_subscription_billing_details_without_sub(self, mock_stripe):
        """ Subscription billing history without sub should still work. """
        self.login()
        response = self.client.get(url_for('billing.billing_details'))

        assert_status_with_message(200, response,
                                   'Billing details and history')
Beispiel #3
0
    def test_subscription_update_page_without_subscription(self):
        """ Subscription update page redirects to pricing page. """
        self.login()

        response = self.client.get(url_for('billing.update'),
                                   follow_redirects=True)

        assert_status_with_message(200, response, 'Ready to start winning?')
Beispiel #4
0
    def test_begin_signup_fail(self):
        """ Signup failure due to using an account that exists. """
        user = {'email': '*****@*****.**', 'password': '******'}
        response = self.client.post(url_for('user.signup'),
                                    data=user,
                                    follow_redirects=True)

        assert_status_with_message(200, response, 'Already exists.')
Beispiel #5
0
    def test_pricing_page_as_subscriber(self, subscriptions):
        """ Pricing page for subscribers should redirect to update. """
        self.login(identity='*****@*****.**')

        response = self.client.get(url_for('billing.pricing'),
                                   follow_redirects=True)

        assert_status_with_message(200, response, 'Change plan')
Beispiel #6
0
    def test_subscription_update_page(self, subscriptions):
        """ Subscription update page renders successfully. """
        self.login(identity='*****@*****.**')

        response = self.client.get(url_for('billing.update'),
                                   follow_redirects=True)

        assert_status_with_message(200, response, 'about to change plans')
Beispiel #7
0
    def test_begin_password_reset_fail(self):
        """ Begin reset failure due to using a non-existent account. """
        user = {'identity': '*****@*****.**'}
        response = self.client.post(url_for('user.begin_password_reset'),
                                    data=user,
                                    follow_redirects=True)

        assert_status_with_message(200, response, 'Unable to locate account.')
Beispiel #8
0
    def test_subscription_update_payment_method_without_card(self):
        """ Subscription update method without card should fail. """
        self.login()
        response = self.client.post(url_for('billing.update_payment_method'),
                                    data={},
                                    follow_redirects=True)

        assert_status_with_message(
            200, response, 'You do not have a payment method on file.')
Beispiel #9
0
    def test_subscription_cancel_page_without_subscription(self):
        """ Subscription cancel page redirects to settings. """
        self.login()

        response = self.client.get(url_for('billing.cancel'),
                                   follow_redirects=True)

        assert_status_with_message(200, response,
                                   'You do not have an active subscription.')
Beispiel #10
0
    def test_subscription_create_as_subscriber(self, subscriptions):
        """ Subscribers should not be allowed to create a subscription. """
        self.login(identity='*****@*****.**')

        response = self.client.get(url_for('billing.create'),
                                   follow_redirects=True)

        assert_status_with_message(200, response,
                                   'You already have an active subscription.')
Beispiel #11
0
    def test_begin_update_credentials_invalid_current(self):
        """ Update credentials failure due to invalid current password. """
        self.login()

        user = {'current_password': '******', 'email': '*****@*****.**'}
        response = self.client.post(url_for('user.update_credentials'),
                                    data=user,
                                    follow_redirects=True)

        assert_status_with_message(200, response, 'Does not match.')
Beispiel #12
0
    def test_begin_update_credentials_existing_email(self):
        """ Update credentials failure due to existing account w/ email. """
        self.login()

        user = {'current_password': '******', 'email': '*****@*****.**'}
        response = self.client.post(url_for('user.update_credentials'),
                                    data=user,
                                    follow_redirects=True)

        assert_status_with_message(200, response, 'Already exists.')
Beispiel #13
0
    def test_password_reset_invalid_token(self):
        """ Reset failure due to tampered reset token. """
        reset = {'password': '******', 'token': '123'}
        response = self.client.post(url_for('user.password_reset'),
                                    data=reset,
                                    follow_redirects=True)

        assert_status_with_message(
            200, response, 'Your reset token has expired or was '
            'tampered with.')
Beispiel #14
0
    def test_begin_password_reset(self):
        """ Begin password reset successfully. """
        user = {'identity': '*****@*****.**'}
        response = self.client.post(url_for('user.begin_password_reset'),
                                    data=user,
                                    follow_redirects=True)

        assert_status_with_message(
            200, response,
            'An email has been sent to {0}.'.format('*****@*****.**'))
Beispiel #15
0
    def test_welcome(self, users):
        """ Create username successfully. """
        self.login()

        user = {'username': '******'}
        response = self.client.post(url_for('user.welcome'),
                                    data=user,
                                    follow_redirects=True)

        assert_status_with_message(200, response,
                                   'Sign up is complete, enjoy our services.')
Beispiel #16
0
    def test_subscription_cancel(self, subscriptions, mock_stripe):
        """ Subscription cancel is successful. """
        self.login(identity='*****@*****.**')

        response = self.client.post(url_for('billing.cancel'),
                                    data={},
                                    follow_redirects=True)

        assert_status_with_message(
            200, response, 'Sorry to see you go, your subscription'
            ' has been cancelled.')
Beispiel #17
0
    def test_subscription_update_payment_method(self, subscriptions,
                                                mock_stripe):
        """ Subscription update payment requires JavaScript. """
        self.login(identity='*****@*****.**')
        response = self.client.post(url_for('billing.update_payment_method'),
                                    data={},
                                    follow_redirects=True)

        assert_status_with_message(
            200, response, 'You must enable JavaScript'
            ' for this request.')
Beispiel #18
0
    def test_edit_resource(self):
        """ Edit this resource successfully. """
        params = {'role': 'admin', 'username': '******', 'active': True}

        self.login()
        response = self.client.post(url_for('admin.users_edit', id=1),
                                    data=params,
                                    follow_redirects=True)

        assert_status_with_message(200, response,
                                   'User has been saved successfully.')
Beispiel #19
0
    def test_contact_form(self, client):
        """ Contact form should redirect with a message. """
        form = {
            'email': '*****@*****.**',
            'message': 'Test message from Snake Eyes.'
        }

        response = client.post(url_for('contact.index'),
                               data=form,
                               follow_redirects=True)
        assert_status_with_message(200, response, 'Thanks')
Beispiel #20
0
    def test_password_reset(self, users, token):
        """ Reset successful. """
        reset = {'password': '******', 'reset_token': token}
        response = self.client.post(url_for('user.password_reset'),
                                    data=reset,
                                    follow_redirects=True)

        assert_status_with_message(200, response,
                                   'Your password has been reset.')

        admin = User.find_by_identity('*****@*****.**')
        assert admin.password != 'newpassword'
Beispiel #21
0
    def test_bulk_delete(self, coupons, mock_stripe):
        """ Resource gets bulk deleted. """
        params = {'bulk_ids': [1, 2, 3], 'scope': 'all_selected_items'}

        self.login()
        response = self.client.post(url_for('admin.coupons_bulk_delete'),
                                    data=params,
                                    follow_redirects=True)

        assert_status_with_message(
            200, response, '{0} coupons(s)'
            ' were scheduled to be deleted.'.format(3))
Beispiel #22
0
    def test_cancel_subscription(self, subscriptions, mock_stripe):
        """ User subscription gets cancelled. """
        user = User.find_by_identity('*****@*****.**')
        params = {'id': user.id}

        self.login()
        response = self.client.post(url_for('admin.users_cancel_subscription'),
                                    data=params,
                                    follow_redirects=True)

        assert_status_with_message(
            200, response, 'Subscription has been cancelled for Subby')
        assert user.cancelled_subscription_on is not None
Beispiel #23
0
    def test_bulk_delete_nothing(self):
        """ Last admin account should not get deleted. """
        old_count = User.query.count()
        params = {'bulk_ids': [1], 'scope': 'all_selected_items'}

        self.login()
        response = self.client.post(url_for('admin.users_bulk_delete'),
                                    data=params,
                                    follow_redirects=True)

        assert_status_with_message(200, response,
                                   '0 user(s) were scheduled to be deleted.')

        new_count = User.query.count()
        assert old_count == new_count
Beispiel #24
0
    def test_welcome_with_existing_username(self, users):
        """ Create username failure due to username already existing. """
        self.login()

        u = User.find_by_identity('*****@*****.**')
        u.username = '******'
        u.save()

        user = {'username': '******'}
        response = self.client.post(url_for('user.welcome'),
                                    data=user,
                                    follow_redirects=True)

        assert_status_with_message(200, response,
                                   'You already picked a username.')
Beispiel #25
0
    def test_subscription_create(self, users, mock_stripe):
        """ Subscription create requires JavaScript. """
        self.login()

        params = {
            'stripe_key': 'cus_000',
            'plan': 'gold',
            'name': 'Foobar Johnson'
        }

        response = self.client.post(url_for('billing.create'),
                                    data=params,
                                    follow_redirects=True)

        assert_status_with_message(
            200, response, 'You must enable JavaScript'
            ' for this request.')
Beispiel #26
0
    def test_begin_update_credentials_email_change(self):
        """ Update credentials but only the e-mail address. """
        self.login()

        user = {'current_password': '******', 'email': '*****@*****.**'}
        response = self.client.post(url_for('user.update_credentials'),
                                    data=user,
                                    follow_redirects=True)

        assert_status_with_message(200, response,
                                   'Your sign in settings have been updated.')

        old_user = User.find_by_identity('*****@*****.**')
        assert old_user is None

        new_user = User.find_by_identity('*****@*****.**')
        assert new_user is not None
Beispiel #27
0
    def test_signup(self, users):
        """ Signup successfully. """
        old_user_count = User.query.count()

        user = {'email': '*****@*****.**', 'password': '******'}
        response = self.client.post(url_for('user.signup'),
                                    data=user,
                                    follow_redirects=True)

        assert_status_with_message(200, response,
                                   'Awesome, thanks for signing up!')

        new_user_count = User.query.count()
        assert (old_user_count + 1) == new_user_count

        new_user = User.find_by_identity('*****@*****.**')
        assert new_user.password != 'password'
Beispiel #28
0
    def test_new_resource(self, mock_stripe):
        """ Edit this resource successfully. """
        params = {
            'code': '1337',
            'duration': 'repeating',
            'percent_off': 5,
            'amount_off': None,
            'currency': 'usd',
            'redeem_by': None,
            'max_redemptions': 10,
            'duration_in_months': 5,
        }

        self.login()
        response = self.client.post(url_for('admin.coupons_new'),
                                    data=params,
                                    follow_redirects=True)

        assert_status_with_message(200, response,
                                   'Coupon has been created successfully.')
Beispiel #29
0
    def test_404_page(self, client):
        """ 404 errors should show the custom 404 page. """
        response = client.get('/nochancethispagewilleverexistintheapp')

        assert_status_with_message(404, response, 'Error 404')
Beispiel #30
0
    def test_logout(self):
        """ Logout successfully. """
        self.login()

        response = self.logout()
        assert_status_with_message(200, response, 'You have been logged out.')