class RequestTest(TestCase): def setUp(self): self.factory = RequestFactory() self.client = Client() def test_successful_signup(self): # TODO pass def create_user(self): self.user_test = User() self.user_test.username = "******" self.user_test.email = "*****@*****.**" self.user_test.set_password("1234colab") self.user_test.save() def test_invalid_user_profile_url(self): response = self.client.get('/account/johndoe/') self.assertEqual(404, response.status_code) def test_valid_user_profile_url(self): self.create_user() response = self.client.get('/account/usertest/') self.assertEqual(200, response.status_code) def test_valid_login_url(self): response = self.client.get('/account/login') self.assertEqual(200, response.status_code) def test_myaccount_redirect_not_authenticated_user(self): self.create_user() response = self.client.get('/myaccount/edit') self.assertEqual(404, response.status_code) def test_myaccount_redirect_user_profile(self): self.create_user() self.client.login(username="******", password='******') response = self.client.get('/myaccount/') self.assertEqual(302, response.status_code) self.assertEqual("http://testserver/account/usertest/", response.url) def test_myaccount_redirect_edit(self): self.create_user() self.client.login(username="******", password='******') response = self.client.get('/myaccount/edit') self.assertEqual(302, response.status_code) self.assertEqual("http://testserver/account/usertest/edit", response.url) def test_myaccount_redirect_subscriptions(self): self.create_user() self.client.login(username="******", password='******') response = self.client.get('/myaccount/subscriptions') self.assertEqual(302, response.status_code) self.assertEqual("http://testserver/account/usertest/subscriptions", response.url)
def create_user(self): user = User() user.username = "******" user.set_password("123colab4") user.email = "*****@*****.**" user.id = 1 user.first_name = "USERtestCoLaB" user.last_name = "COLAB" user.save() return user
def create_user(self, name='samplename', email='*****@*****.**', is_active=True): user = User() user.username = name user.email = email user.is_active = is_active user.save()
class SocialNetworkTest(TestCase): """docstring for SocialNetworkTest""" def setUp(self): self.factory = RequestFactory() self.client = Client() def create_user(self): self.user_test = User() self.user_test.username = "******" self.user_test.email = "*****@*****.**" self.user_test.set_password("1234colab") self.user_test.save() def test_social_network(self): self.create_user() self.client.login(username="******", password='******') response = self.client.get('/myaccount/') result = social_network_enabled(response)['SOCIAL_NETWORK_ENABLED'] self.assertTrue(result) self.assertTrue(settings.SOCIAL_NETWORK_ENABLED)
def setUp(self): user = User() user.username = "******" user.set_password("123colab4") user.email = "*****@*****.**" user.id = 1 user.twitter = "usertestcolab" user.facebook = "usertestcolab" user.first_name = "USERtestCoLaB" user.last_name = "COLAB" user.save()
def create_user(self): user = User() user.username = "******" user.set_password("123colab4") user.email = "*****@*****.**" user.id = 1 user.twitter = "usertest" user.facebook = "usertest" user.first_name = "usertest" user.last_name = "COLAB" user.save() return user
def create_user(self): self.user_test = User() self.user_test.username = "******" self.user_test.email = "*****@*****.**" self.user_test.set_password("1234colab") self.user_test.save()
def create_user(context, username, password, status): user = User() user.username = username user.set_password(password) user.email = "*****@*****.**" user.id = 1 user.first_name = "USERtestCoLaB" user.last_name = "COLAB" user.needs_update = False if status == "active": user.is_active = True else: user.is_active = False user.save()