本文整理汇总了Python中models.Item.set_default_user方法的典型用法代码示例。如果您正苦于以下问题:Python Item.set_default_user方法的具体用法?Python Item.set_default_user怎么用?Python Item.set_default_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Item
的用法示例。
在下文中一共展示了Item.set_default_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InfrastructureViewsTest
# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import set_default_user [as 别名]
class InfrastructureViewsTest(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.type = ItemType(name='test')
self.type.set_default_user()
self.type.save()
self.status = ItemStatus(name='test')
self.status.set_default_user()
self.status.save()
self.field = ItemField(
name='test', label='test', field_type='text')
self.field.set_default_user()
self.field.save()
self.item = Item(
name='test', item_type=self.type, status=self.status)
self.item.set_default_user()
self.item.save()
self.value = ItemValue(field=self.field, item=self.item)
self.value.save()
self.servicing = ItemServicing(name='test')
self.servicing.set_default_user()
self.servicing.save()
######################################
# Testing views when user is logged in
######################################
def test_index_login(self):
"Test index page with login at /infrastructure/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('infrastructure'))
self.assertEquals(response.status_code, 200)
def test_index_infrastructure_login(self):
"Test index page with login at /infrastructure/index/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('infrastructure_index'))
self.assertEquals(response.status_code, 200)
def test_infrastructure_index_owned(self):
"Test index page with login at /infrastructure/owned/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('infrastructure_index_owned'))
self.assertEquals(response.status_code, 200)
# Type
def test_infrastructure_type_add(self):
"Test index page with login at /infrastructure/type/add/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('infrastructure_type_add'))
self.assertEquals(response.status_code, 200)
def test_infrastructure_type_view(self):
"Test index page with login at /infrastructure/type/view/<type_id>"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(
reverse('infrastructure_type_view', args=[self.type.id]))
self.assertEquals(response.status_code, 200)
def test_infrastructure_type_edit(self):
"Test index page with login at /infrastructure/type/edit/<type_id>"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(
reverse('infrastructure_type_edit', args=[self.type.id]))
self.assertEquals(response.status_code, 200)
def test_infrastructure_type_delete(self):
"Test index page with login at /infrastructure/type/delete/<type_id>"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(
reverse('infrastructure_type_delete', args=[self.type.id]))
#.........这里部分代码省略.........