コード例 #1
0
    def test_jinja_templates_render(self, notification, pyramid_config,
                                    pyramid_request):
        """Ensure that the jinja templates don't contain syntax errors"""
        pyramid_config.include('pyramid_jinja2')
        pyramid_config.add_jinja2_extension('h.jinja_extensions.Filters')

        generate(pyramid_request, notification)
コード例 #2
0
ファイル: reply_notification_test.py プロジェクト: gnott/h
    def test_falls_back_to_individual_page_if_no_bouncer(self,
                                                         notification,
                                                         parent_user,
                                                         pyramid_request,
                                                         reply_user,
                                                         html_renderer,
                                                         text_renderer,
                                                         links):
        """
        It link to individual pages if bouncer isn't available.

        If bouncer isn't enabled direct links in reply notification emails
        should fall back to linking to the reply's individual page, instead of
        the bouncer direct link.

        """
        # incontext_link() returns None if bouncer isn't available.
        links.incontext_link.return_value = None

        generate(pyramid_request, notification)

        expected_context = {
            'document_title': 'My fascinating page',
            'document_url': 'http://example.org/',
            'parent': notification.parent,
            'parent_user': parent_user,
            'reply_user_url': 'http://example.com/stream/user/patricia',
            'reply': notification.reply,
            'reply_url': 'http://example.com/ann/bar456',
            'reply_user': reply_user,
            'reply_user_url': 'http://example.com/stream/user/ron',
            'unsubscribe_url': 'http://example.com/unsub/FAKETOKEN',
        }
        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #3
0
ファイル: reply_notification_test.py プロジェクト: kaydoh/h
    def test_jinja_templates_render(self, notification, pyramid_config,
                                    pyramid_request):
        """Ensure that the jinja templates don't contain syntax errors."""
        pyramid_config.include("pyramid_jinja2")
        pyramid_config.include("h.jinja_extensions")

        generate(pyramid_request, notification)
コード例 #4
0
    def test_falls_back_to_individual_page_if_no_bouncer(
            self, notification, parent_user, pyramid_request, reply_user,
            html_renderer, text_renderer, links):
        """
        It link to individual pages if bouncer isn't available.

        If bouncer isn't enabled direct links in reply notification emails
        should fall back to linking to the reply's individual page, instead of
        the bouncer direct link.

        """
        # incontext_link() returns None if bouncer isn't available.
        links.incontext_link.return_value = None

        generate(pyramid_request, notification)

        expected_context = {
            'document_title': 'My fascinating page',
            'document_url': 'http://example.org/',
            'parent': notification.parent,
            'parent_user_display_name': parent_user.display_name,
            'parent_user_url': 'http://example.com/stream/user/patricia',
            'reply': notification.reply,
            'reply_url': 'http://example.com/ann/bar456',
            'reply_user_display_name': reply_user.display_name,
            'reply_user_url': 'http://example.com/stream/user/ron',
            'unsubscribe_url': 'http://example.com/unsub/FAKETOKEN',
        }
        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #5
0
    def test_calls_renderers_with_appropriate_context(
        self,
        notification,
        parent_user,
        pyramid_request,
        reply_user,
        html_renderer,
        text_renderer,
        links,
    ):
        generate(pyramid_request, notification)

        expected_context = {
            "document_title": "My fascinating page",
            "document_url": "http://example.org/",
            "parent": notification.parent,
            "parent_user_display_name": parent_user.display_name,
            "parent_user_url": "http://example.com/stream/user/patricia",
            "reply": notification.reply,
            "reply_url": links.incontext_link.return_value,
            "reply_user_display_name": reply_user.display_name,
            "reply_user_url": "http://example.com/stream/user/ron",
            "unsubscribe_url": "http://example.com/unsub/FAKETOKEN",
        }
        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #6
0
    def test_calls_token_serializer_with_correct_arguments(
        self, notification, pyramid_request, token_serializer
    ):
        generate(pyramid_request, notification)

        token_serializer.dumps.assert_called_once_with(
            {"type": "reply", "uri": "acct:[email protected]"}
        )
コード例 #7
0
    def test_falls_back_to_target_uri_for_document_title(
            self, notification, pyramid_request, html_renderer, text_renderer):
        notification.document.title = None

        generate(pyramid_request, notification)

        html_renderer.assert_(document_title='http://example.org/')
        text_renderer.assert_(document_title='http://example.org/')
