本文整理汇总了Python中models.Folder.set_default_user方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.set_default_user方法的具体用法?Python Folder.set_default_user怎么用?Python Folder.set_default_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Folder
的用法示例。
在下文中一共展示了Folder.set_default_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DocumentsViewsTest
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import set_default_user [as 别名]
class DocumentsViewsTest(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.folder = Folder(name='test')
self.folder.set_default_user()
self.folder.save()
self.document = Document(title='test_document', folder=self.folder)
self.document.set_default_user()
self.document.save()
self.file = File(name='test_file', folder=self.folder)
self.file.set_default_user()
self.file.save()
self.link = WebLink(title='test', folder=self.folder, url='test')
self.link.set_default_user()
self.link.save()
######################################
# Testing views when user is logged in
######################################
def test_index_login(self):
"Test index page with login at /documents/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('document_index'))
self.assertEquals(response.status_code, 200)
def test_index_documents_login(self):
"Test index page with login at /documents/documents/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('index_documents'))
self.assertEquals(response.status_code, 200)
def test_index_files_login(self):
"Test index page with login at /documents/files/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('index_files'))
self.assertEquals(response.status_code, 200)
def test_index_weblinks_login(self):
"Test index page with login at /documents/weblinks/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('index_weblinks'))
self.assertEquals(response.status_code, 200)
# Folders
def test_folder_add(self):
"Test index page with login at /documents/folder/add/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('documents_folder_add'))
self.assertEquals(response.status_code, 200)
# form
self.assertEqual(Folder.objects.count(), 1)
post_data = {'name': 'test'}
response = self.client.post(reverse('documents_folder_add'), post_data)
self.assertEquals(response.status_code, 302) # redirect somewhere
self.assertEquals(Folder.objects.count(), 2)
def test_folder_view_login(self):
"Test index page with login at /documents/folder/view/<folder_id>"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(
reverse('documents_folder_view', args=[self.folder.id]))
self.assertEquals(response.status_code, 200)
def test_folder_edit_login(self):
"Test index page with login at /documents/folder/edit/<folder_id>"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(
reverse('documents_folder_edit', args=[self.folder.id]))
self.assertEquals(response.status_code, 200)
#.........这里部分代码省略.........