示例#1
0
    def test_activate_account(self):
        # Create the account, which is initially inactive
        activation_key = account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)
        account = account_api.account_info(self.USERNAME)
        self.assertEqual(account, {
            'username': self.USERNAME,
            'email': self.EMAIL,
            'is_active': False
        })

        # Activate the account and verify that it is now active
        account_api.activate_account(activation_key)
        account = account_api.account_info(self.USERNAME)
        self.assertTrue(account['is_active'])
    def test_activate_account(self):
        # Create the account, which is initially inactive
        activation_key = account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)
        account = account_api.account_info(self.USERNAME)
        self.assertEqual(account, {
            'username': self.USERNAME,
            'email': self.EMAIL,
            'is_active': False
        })

        # Activate the account and verify that it is now active
        account_api.activate_account(activation_key)
        account = account_api.account_info(self.USERNAME)
        self.assertTrue(account['is_active'])
示例#3
0
    def test_change_email(self):
        # Request an email change
        account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)
        activation_key = account_api.request_email_change(
            self.USERNAME, u"*****@*****.**", self.PASSWORD)

        # Verify that the email has not yet changed
        account = account_api.account_info(self.USERNAME)
        self.assertEqual(account['email'], self.EMAIL)

        # Confirm the change, using the activation code
        old_email, new_email = account_api.confirm_email_change(activation_key)
        self.assertEqual(old_email, self.EMAIL)
        self.assertEqual(new_email, u"*****@*****.**")

        # Verify that the email is changed
        account = account_api.account_info(self.USERNAME)
        self.assertEqual(account['email'], u"*****@*****.**")
    def test_change_email(self):
        # Request an email change
        account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)
        activation_key = account_api.request_email_change(
            self.USERNAME, u"*****@*****.**", self.PASSWORD
        )

        # Verify that the email has not yet changed
        account = account_api.account_info(self.USERNAME)
        self.assertEqual(account['email'], self.EMAIL)

        # Confirm the change, using the activation code
        old_email, new_email = account_api.confirm_email_change(activation_key)
        self.assertEqual(old_email, self.EMAIL)
        self.assertEqual(new_email, u"*****@*****.**")

        # Verify that the email is changed
        account = account_api.account_info(self.USERNAME)
        self.assertEqual(account['email'], u"*****@*****.**")
    def test_confirm_email_already_exists(self):
        account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)

        # Request a change
        activation_key = account_api.request_email_change(
            self.USERNAME, u"*****@*****.**", self.PASSWORD
        )

        # Another use takes the email before we confirm the change
        account_api.create_account(u"other_user", u"password", u"*****@*****.**")

        # When we try to confirm our change, we get an error because the email is taken
        with self.assertRaises(account_api.AccountEmailAlreadyExists):
            account_api.confirm_email_change(activation_key)

        # Verify that the email was NOT changed
        self.assertEqual(account_api.account_info(self.USERNAME)['email'], self.EMAIL)
示例#6
0
    def test_confirm_email_already_exists(self):
        account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)

        # Request a change
        activation_key = account_api.request_email_change(
            self.USERNAME, u'*****@*****.**', self.PASSWORD
        )

        # Another use takes the email before we confirm the change
        account_api.create_account(u'other_user', u'password', u'*****@*****.**')

        # When we try to confirm our change, we get an error because the email is taken
        with self.assertRaises(account_api.AccountEmailAlreadyExists):
            account_api.confirm_email_change(activation_key)

        # Verify that the email was NOT changed
        self.assertEqual(account_api.account_info(self.USERNAME)['email'], self.EMAIL)
 def test_account_info_no_user(self):
     self.assertIs(account_api.account_info("does_not_exist"), None)
示例#8
0
 def test_account_info_no_user(self):
     self.assertIs(account_api.account_info('does_not_exist'), None)