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


Python Message.set_default_user方法代码示例

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


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

示例1: MessagingViewsTest

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

        self.message = Message(
            title='test', body='test', author=self.contact, stream=self.stream)
        self.message.set_default_user()
        self.message.save()

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

    def test_message_index_sent(self):
        "Test index page with login at /messaging/sent/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('messaging_sent'))
        self.assertEquals(response.status_code, 200)

    def test_message_index_inbox(self):
        "Test index page with login at /messaging/inbox/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('messaging_inbox'))
        self.assertEquals(response.status_code, 200)

    def test_message_index_unread(self):
        "Test index page with login at /messaging/unread/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('messaging_unread'))
        self.assertEquals(response.status_code, 200)

    # Messages

    def test_message_compose_login(self):
        "Test index page with login at /message/compose/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('messaging_message_compose'))
        # self.assertEquals(response.status_code, 200)

    def test_message_view_login(self):
        "Test index page with login at /message/view/<message_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('messaging_message_view', args=[self.message.id]))
        self.assertEquals(response.status_code, 200)

    def test_message_delete_login(self):
        "Test index page with login at /message/edit/<message_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('messaging_message_delete', args=[self.message.id]))
        self.assertEquals(response.status_code, 200)

    # Streams
    def test_stream_add(self):
        "Test index page with login at /stream/add/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
#.........这里部分代码省略.........
开发者ID:tovmeod,项目名称:anaf,代码行数:103,代码来源:tests.py


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