def test_URIMatcher_respects_querystring(): ("URIMatcher response querystring") matcher = URIMatcher('http://www.foo.com/?query=true', None) info = URIInfo.from_uri('http://www.foo.com/', None) assert matcher.matches(info) matcher = URIMatcher('http://www.foo.com/?query=true', None, match_querystring=True) info = URIInfo.from_uri('http://www.foo.com/', None) assert not matcher.matches(info) matcher = URIMatcher('http://www.foo.com/?query=true', None, match_querystring=True) info = URIInfo.from_uri('http://www.foo.com/?query=true', None) assert matcher.matches(info) matcher = URIMatcher('http://www.foo.com/?query=true&unquery=false', None, match_querystring=True) info = URIInfo.from_uri('http://www.foo.com/?unquery=false&query=true', None) assert matcher.matches(info) matcher = URIMatcher('http://www.foo.com/?unquery=false&query=true', None, match_querystring=True) info = URIInfo.from_uri('http://www.foo.com/?query=true&unquery=false', None) assert matcher.matches(info)
def test_URIMatcher_respects_querystring(): ("URIMatcher response querystring") matcher = URIMatcher('http://www.foo.com/?query=true', None) info = URIInfo.from_uri('http://www.foo.com/', None) assert matcher.matches(info) matcher = URIMatcher('http://www.foo.com/?query=true', None, match_querystring=True) info = URIInfo.from_uri('http://www.foo.com/', None) assert not matcher.matches(info) matcher = URIMatcher('http://www.foo.com/?query=true', None, match_querystring=True) info = URIInfo.from_uri('http://www.foo.com/?query=true', None) assert matcher.matches(info)
def test_Entry_class_counts_dynamic(): result = (200, {}, 'こんにちは'.encode('utf-8')) entry = Entry(HTTPretty.GET, 'http://example.com', lambda *args: result) entry.info = URIInfo.from_uri('http://example.com', entry) buf = FakeSockFile() entry.fill_filekind(buf) response = buf.getvalue() expect(b'content-length: 15\n').to.be.within(response)
def test_Entry_class_counts_dynamic(): result = (200, {}, 'こんにちは'.encode('utf-8')) entry = Entry(HTTPretty.GET, 'http://example.com', lambda *args: result) entry.info = URIInfo.from_uri('http://example.com', entry) buf = FakeSockFile() entry.fill_filekind(buf) response = buf.getvalue() expect(b'content-length: 15\n').to.be.within(response)