コード例 #8
0
ファイル: reply_notification_test.py プロジェクト: gnott/h
    def test_jinja_templates_render(self,
                                    notification,
                                    pyramid_config,
                                    pyramid_request):
        """Ensure that the jinja templates don't contain syntax errors"""
        pyramid_config.include('pyramid_jinja2')
        pyramid_config.add_jinja2_extension('h.jinja_extensions.Filters')

        generate(pyramid_request, notification)
コード例 #9
0
    def test_calls_token_serializer_with_correct_arguments(
            self, notification, pyramid_request, token_serializer):
        generate(pyramid_request, notification)

        token_serializer.dumps.assert_called_once_with({
            'type':
            'reply',
            'uri':
            'acct:[email protected]',
        })
コード例 #10
0
    def test_urls_not_set_for_third_party_users(
        self, notification, pyramid_request, html_renderer, text_renderer
    ):
        pyramid_request.default_authority = "foo.org"
        expected_context = {"parent_user_url": None, "reply_user_url": None}

        generate(pyramid_request, notification)

        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #11
0
ファイル: reply_notification_test.py プロジェクト: gnott/h
    def test_calls_token_serializer_with_correct_arguments(self,
                                                           notification,
                                                           pyramid_request,
                                                           token_serializer):
        generate(pyramid_request, notification)

        token_serializer.dumps.assert_called_once_with({
            'type': 'reply',
            'uri': 'acct:[email protected]',
        })
コード例 #12
0
ファイル: reply_notification_test.py プロジェクト: gnott/h
    def test_falls_back_to_target_uri_for_document_title(self,
                                                         notification,
                                                         pyramid_request,
                                                         html_renderer,
                                                         text_renderer):
        notification.document.title = None

        generate(pyramid_request, notification)

        html_renderer.assert_(document_title='http://example.org/')
        text_renderer.assert_(document_title='http://example.org/')
コード例 #13
0
    def test_falls_back_to_target_uri_for_document_title(
            self, req, notification, storage_driver, html_renderer,
            text_renderer):
        if storage_driver == 'elastic':
            notification.document['title'] = []
        else:
            notification.document.meta[0].value = []

        generate(req, notification)

        html_renderer.assert_(document_title='http://example.org/')
        text_renderer.assert_(document_title='http://example.org/')
コード例 #14
0
    def test_urls_set_for_first_party_users(
        self, notification, pyramid_request, html_renderer, text_renderer
    ):
        expected_context = {
            "parent_user_url": "http://example.com/stream/user/patricia",
            "reply_user_url": "http://example.com/stream/user/ron",
        }

        generate(pyramid_request, notification)

        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #15
0
    def test_urls_not_set_for_third_party_users(self, notification,
                                                pyramid_request, html_renderer,
                                                text_renderer):
        pyramid_request.authority = 'foo.org'
        expected_context = {
            'parent_user_url': None,
            'reply_user_url': None,
        }

        generate(pyramid_request, notification)

        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #16
0
    def test_urls_set_for_first_party_users(self,
                                            notification,
                                            pyramid_request,
                                            html_renderer,
                                            text_renderer):
        expected_context = {
            'parent_user_url': 'http://example.com/stream/user/patricia',
            'reply_user_url': 'http://example.com/stream/user/ron',
        }

        generate(pyramid_request, notification)

        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #17
0
ファイル: reply_notification_test.py プロジェクト: djcun95/h
    def test_falls_back_to_target_uri_for_document_title(self,
                                                         notification,
                                                         pyramid_request,
                                                         storage_driver,
                                                         html_renderer,
                                                         text_renderer):
        if storage_driver == 'elastic':
            notification.document['title'] = []
        else:
            notification.document.meta[0].value = []

        generate(pyramid_request, notification)

        html_renderer.assert_(document_title='http://example.org/')
        text_renderer.assert_(document_title='http://example.org/')
コード例 #18
0
    def test_urls_not_set_for_third_party_users(self,
                                                notification,
                                                pyramid_request,
                                                html_renderer,
                                                text_renderer):
        pyramid_request.authority = 'foo.org'
        expected_context = {
            'parent_user_url': None,
            'reply_user_url': None,
        }

        generate(pyramid_request, notification)

        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #19
