Example #1
0
    def test_returns_none_when_subscription_absent(self, db_session, parent,
                                                   pyramid_request, reply):
        db_session.query(Subscriptions).delete()

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #2
0
    def test_returns_none_when_subscription_inactive(self, pyramid_request,
                                                     reply, subscription):
        subscription.active = False

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #3
0
    def test_returns_none_when_reply_by_same_user(self, parent,
                                                  pyramid_request, reply):
        parent.userid = 'acct:[email protected]'

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #4
0
    def test_returns_none_when_parent_user_cannot_read_reply(
            self, pyramid_request, reply):
        reply.shared = False

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #5
0
    def test_returns_none_when_parent_does_not_exist(self, annotations, parent,
                                                     pyramid_request, reply):
        del annotations[parent.id]

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #6
0
    def test_returns_none_when_annotation_is_not_reply(self, reply):
        request = DummyRequest(db=db.Session)
        reply.references = None

        result = get_notification(request, reply, 'create')

        assert result is None
Example #7
0
    def test_returns_none_when_parent_does_not_exist(self, annotations, parent,
                                                     pyramid_request, reply):
        del annotations[parent.id]

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #8
0
    def test_returns_none_when_subscription_absent(self, reply, parent, subscription):
        request = DummyRequest(db=db.Session)
        db.Session.delete(subscription)

        result = get_notification(request, reply, 'create')

        assert result is None
Example #9
0
    def test_returns_none_when_subscription_inactive(self, reply, subscription):
        request = DummyRequest(db=db.Session)
        subscription.active = False

        result = get_notification(request, reply, 'create')

        assert result is None
Example #10
0
    def test_returns_none_when_parent_user_cannot_read_reply(self, reply):
        request = DummyRequest(db=db.Session)
        reply.shared = False

        result = get_notification(request, reply, 'create')

        assert result is None
Example #11
0
    def test_returns_none_when_reply_by_same_user(self, reply, parent):
        request = DummyRequest(db=db.Session)
        parent.userid = 'acct:[email protected]'

        result = get_notification(request, reply, 'create')

        assert result is None
Example #12
0
    def test_returns_none_when_subscription_inactive(self, pyramid_request,
                                                     reply, subscription):
        subscription.active = False

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #13
0
    def test_returns_none_when_parent_user_cannot_read_reply(
            self, pyramid_request, reply):
        reply.shared = False

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #14
0
    def test_returns_none_when_reply_by_same_user(self, parent,
                                                  pyramid_request, reply):
        parent.userid = 'acct:[email protected]'

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #15
0
    def test_returns_none_when_subscription_absent(self, reply, parent, subscription):
        request = DummyRequest(db=db.Session)
        db.Session.delete(subscription)

        result = get_notification(request, reply, 'create')

        assert result is None
Example #16
0
    def test_returns_none_when_annotation_is_not_reply(self, pyramid_request,
                                                       reply):
        reply.references = None

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #17
0
    def test_returns_none_when_subscription_absent(self, db_session, parent,
                                                   pyramid_request, reply):
        db_session.query(Subscriptions).delete()

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #18
0
    def test_returns_none_when_subscription_inactive(self, reply, subscription):
        request = DummyRequest(db=db.Session)
        subscription.active = False

        result = get_notification(request, reply, 'create')

        assert result is None
Example #19
0
    def test_returns_none_when_parent_user_does_not_exist(self, factories, pyramid_request, reply, user_service):
        users = {'acct:[email protected]': factories.User()}
        user_service.fetch.side_effect = users.get

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #20
0
    def test_returns_none_when_annotation_is_not_reply(self, pyramid_request,
                                                       reply):
        reply.references = None

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #21
0
    def test_returns_none_when_parent_does_not_exist(self, annotations, reply, parent):
        request = DummyRequest(db=db.Session)
        del annotations[parent.id]

        result = get_notification(request, reply, 'create')

        assert result is None
