예제 #1
0
    def test_raises_not_found_if_token_invalue(self, pyramid_request, token_serializer):
        from pyramid.exceptions import HTTPNotFound
        pyramid_request.matchdict = {'token': 'wibble'}
        token_serializer.loads.side_effect = ValueError('token invalid')

        with pytest.raises(HTTPNotFound):
            unsubscribe(pyramid_request)
예제 #2
0
    def test_raises_not_found_if_token_invalue(self, pyramid_request,
                                               token_serializer):
        from pyramid.exceptions import HTTPNotFound
        pyramid_request.matchdict = {'token': 'wibble'}
        token_serializer.loads.side_effect = ValueError('token invalid')

        with pytest.raises(HTTPNotFound):
            unsubscribe(pyramid_request)
예제 #3
0
    def test_raises_not_found_if_token_invalue(self, pyramid_request,
                                               token_serializer):

        pyramid_request.matchdict = {"token": "wibble"}
        token_serializer.loads.side_effect = ValueError("token invalid")

        with pytest.raises(HTTPNotFound):
            unsubscribe(pyramid_request)
예제 #4
0
    def test_successfully_unsubscribes_user(self, pyramid_request, subscriptions, token_serializer):
        sub1, _, _ = subscriptions
        pyramid_request.matchdict = {'token': 'wibble'}
        token_serializer.loads.return_value = {'type': 'reply', 'uri': 'acct:[email protected]'}

        unsubscribe(pyramid_request)

        assert not sub1.active
예제 #5
0
    def test_ignores_other_subscriptions(self, pyramid_request, subscriptions, token_serializer):
        _, sub2, sub3 = subscriptions
        pyramid_request.matchdict = {'token': 'wibble'}
        token_serializer.loads.return_value = {'type': 'reply', 'uri': 'acct:[email protected]'}

        unsubscribe(pyramid_request)

        assert sub2.active
        assert sub3.active
예제 #6
0
    def test_successfully_unsubscribes_user(self, pyramid_request,
                                            subscriptions, token_serializer):
        sub1, _, _ = subscriptions
        pyramid_request.matchdict = {'token': 'wibble'}
        token_serializer.loads.return_value = {
            'type': 'reply',
            'uri': 'acct:[email protected]'
        }

        unsubscribe(pyramid_request)

        assert not sub1.active
    def test_multiple_calls_ok(self, pyramid_request, subscriptions, token_serializer):
        sub1, _, _ = subscriptions
        pyramid_request.matchdict = {"token": "wibble"}
        token_serializer.loads.return_value = {
            "type": "reply",
            "uri": "acct:[email protected]",
        }

        unsubscribe(pyramid_request)
        unsubscribe(pyramid_request)

        assert not sub1.active
예제 #8
0
    def test_multiple_calls_ok(self, pyramid_request, subscriptions, token_serializer):
        sub1, _, _ = subscriptions
        pyramid_request.matchdict = {"token": "wibble"}
        token_serializer.loads.return_value = {
            "type": "reply",
            "uri": "acct:[email protected]",
        }

        unsubscribe(pyramid_request)
        unsubscribe(pyramid_request)

        assert not sub1.active
예제 #9
0
    def test_ignores_other_subscriptions(self, pyramid_request, subscriptions,
                                         token_serializer):
        _, sub2, sub3 = subscriptions
        pyramid_request.matchdict = {'token': 'wibble'}
        token_serializer.loads.return_value = {
            'type': 'reply',
            'uri': 'acct:[email protected]'
        }

        unsubscribe(pyramid_request)

        assert sub2.active
        assert sub3.active
예제 #10
0
    def test_ignores_other_subscriptions(self, pyramid_request, subscriptions,
                                         token_serializer):
        _, sub2, sub3 = subscriptions
        pyramid_request.matchdict = {"token": "wibble"}
        token_serializer.loads.return_value = {
            "type": "reply",
            "uri": "acct:[email protected]",
        }

        unsubscribe(pyramid_request)

        assert sub2.active
        assert sub3.active
예제 #11
0
    def test_ignores_other_subscriptions(
        self, pyramid_request, subscriptions, token_serializer
    ):
        _, sub2, sub3 = subscriptions
        pyramid_request.matchdict = {"token": "wibble"}
        token_serializer.loads.return_value = {
            "type": "reply",
            "uri": "acct:[email protected]",
        }

        unsubscribe(pyramid_request)

        assert sub2.active
        assert sub3.active
예제 #12
0
    def test_deserializes_token(self, pyramid_request, token_serializer):
        pyramid_request.matchdict = {'token': 'wibble'}

        unsubscribe(pyramid_request)

        token_serializer.loads.assert_called_once_with('wibble')
예제 #13
0
    def test_deserializes_token(self, pyramid_request, token_serializer):
        pyramid_request.matchdict = {'token': 'wibble'}

        unsubscribe(pyramid_request)

        token_serializer.loads.assert_called_once_with('wibble')