def test_page_user_form_initial(self): myuser = User.objects.create_superuser("myuser", "*****@*****.**", "myuser") user = create_page_user(myuser, myuser, grant_all=True) puf = PageUserForm(instance=user) names = ['can_add_page', 'can_change_page', 'can_delete_page', 'can_add_pageuser', 'can_change_pageuser', 'can_delete_pageuser', 'can_add_pagepermission', 'can_change_pagepermission', 'can_delete_pagepermission'] for name in names: self.assertTrue(puf.initial.get(name, False))
def test_09_page_user_form_initial(self): user = self.create_page_user('myuser', 'myuser', grant_all=True) puf = PageUserForm(instance=user) names = [ 'can_add_page', 'can_change_page', 'can_delete_page', 'can_add_pageuser', 'can_change_pageuser', 'can_delete_pageuser', 'can_add_pagepermission', 'can_change_pagepermission', 'can_delete_pagepermission' ] for name in names: self.assertTrue(puf.initial.get(name, False))
def test_user_forms(self): user = self.get_superuser() user2 = self._create_user("randomuser", is_staff=True, add_default_permissions=True) set_current_user(user) data = {'username': "******", 'password': '******', 'password1': 'hello', 'password2': 'hello', 'created_by': user.pk, 'last_login': datetime.now(), 'date_joined': datetime.now(), 'email': '*****@*****.**', } form = PageUserForm(data=data, files=None) self.assertTrue(form.is_valid(), form.errors) form.save() data = {'username': "******", 'password': '******', 'password1': 'hello', 'password2': 'hello', 'email': '*****@*****.**', 'created_by': user.pk, 'last_login': datetime.now(), 'date_joined': datetime.now(), 'notify_user': '******', } form = PageUserForm(data=data, files=None, instance=user2) self.assertTrue(form.is_valid(), form.errors) form.save() data = { 'name': 'test_group' } form = PageUserGroupForm(data=data, files=None) self.assertTrue(form.is_valid(), form.errors) instance = form.save() form = PageUserGroupForm(data=data, files=None, instance=instance) self.assertTrue(form.is_valid(), form.errors) form.save()
def test_user_forms(self): user = self.get_superuser() user2 = self._create_user("randomuser", is_staff=True, add_default_permissions=True) set_current_user(user) data = { "username": "******", "password": "******", "password1": "hello", "password2": "hello", "created_by": user.pk, "last_login": datetime.now(), "date_joined": datetime.now(), "email": "*****@*****.**", } form = PageUserForm(data=data, files=None) self.assertTrue(form.is_valid(), form.errors) form.save() data = { "username": "******", "password": "******", "password1": "hello", "password2": "hello", "email": "*****@*****.**", "created_by": user.pk, "last_login": datetime.now(), "date_joined": datetime.now(), "notify_user": "******", } form = PageUserForm(data=data, files=None, instance=user2) self.assertTrue(form.is_valid(), form.errors) form.save() data = {"name": "test_group"} form = PageUserGroupForm(data=data, files=None) self.assertTrue(form.is_valid(), form.errors) instance = form.save() form = PageUserGroupForm(data=data, files=None, instance=instance) self.assertTrue(form.is_valid(), form.errors) form.save()