0
    def test_returns_usernames_if_no_display_names(self, notification,
                                                   pyramid_request,
                                                   html_renderer,
                                                   text_renderer, parent_user,
                                                   reply_user):
        parent_user.display_name = None
        reply_user.display_name = None

        generate(pyramid_request, notification)

        expected_context = {
            'parent_user_display_name': parent_user.username,
            'reply_user_display_name': reply_user.username
        }
        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #20
0
    def test_returns_usernames_if_no_display_names(self,
                                                   notification,
                                                   pyramid_request,
                                                   html_renderer,
                                                   text_renderer,
                                                   parent_user,
                                                   reply_user):
        parent_user.display_name = None
        reply_user.display_name = None

        generate(pyramid_request, notification)

        expected_context = {'parent_user_display_name': parent_user.username,
                            'reply_user_display_name': reply_user.username}
        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #21
0
    def test_returns_subject_with_reply_username(
        self, notification, pyramid_request, reply_user
    ):
        reply_user.display_name = None
        _, subject, _, _ = generate(pyramid_request, notification)

        assert subject == "ron has replied to your annotation"
コード例 #22
0
    def test_returns_text_and_body_results_from_renderers(
            self, notification, pyramid_request, html_renderer, text_renderer):
        html_renderer.string_response = 'HTML output'
        text_renderer.string_response = 'Text output'

        _, _, text, html = generate(pyramid_request, notification)

        assert html == 'HTML output'
        assert text == 'Text output'
コード例 #23
0
    def test_supports_non_ascii_display_names(self, notification,
                                              pyramid_request, html_renderer,
                                              text_renderer, parent_user,
                                              reply_user):
        parent_user.display_name = 'Parent 👩'
        reply_user.display_name = 'Child 👧'

        (_, subject, _, _) = generate(pyramid_request, notification)

        assert subject == 'Child 👧 has replied to your annotation'
コード例 #24
0
    def test_calls_renderers_with_appropriate_context(
            self, notification, parent_user, pyramid_request, reply_user,
            html_renderer, text_renderer, links):
        generate(pyramid_request, notification)

        expected_context = {
            'document_title': 'My fascinating page',
            'document_url': 'http://example.org/',
            'parent': notification.parent,
            'parent_user_display_name': parent_user.display_name,
            'parent_user_url': 'http://example.com/stream/user/patricia',
            'reply': notification.reply,
            'reply_url': links.incontext_link.return_value,
            'reply_user_display_name': reply_user.display_name,
            'reply_user_url': 'http://example.com/stream/user/ron',
            'unsubscribe_url': 'http://example.com/unsub/FAKETOKEN',
        }
        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #25
0
    def test_calls_renderers_with_appropriate_context(self, req, notification,
                                                      parent_user, reply_user,
                                                      html_renderer,
                                                      text_renderer):
        generate(req, notification)

        expected_context = {
            'document_title': 'My fascinating page',
            'document_url': 'http://example.org/',
            'parent': notification.parent,
            'parent_url': 'http://example.com/ann/foo123',
            'parent_user': parent_user,
            'reply': notification.reply,
            'reply_url': 'http://example.com/ann/bar456',
            'reply_user': reply_user,
            'reply_user_url': 'http://example.com/stream/user/ron',
            'unsubscribe_url': 'http://example.com/unsub/FAKETOKEN',
        }
        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #26
0
ファイル: reply_notification_test.py プロジェクト: gnott/h
    def test_returns_text_and_body_results_from_renderers(self,
                                                          notification,
                                                          pyramid_request,
                                                          html_renderer,
                                                          text_renderer):
        html_renderer.string_response = 'HTML output'
        text_renderer.string_response = 'Text output'

        _, _, text, html = generate(pyramid_request, notification)

        assert html == 'HTML output'
        assert text == 'Text output'
コード例 #27
0
    def test_supports_non_ascii_display_names(self,
                                              notification,
                                              pyramid_request,
                                              html_renderer,
                                              text_renderer,
                                              parent_user,
                                              reply_user):
        parent_user.display_name = 'Parent 👩'
        reply_user.display_name = 'Child 👧'

        (_, subject, _, _) = generate(pyramid_request, notification)

        assert subject == 'Child 👧 has replied to your annotation'
コード例 #28
0
ファイル: reply_notification_test.py プロジェクト: kaydoh/h
    def test_supports_non_ascii_display_names(
        self,
        notification,
        pyramid_request,
        parent_user,
        reply_user,
    ):
        parent_user.display_name = "Parent 👩"
        reply_user.display_name = "Child 👧"

        (_, subject, _, _) = generate(pyramid_request, notification)

        assert subject == "Child 👧 has replied to your annotation"
