当前位置: 首页>>代码示例>>Python>>正文


Python Task.set_default_user方法代码示例

本文整理汇总了Python中models.Task.set_default_user方法的典型用法代码示例。如果您正苦于以下问题:Python Task.set_default_user方法的具体用法?Python Task.set_default_user怎么用?Python Task.set_default_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Task的用法示例。


在下文中一共展示了Task.set_default_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ProjectsViewsTest

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import set_default_user [as 别名]
class ProjectsViewsTest(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='test')
        self.contact_type.set_default_user()
        self.contact_type.save()

        self.contact = Contact(name='test', contact_type=self.contact_type)
        self.contact.related_user = self.user.profile
        self.contact.set_default_user()
        self.contact.save()

        self.project = Project(name='test', manager=self.contact, client=self.contact)
        self.project.set_default_user()
        self.project.save()

        self.status = TaskStatus(name='test')
        self.status.set_default_user()
        self.status.save()

        self.milestone = Milestone(name='test', project=self.project, status=self.status)
        self.milestone.set_default_user()
        self.milestone.save()

        self.task = Task(name='test', project=self.project, status=self.status, caller=self.contact)
        self.task.set_default_user()
        self.task.save()

        self.task_assigned = Task(name='test', project=self.project, status=self.status)
        self.task_assigned.save()
        self.task_assigned.assigned.add(self.user.profile)

        self.time_slot = TaskTimeSlot(task=self.task, details='test', time_from=datetime.now(), user=self.user.profile)
        self.time_slot.set_default_user()
        self.time_slot.save()

        self.parent = Project(name='test')
        self.parent.set_default_user()
        self.parent.save()

        self.parent_task = Task(
            name='test', project=self.project, status=self.status, priority=3)
        self.parent_task.set_default_user()
        self.parent_task.save()

        self.client = Client()

        self.client.login(username=self.username, password=self.password)

    def test_index(self):
        """Test project index page with login at /projects/"""
        response = self.client.get(reverse('projects'))
        self.assertEquals(response.status_code, 200)

    def assertQuerysetEqual(self, qs, values, transform=repr, ordered=True, msg=None):
        return super(ProjectsViewsTest, self).assertQuerysetEqual(qs, map(repr, values), transform, ordered, msg)

    def test_index_owned(self):
        """Test owned tasks page at /task/owned/"""
        response = self.client.get(reverse('projects_index_owned'))
        self.assertEquals(response.status_code, 200)
        self.assertQuerysetEqual(response.context['milestones'], [self.milestone])
        self.assertQuerysetEqual(response.context['tasks'], [self.task])
        self.assertEqual(type(response.context['filters']), FilterForm)
        # todo: actually test the form generated, if it has the right fields and querysets
        # self.assertEqual(str(response.context['filters']), str(filterform))

    def test_index_assigned(self):
        """Test assigned tasks page at /task/assigned/"""
        response = self.client.get(reverse('projects_index_assigned'))
        self.assertEquals(response.status_code, 200)
        self.assertQuerysetEqual(response.context['milestones'], [self.milestone])
        self.assertQuerysetEqual(response.context['tasks'], [self.task_assigned])
        self.assertEqual(type(response.context['filters']), FilterForm)

    # Projects
    def test_project_add(self):
        """Test index page with login at /projects/add/"""
        response = self.client.get(reverse('project_add'))
        self.assertEquals(response.status_code, 200)
        self.assertEqual(type(response.context['form']), ProjectForm)

        projects_qty = Project.objects.count()
        form_params = {'name': 'project_name', 'details': 'new project details'}
        response = self.client.post(reverse('project_add'), data=form_params)
        self.assertEquals(response.status_code, 302)
        project_id = response['Location'].split('/')[-1]
        self.assertRedirects(response, reverse('projects_project_view', args=[project_id]))
#.........这里部分代码省略.........
开发者ID:tovmeod,项目名称:anaf,代码行数:103,代码来源:tests.py


注:本文中的models.Task.set_default_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。