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


Python tests.attrs_eq函数代码示例

本文整理汇总了Python中sumo.tests.attrs_eq函数的典型用法代码示例。如果您正苦于以下问题:Python attrs_eq函数的具体用法?Python attrs_eq怎么用?Python attrs_eq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_private_message_sends_email

    def test_private_message_sends_email(self, get_current):
        """
        With the setting enabled and receiving a private message should
        send and email.
        """
        get_current.return_value.domain = 'testserver'

        to = User.objects.all()[1]
        s, c = Setting.objects.get_or_create(user=to,
                                             name='email_private_messages')
        s.value = True
        s.save()
        # User has setting, and should recieve notification email.

        assert Setting.get_for_user(to, 'email_private_messages')

        self.client.login(username='jsocol', password='testpass')
        res = post(self.client, 'messages.new',
             {'to': to, 'message': 'a message'})
        subject = u'[SUMO] You have a new private message from [{sender}]'

        attrs_eq(mail.outbox[0], to=[to.email],
                 subject=subject.format(sender='jsocol'))
        starts_with(mail.outbox[0].body,
                    PRIVATE_MESSAGE_EMAIL.format(sender='jsocol'))
开发者ID:erikrose,项目名称:kitsune,代码行数:25,代码来源:test_notifications.py

示例2: test_watch_both_then_new_post

    def test_watch_both_then_new_post(self, get_current):
        """Watching both forum and thread.

        Replying to a thread should send ONE email."""
        get_current.return_value.domain = 'testserver'

        t = thread(save=True)
        f = t.forum
        forum_post(thread=t, save=True)
        poster = user(save=True)
        watcher = user(save=True)

        self._toggle_watch_forum_as(f, watcher, turn_on=True)
        self._toggle_watch_thread_as(t, watcher, turn_on=True)
        self.client.login(username=poster.username, password='testpass')
        post(self.client, 'forums.reply', {'content': 'a post'},
             args=[f.slug, t.id])

        eq_(1, len(mail.outbox))
        p = Post.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=[watcher.email],
                 subject='Re: {f} - {t}'.format(f=f, t=t))
        body = REPLY_EMAIL.format(
            username=poster.username,
            forum_slug=f.slug,
            thread_title=t.title,
            thread_id=t.id,
            post_id=p.id)
        starts_with(mail.outbox[0].body, body)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:29,代码来源:test_notifications.py

示例3: test_solution_notification

    def test_solution_notification(self, get_current):
        """Assert that hitting the watch toggle toggles and that proper mails
        are sent to anonymous and registered watchers."""
        # TODO: Too monolithic. Split this test into several.
        get_current.return_value.domain = 'testserver'

        question = self._toggle_watch_question('solution', turn_on=True)
        QuestionSolvedEvent.notify('[email protected]', question)

        answer = question.answers.all()[0]
        # Post a reply
        self.client.login(username='jsocol', password='testpass')
        post(self.client, 'questions.solution', args=[question.id, answer.id])

        # Order of emails is not important.
        attrs_eq(mail.outbox[0], to=['[email protected]'],
                 subject='Solution found to Firefox Help question')
        starts_with(mail.outbox[0].body, SOLUTION_EMAIL % answer.id)

        attrs_eq(mail.outbox[1], to=['[email protected]'],
                 subject='Solution found to Firefox Help question')
        starts_with(mail.outbox[1].body,
                    SOLUTION_EMAIL_TO_ANONYMOUS % answer.id)

        self._toggle_watch_question('solution', turn_on=False)
开发者ID:Akamad007,项目名称:kitsune,代码行数:25,代码来源:test_notifications.py

示例4: test_watch_forum_then_new_post

    def test_watch_forum_then_new_post(self, get_current):
        """Watching a forum and replying to a thread should send email."""
        get_current.return_value.domain = 'testserver'

        f = self._toggle_watch_forum_as('pcraciunoiu', turn_on=True)
        t = f.thread_set.all()[0]
        self.client.login(username='jsocol', password='testpass')
        post(self.client, 'forums.reply', {'content': 'a post'},
             args=[f.slug, t.id])

        p = Post.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=['[email protected]'],
                 subject='Re: Test forum - Sticky Thread')
        starts_with(mail.outbox[0].body, REPLY_EMAIL % p.id)
开发者ID:bowmasters,项目名称:kitsune,代码行数:14,代码来源:test_notifications.py

