def setUp(self): new_user = User( name="Sharoon Thomas", email="*****@*****.**", ) new_user.set_password("openlabs") new_user.save()
def test_0070_registration_post_3(self): """ Test registration with an email which already exists, with require_activation = True """ options.options.require_activation = True user = User(name="Test User", email="*****@*****.**") user.set_password("password") user.save() with nested( patch.object(smtplib.SMTP, 'sendmail'), patch.object(smtplib.SMTP, 'quit'), ) as (mock_sendmail, mock_quit): response = self.fetch( '/registration', method="POST", follow_redirects=False, body=urlencode({'name':'anoop', 'email':'*****@*****.**', 'password':'******', 'confirm_password':'******'} ) ) self.assertEqual(mock_sendmail.call_count, 0) self.assertEqual(mock_quit.call_count, 0) self.assertEqual(response.code, 200) self.assertEqual( response.body.count( u'This email is already registered.' ), 1 )
def test_0030_login_post_2(self): """ Test login with a user which already exists """ user = User(name="Test User", email="*****@*****.**") user.set_password("password") user.save() response = self.fetch( '/login', method="POST", follow_redirects=False, body=urlencode({ 'email': '*****@*****.**', 'password': '******' }) ) self.assertEqual(response.code, 302)
def test_0130_account_activation_1(self): """ Test activation of account with true activationkey """ user = User(name="Test User", email="*****@*****.**") user.set_password("password") user.save() signer = URLSafeSerializer(self.get_app().settings['cookie_secret']) activation_key = signer.dumps(user.email) response = self.fetch( '/activation/%s' % activation_key, method="GET", follow_redirects=False, ) self.assertEqual(response.code, 302)
def test_0060_registration_post_2(self): """ Test registration with an user which already exists """ user = User(name="Test User", email="*****@*****.**") user.set_password("password") user.save() response = self.fetch( '/registration', method="POST", follow_redirects=False, body=urlencode({'name':'anoop', 'email':'*****@*****.**', 'password':'******', 'confirm_password':'******'} ) ) self.assertEqual(response.code, 200) self.assertEqual( response.body.count(u'This email is already registered.'), 1 )
def test_0120_activationkey_resend_post_2(self): """ Test resend with a user which already exists """ user = User(name="Test User", email="*****@*****.**") user.set_password("password") user.save() with nested( patch.object(smtplib.SMTP, 'sendmail'), patch.object(smtplib.SMTP, 'quit'), ) as (mock_sendmail, mock_quit): response = self.fetch( '/activation_resend', method="POST", follow_redirects=False, body=urlencode({'email':'*****@*****.**'}) ) self.assertEqual(mock_sendmail.call_count, 1) self.assertEqual(mock_quit.call_count, 1) self.assertEqual(response.code, 302)