Exemple #1
0
def test_should_finalize_session():
    _HANDLERS.clear()

    assert not should_finalize_session(MagicMock(is_options=True))
    assert should_finalize_session(MagicMock(is_options=False, is_respmod=True))
    assert should_finalize_session(MagicMock(is_options=False, is_respmod=False, headers=HeadersDict()))

    request = MagicMock(is_options=False, is_respmod=False, headers=HeadersDict())
    request.headers['X-Session-ID'] = 'foo'

    @handler()
    def respmod(request):
        pass

    @handler(name='foo')
    def respmod(request):
        pass

    for p in ['/reqmod', '/reqmod/', '/foo/reqmod', '/foo/reqmod/']:
        request.request_line.uri.path = p
        assert not should_finalize_session(request)

    for p in ['/bar/reqmod', '/bar/reqmod/']:
        request.request_line.uri.path = p
        assert should_finalize_session(request)
def test_should_finalize_session():
    _HANDLERS.clear()

    assert not should_finalize_session(MagicMock(is_options=True))
    assert should_finalize_session(MagicMock(is_options=False, is_respmod=True))
    assert should_finalize_session(MagicMock(is_options=False, is_respmod=False, headers=HeadersDict()))

    request = MagicMock(is_options=False, is_respmod=False, headers=HeadersDict())
    request.headers["X-Session-ID"] = "foo"

    @handler()
    def respmod(request):
        pass

    @handler(name="foo")
    def respmod(request):
        pass

    for p in ["/reqmod", "/reqmod/", "/foo/reqmod", "/foo/reqmod/"]:
        request.request_line.uri.path = p
        assert not should_finalize_session(request)

    for p in ["/bar/reqmod", "/bar/reqmod/"]:
        request.request_line.uri.path = p
        assert should_finalize_session(request)
Exemple #3
0
def test_sort_handlers():
    _HANDLERS.clear()

    _HANDLERS['foo'] = [
        (DomainCriteria('google.com'), None, None),
        (RegexCriteria('.*'), None, None),
    ]

    sort_handlers()

    first, second = _HANDLERS['foo']

    assert isinstance(first[0], RegexCriteria)
    assert isinstance(second[0], DomainCriteria)
def test_sort_handlers():
    _HANDLERS.clear()

    _HANDLERS['foo'] = [
        (DomainCriteria('google.com'), None, None),
        (RegexCriteria('.*'), None, None),
    ]

    sort_handlers()

    first, second = _HANDLERS['foo']

    assert isinstance(first[0], RegexCriteria)
    assert isinstance(second[0], DomainCriteria)
Exemple #5
0
 def setup_method(self, method):
     _HANDLERS.clear()
 def setup_method(self, method):
     _HANDLERS.clear()