Ejemplo n.º 1
0
 def testLoginUser(self):
     """
     Tests login with registered username
     """
     BeatMyGoalUser.create('user1', '*****@*****.**', 'pw')
     response = BeatMyGoalUser.login('user1', 'pw')
     self.assertTrue(not response['errors'])
Ejemplo n.º 2
0
class EditUserTests(TestCase):
    def setUp(self):
        self.testUser = BeatMyGoalUser(username="******", password="******", email="*****@*****.**")
        self.testUser.save()
        self.testUser1 = BeatMyGoalUser(username="******", password="******", email="*****@*****.**")
        self.testUser1.save()

    def testEditUsername(self):
        BeatMyGoalUser.updateUser(user=self.testUser, username="******")
        self.assertEqual(self.testUser.username, "newUsername")

    def testEditEmail(self):
        BeatMyGoalUser.updateUser(user=self.testUser, email="*****@*****.**")
        self.assertEqual(self.testUser.email, "*****@*****.**")

    def testUsernameTaken(self):
        BeatMyGoalUser.updateUser(user=self.testUser, username="******")
        self.assertEqual(self.testUser.username, "test")

    def testEmailTaken(self):
        BeatMyGoalUser.updateUser(user=self.testUser, email="*****@*****.**")
        self.assertEqual(self.testUser.email, "*****@*****.**")

    def testUserIsAuthenticated(self):
        pass
Ejemplo n.º 3
0
 def testLoginInvalidPassword(self):
     """
     Tests login with wrong password
     """
     BeatMyGoalUser.create('user1', '*****@*****.**', 'pw')
     response = BeatMyGoalUser.login('user1','pww')
     self.assertTrue(response['errors'])
Ejemplo n.º 4
0
 def testCreateDuplicateEmail(self):
     """
     Tests that creating account with already existing email works
     """
     response1 = BeatMyGoalUser.create('user1', '*****@*****.**', 'pw')
     self.assertTrue(not response1['errors'])
     response2 = BeatMyGoalUser.create('user2', '*****@*****.**', 'pw')
     self.assertTrue(response2['errors'])
     self.assertFalse(CODE_DUPLICATE_USERNAME in response2['errors'])
     self.assertTrue(CODE_DUPLICATE_EMAIL in response2['errors'])
Ejemplo n.º 5
0
 def testRemoveUser(self):
     """
     test delete method in models
     """
     response = BeatMyGoalUser.create('test_user_view','test_email_view','test_password_view')
     test_user = response['user']
     test_user_userid = test_user.id
     response1 = BeatMyGoalUser.remove(test_user_userid)
     self.assertTrue(not response1['errors'])
     response2 = BeatMyGoalUser.getUserById(test_user_userid)
     self.assertTrue(response2['errors'])
Ejemplo n.º 6
0
 def testGetUserbyId(self):
     """
     test getUserById method in models
     """
     responce = BeatMyGoalUser.create('test_user_view','test_email_view','test_password_view')
     test_user = responce['user']
     test_user_userid = test_user.id
     test_user_username = test_user.username
     test_user_email = test_user.email
     response = BeatMyGoalUser.getUserById(test_user_userid)
     self.assertTrue(not response['errors'])
     user = response['user']
     self.assertEqual(test_user_userid,user.id)
     self.assertEqual(test_user_username,user.username)
     self.assertEqual(test_user_email,user.email)
Ejemplo n.º 7
0
 def testCreateUser(self):
     """
     Tests that creating new user works
     """
     response = BeatMyGoalUser.create('user1', '*****@*****.**', 'pw')
     self.assertTrue(not response['errors'])
     userid = BeatMyGoalUser.objects.get(username = '******')
     self.assertEqual('*****@*****.**', userid.email)
Ejemplo n.º 8
0
 def testRemoveUserWrong(self):
     """
     test delete method in models
     """
     response = BeatMyGoalUser.remove(-99)
     self.assertTrue(response['errors'])
Ejemplo n.º 9
0
 def testEmailTaken(self):
     BeatMyGoalUser.updateUser(user=self.testUser, email="*****@*****.**")
     self.assertEqual(self.testUser.email, "*****@*****.**")
Ejemplo n.º 10
0
 def setUp(self):
     self.testUser = BeatMyGoalUser(username="******", password="******", email="*****@*****.**")
     self.testUser.save()
     self.testUser1 = BeatMyGoalUser(username="******", password="******", email="*****@*****.**")
     self.testUser1.save()
Ejemplo n.º 11
0
 def testLoginInvalidUser(self):
     """
     Tests login with unregistered username
     """
     response = BeatMyGoalUser.login('user1','pw')
     self.assertTrue(response['errors'])
Ejemplo n.º 12
0
 def testCreateEmptyEmail(self):
     """
     Tests that creating account with empty email
     """
     response = BeatMyGoalUser.create('user1', '', 'pw')
     self.assertTrue(response['errors'])
Ejemplo n.º 13
0
 def testCreateEmptyPassword(self):
     """
     Tests that creating account with empty password
     """
     response = BeatMyGoalUser.create('user1', '*****@*****.**', '')
     self.assertTrue(response['errors'])
Ejemplo n.º 14
0
 def testCreateEmptyUsername(self):
     """
     Tests that creating account with empty username
     """
     response = BeatMyGoalUser.create('', '*****@*****.**', 'pw')
     self.assertTrue(response['errors'])
Ejemplo n.º 15
0
 def testEditUsername(self):
     BeatMyGoalUser.updateUser(user=self.testUser, username="******")
     self.assertEqual(self.testUser.username, "newUsername")
Ejemplo n.º 16
0
 def testGetUserbyNameWrong(self):
     """
     test getUserByName method in models
     """
     response = BeatMyGoalUser.getUserByName("")
     self.assertTrue(response['errors'])
Ejemplo n.º 17
0
 def testUsernameTaken(self):
     BeatMyGoalUser.updateUser(user=self.testUser, username="******")
     self.assertEqual(self.testUser.username, "test")
Ejemplo n.º 18
0
 def testEditEmail(self):
     BeatMyGoalUser.updateUser(user=self.testUser, email="*****@*****.**")
     self.assertEqual(self.testUser.email, "*****@*****.**")