示例5: test_watch_forum_then_new_thread

    def test_watch_forum_then_new_thread(self, get_current):
        """Watching a forum and creating a new thread should send email."""
        get_current.return_value.domain = 'testserver'

        f = self._toggle_watch_kbforum_as('pcraciunoiu', turn_on=True)
        self.client.login(username='jsocol', password='testpass')
        post(self.client, 'wiki.discuss.new_thread',
             {'title': 'a title', 'content': 'a post'}, args=[f.slug])

        t = Thread.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=['[email protected]'],
                 subject=u'New thread in an article title: a title',
                 body=EMAIL_CONTENT[1] % t.id)

        self._toggle_watch_kbforum_as('pcraciunoiu', turn_on=False)
开发者ID:fwenzel,项目名称:kitsune,代码行数:15,代码来源:test_notifications.py

示例6: test_watch_thread_then_reply

    def test_watch_thread_then_reply(self, get_current):
        """The event fires and sends emails when watching a thread."""
        get_current.return_value.domain = 'testserver'

        t = self._toggle_watch_thread_as('pcraciunoiu', turn_on=True)
        self.client.login(username='jsocol', password='testpass')
        post(self.client, 'forums.reply', {'content': 'a post'},
             args=[t.forum.slug, t.id])

        p = Post.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=['[email protected]'],
                 subject='Re: Test forum - Sticky Thread')
        starts_with(mail.outbox[0].body, REPLY_EMAIL % p.id)

        self._toggle_watch_thread_as('pcraciunoiu', turn_on=False)
开发者ID:bowmasters,项目名称:kitsune,代码行数:15,代码来源:test_notifications.py

示例7: test_watch_forum_then_new_thread

    def test_watch_forum_then_new_thread(self, get_current):
        """Watching a forum and creating a new thread should send email."""
        get_current.return_value.domain = 'testserver'

        f = self._toggle_watch_forum_as('pcraciunoiu', turn_on=True)
        self.client.login(username='jsocol', password='testpass')
        post(self.client, 'forums.new_thread',
             {'title': 'a title', 'content': 'a post'}, args=[f.slug])

        t = Thread.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=['[email protected]'],
                 subject='Test forum - a title')
        starts_with(mail.outbox[0].body, NEW_THREAD_EMAIL % t.id)

        self._toggle_watch_forum_as('pcraciunoiu', turn_on=False)
开发者ID:bowmasters,项目名称:kitsune,代码行数:15,代码来源:test_notifications.py

示例8: test_watch_thread_then_reply

    def test_watch_thread_then_reply(self, get_current):
        """The event fires and sends emails when watching a thread."""
        get_current.return_value.domain = 'testserver'

        t = self._toggle_watch_thread_as('pcraciunoiu', turn_on=True)
        self.client.login(username='jsocol', password='testpass')
        post(self.client, 'wiki.discuss.reply', {'content': 'a post'},
             args=[t.document.slug, t.id])

        p = Post.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=['[email protected]'],
                 subject='Reply to: Sticky Thread',
                 body=EMAIL_CONTENT[0] % p.id)

        self._toggle_watch_thread_as('pcraciunoiu', turn_on=False)
开发者ID:fwenzel,项目名称:kitsune,代码行数:15,代码来源:test_notifications.py

示例9: test_watch_solution

    def test_watch_solution(self, get_current):
        """Watch a question for solution."""
        self.client.logout()
        get_current.return_value.domain = "testserver"

        post(self.client, "questions.watch", {"email": "[email protected]", "event_type": "solution"}, args=[self.question.id])
        assert QuestionSolvedEvent.is_notifying("[email protected]", self.question), "Watch was not created"

        attrs_eq(mail.outbox[0], to=["[email protected]"], subject="Please confirm your email address")
        assert "questions/confirm/" in mail.outbox[0].body
        assert "Solution found" in mail.outbox[0].body

        # Now activate the watch.
        w = Watch.objects.get()
        get(self.client, "questions.activate_watch", args=[w.id, w.secret])
        assert Watch.objects.get().is_active
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:16,代码来源:test_templates.py

示例10: test_watch_forum_then_new_post

    def test_watch_forum_then_new_post(self, get_current):
        """Watching a forum and replying to a thread should send email."""
        get_current.return_value.domain = 'testserver'

        u = user(save=True)
        d = document(title='an article title', save=True)
        f = self._toggle_watch_kbforum_as(u.username, d, turn_on=True)
        t = thread(title='Sticky Thread', document=d, save=True)
        u2 = user(username='jsocol', save=True)
        self.client.login(username=u2.username, password='testpass')
        post(self.client, 'wiki.discuss.reply', {'content': 'a post'},
             args=[f.slug, t.id])

        p = Post.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=[u.email],
                 subject='Re: an article title - Sticky Thread')
        starts_with(mail.outbox[0].body, REPLY_EMAIL % (d.slug, t.id, p.id))
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:17,代码来源:test_notifications.py

