Exemplo n.º 1
0
 def test_user_form_view(self):
     """Test editing user profile data through form in isolation"""
     LOGGER.debug("Test user edit form")
     form = UserForm(instance=self.user1)
     form_html = form.as_p()
     LOGGER.debug(form_html)
     self.assertInHTML('<input id="id_username" maxlength="30" name="username" type="text" value="user1" />', form_html)
     self.assertInHTML('<input id="id_first_name" maxlength="30" name="first_name" type="text" />', form_html)
     self.assertInHTML('<input id="id_email" maxlength="254" name="email" type="email" value="*****@*****.**" />', form_html)
     self.assertInHTML('<input id="id_last_name" maxlength="30" name="last_name" type="text" />', form_html)
     self.assertNotIn('<input id="id_is_staff" name="is_staff" type="checkbox" />', form_html)
     self.assertNotIn('<input checked="checked" id="id_is_active" name="is_active" type="checkbox" />', form_html)
Exemplo n.º 2
0
 def test_user_form_update(self):
     LOGGER.debug("Test user form create")
     data = {
         'username': '******',
         'first_name': 'user',
         'last_name': 'Two',
         'last_login': '******',
         'date_joined': '2012-09-04 06:00',
         'manually_edited': False
     }
     form = UserForm(data, instance=self.user1)
     self.assertTrue(form.is_valid())
     form.save()
     self.assertEquals(self.user1.last_name, 'Two')
Exemplo n.º 3
0
 def test_user_form_update(self):
     LOGGER.debug("Test user form create")
     data = {
         'username': '******',
         'first_name': 'user',
         'last_name': 'Two',
         'last_login': '******',
         'date_joined': '2012-09-04 06:00',
         'manually_edited': False
     }
     form = UserForm(data, instance=self.user1)
     self.assertTrue(form.is_valid())
     form.save()
     self.assertEquals(self.user1.last_name, 'Two')
Exemplo n.º 4
0
 def test_user_form_create(self):
     LOGGER.debug("Test user form create")
     data = {
         'username': '******',
         'password': '******',
         'email': '*****@*****.**',
         'first_name': 'user',
         'last_name': '2',
         'last_login': '******',
         'date_joined': '2012-09-04 06:00',
         'manually_edited': False
     }
     form = UserForm(data)
     self.assertTrue(form.is_valid())
     form.save()
     user2 = User.objects.get(username='******')
     self.assertEquals(user2.username, 'user2')
Exemplo n.º 5
0
 def test_user_form_create(self):
     LOGGER.debug("Test user form create")
     data = {
         'username': '******',
         'password': '******',
         'email': '*****@*****.**',
         'first_name': 'user',
         'last_name': '2',
         'last_login': '******',
         'date_joined': '2012-09-04 06:00',
         'manually_edited': False
     }
     form = UserForm(data)
     self.assertTrue(form.is_valid())
     form.save()
     user2 = User.objects.get(username='******')
     self.assertEquals(user2.username, 'user2')
Exemplo n.º 6
0
 def test_user_form_dupe_username(self):
     LOGGER.debug("Test user form update")
     data = {
         'username': '******',
         'password': '******',
         'email': '*****@*****.**',
         'first_name': 'user',
         'last_name': '2',
         'last_login': '******',
         'date_joined': '2012-09-04 06:00',
         'manually_edited': False
     }
     form = UserForm(data)
     self.assertIn('already exists', form.errors['username'][0])
Exemplo n.º 7
0
 def test_user_form_view(self):
     """Test editing user profile data through form in isolation"""
     LOGGER.debug("Test user edit form")
     form = UserForm(instance=self.user1)
     form_html = form.as_p()
     LOGGER.debug(form_html)
     self.assertInHTML(
         '<input id="id_username" maxlength="30" name="username" type="text" value="user1" />',
         form_html)
     self.assertInHTML(
         '<input id="id_first_name" maxlength="30" name="first_name" type="text" />',
         form_html)
     self.assertInHTML(
         '<input id="id_email" maxlength="254" name="email" type="email" value="*****@*****.**" />',
         form_html)
     self.assertInHTML(
         '<input id="id_last_name" maxlength="30" name="last_name" type="text" />',
         form_html)
     self.assertNotIn(
         '<input id="id_is_staff" name="is_staff" type="checkbox" />',
         form_html)
     self.assertNotIn(
         '<input checked="checked" id="id_is_active" name="is_active" type="checkbox" />',
         form_html)