本文整理汇总了Python中models.Contact.set_default_user方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.set_default_user方法的具体用法?Python Contact.set_default_user怎么用?Python Contact.set_default_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Contact
的用法示例。
在下文中一共展示了Contact.set_default_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IdentitiesViewsTest
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import set_default_user [as 别名]
class IdentitiesViewsTest(TestCase):
username = "test"
password = "password"
def setUp(self):
self.group, created = Group.objects.get_or_create(name='test')
self.user, created = DjangoUser.objects.get_or_create(username=self.username)
self.user.set_password(self.password)
self.user.save()
perspective, created = Perspective.objects.get_or_create(
name='default')
perspective.set_default_user()
perspective.save()
ModuleSetting.set('default_perspective', perspective.id)
self.contact_type = ContactType(name='Person')
self.contact_type.set_default_user()
self.contact_type.save()
self.contact = Contact(name='Test', contact_type=self.contact_type)
self.contact.set_default_user()
self.contact.save()
self.field = ContactField(
name='Test', label='test', field_type='text')
self.field.set_default_user()
self.field.save()
######################################
# Testing views when user is logged in
######################################
def test_index_login(self):
"Test index page with login at /contacts/"
response = self.client.post('/accounts/login', {'username': self.username,
'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('identities_index'))
self.assertEquals(response.status_code, 200)
def test_contact_users_login(self):
"Test page with login at /contacts/users/"
response = self.client.post('/accounts/login', {'username': self.username,
'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('identities_index_users'))
self.assertEquals(response.status_code, 200)
def test_contact_groups_login(self):
"Test page with login at /contacts/groups/"
response = self.client.post('/accounts/login', {'username': self.username,
'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('identities_index_groups'))
self.assertEquals(response.status_code, 200)
# Contact types
def test_contact_type_add(self):
"Test page with login at /contacts/types/add/"
response = self.client.post('/accounts/login', {'username': self.username,
'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('identities_type_add'))
self.assertEquals(response.status_code, 200)
def test_contact_type_view(self):
"Test page with login at /contacts/type/view/(?P<type_id>\d+)"
response = self.client.post('/accounts/login', {'username': self.username,
'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(
reverse('identities_type_view', args=[self.contact_type.id]))
self.assertEquals(response.status_code, 200)
def test_contact_type_edit(self):
"Test page with login at /contacts/type/edit/(?P<type_id>\d+)"
response = self.client.post('/accounts/login', {'username': self.username,
'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(
reverse('identities_type_edit', args=[self.contact_type.id]))
self.assertEquals(response.status_code, 200)
def test_contact_type_delete(self):
"Test page with login at /contacts/type/delete/(?P<type_id>\d+)"
response = self.client.post('/accounts/login', {'username': self.username,
'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(
reverse('identities_type_delete', args=[self.contact_type.id]))
self.assertEquals(response.status_code, 200)
# Contact fields
def test_contact_field_add(self):
"Test page with login at /contacts/field/add"
response = self.client.post('/accounts/login', {'username': self.username,
'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('identities_field_add'))
self.assertEquals(response.status_code, 200)
#.........这里部分代码省略.........