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


Python Service.set_default_user方法代码示例

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


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

示例1: ServicesViewsTest

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import set_default_user [as 别名]
class ServicesViewsTest(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.set_default_user()
        self.contact.save()

        self.status = TicketStatus(name='TestStatus')
        self.status.set_default_user()
        self.status.save()

        self.queue = TicketQueue(
            name='TestQueue', default_ticket_status=self.status)
        self.queue.set_default_user()
        self.queue.save()

        self.ticket = Ticket(
            name='TestTicket', status=self.status, queue=self.queue)
        self.ticket.set_default_user()
        self.ticket.save()

        self.agent = ServiceAgent(related_user=self.user.profile, available_from=datetime.time(9),
                                  available_to=datetime.time(17))
        self.agent.set_default_user()
        self.agent.save()

        self.service = Service(name='test')
        self.service.set_default_user()
        self.service.save()

        self.sla = ServiceLevelAgreement(name='test', service=self.service,
                                         client=self.contact, provider=self.contact)
        self.sla.set_default_user()
        self.sla.save()

    ######################################
    # Testing views when user is logged in
    ######################################
    def test_index_login(self):
        "Test index page with login at /services/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('services'))
        self.assertEquals(response.status_code, 200)

    def test_index_owned(self):
        "Test index page with login at /services/owned"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('services_index_owned'))
        self.assertEquals(response.status_code, 200)

    def test_index_assigned(self):
        "Test index page with login at /services/assigned"

        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('services_index_assigned'))
        self.assertEquals(response.status_code, 200)

    # Queues
    def test_queue_add(self):
        "Test page with login at /services/queue/add"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('services_queue_add'))
        self.assertEquals(response.status_code, 200)

    def test_queue_view(self):
        "Test page with login at /services/queue/view/<queue_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('services_queue_view', args=[self.queue.id]))
        self.assertEquals(response.status_code, 200)

    def test_queue_edit(self):
        "Test page with login at /services/queue/edit/<queue_id>"
        response = self.client.post('/accounts/login',
#.........这里部分代码省略.........
开发者ID:tovmeod,项目名称:anaf,代码行数:103,代码来源:tests.py


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