コード例 #29
0
ファイル: reply_notification_test.py プロジェクト: djcun95/h
    def test_calls_renderers_with_appropriate_context(self,
                                                      notification,
                                                      parent_user,
                                                      pyramid_request,
                                                      reply_user,
                                                      html_renderer,
                                                      text_renderer):
        generate(pyramid_request, notification)

        expected_context = {
            'document_title': 'My fascinating page',
            'document_url': 'http://example.org/',
            'parent': notification.parent,
            'parent_url': 'http://example.com/ann/foo123',
            'parent_user': parent_user,
            'reply': notification.reply,
            'reply_url': 'http://example.com/ann/bar456',
            'reply_user': reply_user,
            'reply_user_url': 'http://example.com/stream/user/ron',
            'unsubscribe_url': 'http://example.com/unsub/FAKETOKEN',
        }
        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #30
0
    def test_calls_renderers_with_appropriate_context(self,
                                                      notification,
                                                      parent_user,
                                                      pyramid_request,
                                                      reply_user,
                                                      html_renderer,
                                                      text_renderer,
                                                      links):
        generate(pyramid_request, notification)

        expected_context = {
            'document_title': 'My fascinating page',
            'document_url': 'http://example.org/',
            'parent': notification.parent,
            'parent_user_display_name': parent_user.display_name,
            'parent_user_url': 'http://example.com/stream/user/patricia',
            'reply': notification.reply,
            'reply_url': links.incontext_link.return_value,
            'reply_user_display_name': reply_user.display_name,
            'reply_user_url': 'http://example.com/stream/user/ron',
            'unsubscribe_url': 'http://example.com/unsub/FAKETOKEN',
        }
        html_renderer.assert_(**expected_context)
        text_renderer.assert_(**expected_context)
コード例 #31
0
ファイル: reply_notification_test.py プロジェクト: bZichett/h
    def test_returns_parent_email_as_recipients(self, req, notification):
        recipients, _, _, _ = generate(req, notification)

        assert recipients == ['*****@*****.**']
コード例 #32
0
ファイル: reply_notification_test.py プロジェクト: gnott/h
    def test_gets_in_context_link(self, notification, links, pyramid_request):
        generate(pyramid_request, notification)

        links.incontext_link.assert_called_once_with(pyramid_request,
                                                     notification.reply)
コード例 #33
0
    def test_returns_subject_with_reply_display_name(self, notification, pyramid_request, reply_user):
        _, subject, _, _ = generate(pyramid_request, notification)

        assert subject == 'Ron Burgundy has replied to your annotation'
コード例 #34
0
ファイル: reply_notification_test.py プロジェクト: gnott/h
    def test_returns_parent_email_as_recipients(self, notification, pyramid_request):
        recipients, _, _, _ = generate(pyramid_request, notification)

        assert recipients == ['*****@*****.**']
コード例 #35
0
ファイル: reply_notification_test.py プロジェクト: gnott/h
    def test_returns_subject_with_reply_username(self, notification, pyramid_request):
        _, subject, _, _ = generate(pyramid_request, notification)

        assert subject == 'ron has replied to your annotation'
コード例 #36
0
    def test_returns_subject_with_reply_username(self, req, notification):
        _, subject, _, _ = generate(req, notification)

        assert subject == 'ron has replied to your annotation'
コード例 #37
0
    def test_returns_parent_email_as_recipients(self, req, notification):
        recipients, _, _, _ = generate(req, notification)

        assert recipients == ['*****@*****.**']
コード例 #38
0
    def test_gets_in_context_link(self, notification, links, pyramid_request):
        generate(pyramid_request, notification)

        links.incontext_link.assert_called_once_with(
            pyramid_request, notification.reply
        )
コード例 #39
0
    def test_returns_parent_email_as_recipients(self, notification, pyramid_request):
        recipients, _, _, _ = generate(pyramid_request, notification)

        assert recipients == ["*****@*****.**"]
コード例 #40
0
    def test_returns_subject_with_reply_display_name(
        self, notification, pyramid_request, reply_user
    ):
        _, subject, _, _ = generate(pyramid_request, notification)

        assert subject == "Ron Burgundy has replied to your annotation"