Example #22
0
    def test_returns_none_when_parent_does_not_exist(self, annotations, reply, parent):
        request = DummyRequest(db=db.Session)
        del annotations[parent.id]

        result = get_notification(request, reply, 'create')

        assert result is None
Example #23
0
    def test_returns_none_when_parent_user_has_no_email_address(self, factories, pyramid_request, reply, user_service):
        users = {
            "acct:[email protected]": factories.User(email=None),
            "acct:[email protected]": factories.User(),
        }
        user_service.fetch.side_effect = users.get

        assert get_notification(pyramid_request, reply, "create") is None
Example #24
0
    def test_returns_none_when_parent_user_does_not_exist(
            self, factories, pyramid_request, reply, user_service):
        users = {'acct:[email protected]': factories.User()}
        user_service.fetch.side_effect = users.get

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #25
0
    def test_returns_none_when_parent_user_has_no_email_address(
            self, factories, pyramid_request, reply, user_service):
        users = {
            "acct:[email protected]": factories.User(email=None),
            "acct:[email protected]": factories.User(),
        }
        user_service.fetch.side_effect = users.get

        assert get_notification(pyramid_request, reply, "create") is None
Example #26
0
    def test_returns_none_when_parent_user_cannot_read_reply(self, reply, storage_driver):
        request = DummyRequest(db=db.Session)
        if storage_driver == 'elastic':
            reply['permissions'] = {'read': ['acct:[email protected]']}
        else:
            reply.shared = False

        result = get_notification(request, reply, 'create')

        assert result is None
Example #27
0
    def test_returns_none_when_reply_by_same_user(self, reply, parent, storage_driver):
        request = DummyRequest(db=db.Session)
        if storage_driver == 'elastic':
            parent['user'] = '******'
        else:
            parent.userid = 'acct:[email protected]'

        result = get_notification(request, reply, 'create')

        assert result is None
Example #28
0
    def test_returns_none_when_annotation_is_not_reply(self, reply, storage_driver):
        request = DummyRequest(db=db.Session)
        if storage_driver == 'elastic':
            del reply['references']
        else:
            reply.references = None

        result = get_notification(request, reply, 'create')

        assert result is None
Example #29
0
    def test_returns_none_when_parent_user_does_not_exist(self, get_user, pyramid_request, reply):
        def _only_return_reply_user(userid, _):
            if userid == 'acct:[email protected]':
                return User(username='******')
            return None
        get_user.side_effect = _only_return_reply_user

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #30
0
    def test_returns_correct_params_when_subscribed(
            self, parent, pyramid_request, reply, user_service):
        result = get_notification(pyramid_request, reply, 'create')

        assert isinstance(result, Notification)
        assert result.reply == reply
        assert result.parent == parent
        assert result.reply_user == user_service.fetch(reply.userid)
        assert result.parent_user == user_service.fetch(parent.userid)
        assert result.document == reply.document
Example #31
0
    def test_returns_correct_params_when_subscribed(self, parent,
                                                    pyramid_request, reply,
                                                    user_service):
        result = get_notification(pyramid_request, reply, 'create')

        assert isinstance(result, Notification)
        assert result.reply == reply
        assert result.parent == parent
        assert result.reply_user == user_service.fetch(reply.userid)
        assert result.parent_user == user_service.fetch(parent.userid)
        assert result.document == reply.document
Example #32
0
    def test_returns_correct_params_when_subscribed(self, get_user, reply, parent):
        request = DummyRequest(db=db.Session)

        result = get_notification(request, reply, 'create')

        assert isinstance(result, Notification)
        assert result.reply == reply
        assert result.parent == parent
        assert result.reply_user == get_user(reply.userid, request)
        assert result.parent_user == get_user(parent.userid, request)
        assert result.document == reply.document
