示例#1
0
    def test_edit_resource(self):
        """ Edit this resource successfully. """
        params = {
            'label': 'signup',
            'email': '*****@*****.**',
            'question': 'Cool.',
            'status': 'open',
        }

        issue = Issue(**params)
        issue.save()

        params_edit = {
            'label': 'other',
            'email': '*****@*****.**',
            'question': 'Cool.',
            'status': 'closed',
        }

        self.login()
        response = self.client.post(url_for('admin.issues_edit', id=issue.id),
                                    data=params_edit, follow_redirects=True)

        assert_status_with_message(200, response,
                                   _('Issue has been saved successfully.'))
    def test_logout(self):
        """ Logout successfully. """
        self.login()

        response = self.logout()
        assert_status_with_message(200, response,
                                   _('You have been logged out.'))
示例#3
0
    def test_subscription_billing_history_without_sub(self, mock_stripe):
        """ Subscription billing history without sub should still work. """
        self.login()
        response = self.client.get(url_for('billing.billing_history'))

        assert_status_with_message(200, response,
                                   'Billing details and history')
示例#4
0
    def test_subscription_billing_history(self, subscriptions, mock_stripe):
        """ Subscription billing history should render successfully. """
        self.login(identity='*****@*****.**')
        response = self.client.get(url_for('billing.billing_history'))

        assert_status_with_message(200, response,
                                   'Billing details and history')
    def test_logout(self):
        """ Logout successfully. """
        self.login()

        response = self.logout()
        assert_status_with_message(200, response,
                                   _('You have been logged out.'))
    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.')
    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.')
    def test_support_page_while_logged_in(self):
        """ Support page renders successfully with pre-populated e-mail. """
        self.login()
        response = self.client.get(url_for('issue.support'))

        assert_status_with_message(200, response,
                                   'value="*****@*****.**"')
示例#9
0
    def test_support_page_while_logged_in(self):
        """ Support page renders successfully with pre-populated e-mail. """
        self.login()
        response = self.client.get(url_for('issue.support'))

        assert_status_with_message(200, response,
                                   'value="*****@*****.**"')
示例#10
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')
示例#11
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, "You're moments away")
    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.')
    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.')
示例#14
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.'))
示例#15
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,
                                   "You're about to change plans")
    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.'))
    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.')
    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 %(email)s.',
                                     email='*****@*****.**'))
    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.')
示例#20
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.'))
示例#21
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.'))
示例#22
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'
                                     '.'))
示例#23
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'
                                     '.'))
    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.'))
    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.'))
    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'
    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 %(email)s.',
              email='*****@*****.**'))
    def test_support_invalid_label(self):
        """ Support issue fails due to an invalid label. """
        issue = {
            'label': 'notlegit',
            'email': '*****@*****.**',
            'question': 'Help!'
        }

        response = self.client.post(url_for('issue.support'), data=issue,
                                    follow_redirects=True)

        assert_status_with_message(200, response, 'Not a valid choice')
    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.')
    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.'))
    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'
示例#32
0
    def test_support_invalid_label(self):
        """ Support issue fails due to an invalid label. """
        issue = {
            'label': 'notlegit',
            'email': '*****@*****.**',
            'question': 'Help!'
        }

        response = self.client.post(url_for('issue.support'),
                                    data=issue,
                                    follow_redirects=True)

        assert_status_with_message(200, response, 'Not a valid choice')
    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, 'Already exists.')
    def test_begin_update_locale(self, users):
        """ Update the locale. """
        self.login()

        user = {'locale': 'es'}

        response = self.client.post(url_for('user.update_locale'),
                                    data=user,
                                    follow_redirects=True)

        assert_status_with_message(
            200, response, _('Your locale settings have been '
                             'updated.'))
    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.')
示例#36
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.'))
    def test_begin_update_locale(self, users):
        """ Update the locale. """
        self.login()

        user = {
            'locale': 'es'
        }

        response = self.client.post(url_for('user.update_locale'),
                                    data=user, follow_redirects=True)

        assert_status_with_message(200, response,
                                   _('Your locale settings have been '
                                     'updated.'))
示例#38
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 '
                                     '%(user)s', user='******'))
        assert user.cancelled_subscription_on is not None
    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.'))
示例#40
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.'))
示例#41
0
    def test_bulk_delete(self, coupons, mock_stripe):
        """ Resource gets bulk deleted. """
        params = {
            'bulk_ids': [1, 2, 3],
            'scope': 'all_search_results'
        }

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

        assert_status_with_message(200, response,
                                   _n('%(num)d coupon was scheduled to be '
                                      'deleted.',
                                      '%(num)d coupons were scheduled to be '
                                      'deleted.', num=3))
示例#42
0
    def test_support(self):
        """ Support issue gets saved. """
        old_issue_count = Issue.query.count()
        issue = {'label': 'login', 'email': '*****@*****.**', 'question': 'Help!'}

        response = self.client.post(url_for('issue.support'),
                                    data=issue,
                                    follow_redirects=True)

        assert_status_with_message(
            200, response,
            _('Help is on the way, expect a response '
              'shortly.'))

        new_issue_count = Issue.query.count()
        assert (old_issue_count + 1) == new_issue_count
    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'
    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'
    def test_support(self):
        """ Support issue gets saved. """
        old_issue_count = Issue.query.count()
        issue = {
            'label': 'login',
            'email': '*****@*****.**',
            'question': 'Help!'
        }

        response = self.client.post(url_for('issue.support'), data=issue,
                                    follow_redirects=True)

        assert_status_with_message(200, response,
                                   _('Help is on the way, expect a response '
                                     'shortly.'))

        new_issue_count = Issue.query.count()
        assert (old_issue_count + 1) == new_issue_count