示例11: test_watch_forum_then_new_thread

    def test_watch_forum_then_new_thread(self, get_current):
        """Watching a forum and creating a new thread should send email."""
        get_current.return_value.domain = 'testserver'

        u = user(save=True)
        d = document(title='an article title', save=True)
        f = self._toggle_watch_kbforum_as(u.username, d, turn_on=True)
        u2 = user(username='jsocol', save=True)
        self.client.login(username=u2.username, password='testpass')
        post(self.client, 'wiki.discuss.new_thread',
             {'title': 'a title', 'content': 'a post'}, args=[f.slug])

        t = Thread.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=[u.email],
                 subject=u'an article title - a title')
        starts_with(mail.outbox[0].body, NEW_THREAD_EMAIL % (d.slug, t.id))

        self._toggle_watch_kbforum_as(u.username, d, turn_on=False)
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:18,代码来源:test_notifications.py

示例12: test_watch_locale_then_new_thread

    def test_watch_locale_then_new_thread(self, get_current):
        """Watching locale and create a thread."""
        get_current.return_value.domain = 'testserver'

        d = document(title='an article title', locale='en-US', save=True)
        u = user(username='berkerpeksag', save=True)
        self.client.login(username=u.username, password='testpass')
        post(self.client, 'wiki.discuss.watch_locale', {'watch': 'yes'})

        u2 = user(username='jsocol', save=True)
        self.client.login(username=u2.username, password='testpass')
        post(self.client, 'wiki.discuss.new_thread',
             {'title': 'a title', 'content': 'a post'}, args=[d.slug])

        # Email was sent as expected.
        t = Thread.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=[u.email],
                 subject=u'an article title - a title')
        starts_with(mail.outbox[0].body, NEW_THREAD_EMAIL % (d.slug, t.id))
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:19,代码来源:test_notifications.py

示例13: test_watch_thread_then_reply

    def test_watch_thread_then_reply(self, get_current):
        """The event fires and sends emails when watching a thread."""
        get_current.return_value.domain = 'testserver'
        u = user(username='jsocol', save=True)
        u_b = user(username='berkerpeksag', save=True)
        d = document(title='an article title', save=True)
        _t = thread(title='Sticky Thread', document=d, is_sticky=True,
                    save=True)
        t = self._toggle_watch_thread_as(u_b.username, _t, turn_on=True)
        self.client.login(username=u.username, password='testpass')
        post(self.client, 'wiki.discuss.reply', {'content': 'a post'},
             args=[t.document.slug, t.id])

        p = Post.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=[u_b.email],
                 subject='Re: an article title - Sticky Thread')
        starts_with(mail.outbox[0].body, REPLY_EMAIL % (d.slug, t.id, p.id))

        self._toggle_watch_thread_as(u_b.username, _t, turn_on=False)
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:19,代码来源:test_notifications.py

示例14: test_watch_locale_then_new_thread

    def test_watch_locale_then_new_thread(self, get_current):
        """Watching locale and create a thread."""
        get_current.return_value.domain = 'testserver'

        d = Document.objects.filter(locale='en-US')[0]
        # Log in as pcraciunoiu.
        self.client.login(username='pcraciunoiu', password='testpass')
        post(self.client, 'wiki.discuss.watch_locale', {'watch': 'yes'})

        # Create new thread as jsocol for document d.
        self.client.login(username='jsocol', password='testpass')
        post(self.client, 'wiki.discuss.new_thread',
             {'title': 'a title', 'content': 'a post'}, args=[d.slug])

        # Email was sent as expected.
        t = Thread.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=['[email protected]'],
                 subject=u'an article title - a title')
        starts_with(mail.outbox[0].body, NEW_THREAD_EMAIL % t.id)
开发者ID:bowmasters,项目名称:kitsune,代码行数:19,代码来源:test_notifications.py

示例15: test_watch_both_then_new_post

    def test_watch_both_then_new_post(self, get_current):
        """Watching both and replying to a thread should send ONE email."""
        get_current.return_value.domain = 'testserver'

        f = self._toggle_watch_kbforum_as('pcraciunoiu', turn_on=True)
        t = f.thread_set.all()[0]
        self._toggle_watch_thread_as('pcraciunoiu', turn_on=True,
                                     thread_id=t.id)
        self.client.login(username='jsocol', password='testpass')
        post(self.client, 'wiki.discuss.reply', {'content': 'a post'},
             args=[f.slug, t.id])

        eq_(1, len(mail.outbox))
        p = Post.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=['[email protected]'],
                 subject='Reply to: Sticky Thread',
                 body=EMAIL_CONTENT[0] % p.id)

        self._toggle_watch_kbforum_as('pcraciunoiu', turn_on=False)
        self._toggle_watch_thread_as('pcraciunoiu', turn_on=False)
开发者ID:fwenzel,项目名称:kitsune,代码行数:20,代码来源:test_notifications.py


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