Example #33
0
    def test_returns_correct_params_when_subscribed(self, get_user, reply, parent):
        request = DummyRequest(db=db.Session)

        result = get_notification(request, reply, 'create')

        assert isinstance(result, Notification)
        assert result.reply == reply
        assert result.parent == parent
        assert result.reply_user == get_user(reply.userid, request)
        assert result.parent_user == get_user(parent.userid, request)
        assert result.document == reply.document
Example #34
0
    def test_returns_none_when_parent_user_does_not_exist(self, get_user, reply):
        request = DummyRequest(db=db.Session)

        def _only_return_reply_user(userid, _):
            if userid == 'acct:[email protected]':
                return User(username='******')
            return None
        get_user.side_effect = _only_return_reply_user

        result = get_notification(request, reply, 'create')

        assert result is None
Example #35
0
    def test_returns_none_when_reply_user_does_not_exist(self, factories, pyramid_request, reply, user_service):
        """
        Don't send a reply if somehow the replying user ceased to exist.

        It's not clear when or why this would ever happen, but we can't
        construct the reply email without the user who replied existing. We log
        a warning if this happens.
        """
        users = {'acct:[email protected]': factories.User()}
        user_service.fetch.side_effect = users.get

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #36
0
    def test_returns_none_when_reply_user_does_not_exist(
            self, factories, pyramid_request, reply, user_service):
        """
        Don't send a reply if somehow the replying user ceased to exist.

        It's not clear when or why this would ever happen, but we can't
        construct the reply email without the user who replied existing. We log
        a warning if this happens.
        """
        users = {'acct:[email protected]': factories.User()}
        user_service.fetch.side_effect = users.get

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #37
0
    def test_returns_none_when_reply_user_does_not_exist(self, get_user, pyramid_request, reply):
        """
        Don't send a reply if somehow the replying user ceased to exist.

        It's not clear when or why this would ever happen, but we can't
        construct the reply email without the user who replied existing. We log
        a warning if this happens.
        """
        def _only_return_parent_user(userid, _):
            if userid == 'acct:[email protected]':
                return User(username='******')
            return None
        get_user.side_effect = _only_return_parent_user

        result = get_notification(pyramid_request, reply, 'create')

        assert result is None
Example #38
0
    def test_returns_none_when_reply_user_does_not_exist(self, get_user, reply):
        """
        Don't send a reply if somehow the replying user ceased to exist.

        It's not clear when or why this would ever happen, but we can't
        construct the reply email without the user who replied existing. We log
        a warning if this happens.
        """
        request = DummyRequest(db=db.Session)

        def _only_return_parent_user(userid, _):
            if userid == 'acct:[email protected]':
                return User(username='******')
            return None
        get_user.side_effect = _only_return_parent_user

        result = get_notification(request, reply, 'create')

        assert result is None
Example #39
0
 def test_returns_none_when_action_is_not_create(self, pyramid_request, reply):
     assert get_notification(pyramid_request, reply, 'update') is None
     assert get_notification(pyramid_request, reply, 'delete') is None
     assert get_notification(pyramid_request, reply, 'frobnicate') is None
Example #40
0
    def test_returns_none_when_action_is_not_create(self, reply):
        request = DummyRequest(db=db.Session)

        assert get_notification(request, reply, 'update') is None
        assert get_notification(request, reply, 'delete') is None
        assert get_notification(request, reply, 'frobnicate') is None
Example #41
0
    def test_returns_none_when_action_is_not_create(self, reply):
        request = DummyRequest(db=db.Session)

        assert get_notification(request, reply, 'update') is None
        assert get_notification(request, reply, 'delete') is None
        assert get_notification(request, reply, 'frobnicate') is None
Example #42
0
 def test_returns_none_when_action_is_not_create(self, pyramid_request,
                                                 reply):
     assert get_notification(pyramid_request, reply, 'update') is None
     assert get_notification(pyramid_request, reply, 'delete') is None
     assert get_notification(pyramid_request, reply, 'frobnicate') is None