def test_username_unique(self):
        """ Tests for: uniqueness """

        params = self.valid_params.copy()
        params['username'] = '******'

        # This should be valid, as 'abcdef' should be unique
        form = RegistrationForm(params)
        self.assertTrue(form.is_valid())
        form.create_user()

        # Try again and it should throw a validation error
        form = RegistrationForm(params)
        self.assertFalse(form.is_valid())

        self.assertEqual(len(form.errors), 1)
        self.assertIn('username', form.errors)
        self.assertItemsEqual(form.errors['username'], ['Username \'%s\' is already in use. Please choose another one.' % (params['username'])])
Exemple #2
0
    def test_username_unique(self):
        """ Tests for: uniqueness """

        params = self.valid_params.copy()
        params['username'] = '******'

        # This should be valid, as 'abcdef' should be unique
        form = RegistrationForm(params)
        self.assertTrue(form.is_valid())
        form.create_user()

        # Try again and it should throw a validation error
        form = RegistrationForm(params)
        self.assertFalse(form.is_valid())

        self.assertEqual(len(form.errors), 1)
        self.assertIn('username', form.errors)
        self.assertItemsEqual(form.errors['username'], [
            'Username \'%s\' is already in use. Please choose another one.' %
            (params['username'])
        ])
Exemple #3
0
    def test_create_advisor_profile(self):
        """ Tests that an advisor profile for a user and a school is successfully created upon registration """
        params = self.valid_params.copy()
        params["Username"] = "******"
        params["SchoolName"] = "advisor_profile_test"
        form = RegistrationForm(params)
        self.assertTrue(form.is_valid())

        user = form.create_user()
        school = form.create_school()

        profile = form.create_advisor_profile(user, school)
        self.assertFalse(profile is None)

        self.assertEqual(profile.user, user)
        self.assertEqual(profile.school, school)
    def test_create_user(self):
        """ Tests parameters and db insertion """

        params = self.valid_params.copy()
        params['username'] = '******'
        form = RegistrationForm(params)

        self.assertTrue(form.is_valid())
        user = form.create_user()

        # Check return value
        self.assertEqual(user.username, params['username'])
        self.assertEqual(user.first_name, params['first_name'])
        self.assertEqual(user.last_name, params['last_name'])

        # Check to see that it's in the database as well
        self.assertTrue(HuxleyUser.objects.filter(id=user.id).exists())
Exemple #5
0
    def test_create_user(self):
        """ Tests parameters and db insertion """

        params = self.valid_params.copy()
        params['username'] = '******'
        form = RegistrationForm(params)

        self.assertTrue(form.is_valid())
        user = form.create_user()

        # Check return value
        self.assertEqual(user.username, params['username'])
        self.assertEqual(user.first_name, params['first_name'])
        self.assertEqual(user.last_name, params['last_name'])

        # Check to see that it's in the database as well
        self.assertTrue(HuxleyUser.objects.filter(id=user.id).exists())
Exemple #6
0
    def test_create_user(self):
        """ Tests parameters and db insertion """

        params = self.valid_params.copy()
        params["Username"] = "******"
        form = RegistrationForm(params)

        self.assertTrue(form.is_valid())
        user = form.create_user()

        # Check return value
        self.assertEqual(user.username, params["Username"])
        self.assertEqual(user.first_name, params["FirstName"])
        self.assertEqual(user.last_name, params["LastName"])

        # Check to see that it's in the database as well
        users_in_db = User.objects.filter(username=params["Username"])
        self.assertGreater(len(users_in_db), 0)
        self.assertEqual(users_in_db[0], user)