本文整理汇总了Python中models.Report.set_default_user方法的典型用法代码示例。如果您正苦于以下问题:Python Report.set_default_user方法的具体用法?Python Report.set_default_user怎么用?Python Report.set_default_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Report
的用法示例。
在下文中一共展示了Report.set_default_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ReportsViewsTest
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import set_default_user [as 别名]
class ReportsViewsTest(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.report = Report(name='test')
self.report.set_default_user()
self.report.save()
self.chart = Chart(name='test_chart', report=self.report)
self.chart.set_default_user()
self.chart.save()
######################################
# Testing views when user is logged in
######################################
def test_reports_login(self):
"""Testing /reports/"""
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('reports'))
self.assertEquals(response.status_code, 200)
def test_index_login(self):
"Testing /reports/index/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('reports_index'))
self.assertEquals(response.status_code, 200)
def test_index_owned(self):
"Testing /reports/owned/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('reports_index'))
self.assertEquals(response.status_code, 200)
# Charts
def test_chart_add(self):
"Testing /reports/chart/add/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('reports_chart_add'))
self.assertEquals(response.status_code, 200)
def test_chart_delete_login(self):
"Testing /reports/chart/delete/<chart_id>"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(
reverse('reports_chart_delete', args=[self.chart.id]))
self.assertEquals(response.status_code, 200)
# Reports
def test_report_add(self):
"Testing /reports/report/add/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(reverse('reports_report_add'))
self.assertEquals(response.status_code, 200)
def test_report_delete_login(self):
"Testing /reports/report/delete/<report_id>"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password})
self.assertRedirects(response, '/')
response = self.client.get(
reverse('reports_report_delete', args=[self.report.id]))
self.assertEquals(response.status_code, 200)
######################################
# Testing views when user is not logged in
######################################
def test_reports_out(self):
"Testing /reports/"
response = self.client.get(reverse('reports'))
self.assertRedirects(response, reverse('user_login'))
def test_index_out(self):
"Testing /reports/index/"
response = self.client.get(reverse('reports_index'))
self.assertRedirects(response, reverse('user_login'))
def test_index_owned_out(self):
"Testing /reports/owned/"
#.........这里部分代码省略.........