mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 08:04:49 +01:00
Spaces in test responses
It seems like JSON in responses is now minimized without spaces? I'm not sure what changed in the stack to do that.
This commit is contained in:
parent
e824ffda8a
commit
5b72d96871
@ -36,7 +36,7 @@ def header_test_server(environ, start_response):
|
||||
|
||||
# ============================================================================
|
||||
def cookie_test_server(environ, start_response):
|
||||
body = 'cookie value: ' + environ.get('HTTP_COOKIE', '')
|
||||
body = 'cookie value:' + environ.get('HTTP_COOKIE', '')
|
||||
body = body.encode('utf-8')
|
||||
headers = [('Content-Length', str(len(body))),
|
||||
('Content-Type', 'text/plain')]
|
||||
@ -76,14 +76,14 @@ class TestLiveRewriter(HttpBinLiveTests, BaseConfigTest):
|
||||
resp = self.post('/live/{0}httpbin.org/post', fmod_sl, {'foo': 'bar', 'test': 'abc'})
|
||||
assert resp.status_int == 200
|
||||
resp.charset = 'utf-8'
|
||||
assert '"foo": "bar"' in resp.text
|
||||
assert '"test": "abc"' in resp.text
|
||||
assert '"foo":"bar"' in resp.text
|
||||
assert '"test":"abc"' in resp.text
|
||||
assert resp.status_int == 200
|
||||
|
||||
def test_live_anchor_encode(self, fmod_sl):
|
||||
resp = self.get('/live/{0}httpbin.org/get?val=abc%23%23xyz', fmod_sl)
|
||||
assert 'get?val=abc%23%23xyz"' in resp.text
|
||||
assert '"val": "abc##xyz"' in resp.text
|
||||
assert '"val":"abc##xyz"' in resp.text
|
||||
#assert '"http://httpbin.org/anything/abc##xyz"' in resp.text
|
||||
assert resp.status_int == 200
|
||||
|
||||
@ -125,18 +125,18 @@ class TestLiveRewriter(HttpBinLiveTests, BaseConfigTest):
|
||||
headers={'Host': 'example.com'})
|
||||
|
||||
assert resp.headers['Set-Cookie'] == 'testcookie=cookie-val; Path=/live/{0}http://localhost:{1}/'.format(fmod_sl, self.cookie_test_serv.port)
|
||||
assert resp.text == 'cookie value: '
|
||||
assert resp.text == 'cookie value:'
|
||||
|
||||
resp = self.get('/live/{0}http://localhost:%s/' % self.cookie_test_serv.port, fmod_sl,
|
||||
headers={'Host': 'example.com'})
|
||||
|
||||
assert resp.text == 'cookie value: testcookie=cookie-val'
|
||||
assert resp.text == 'cookie value:testcookie=cookie-val'
|
||||
|
||||
resp = self.get('/live/{0}http://localhost:%s/' % self.cookie_test_serv.port, fmod_sl,
|
||||
headers={'Host': 'sub.example.com'})
|
||||
|
||||
assert 'Set-Cookie' not in resp.headers
|
||||
assert resp.text == 'cookie value: testcookie=cookie-val'
|
||||
assert resp.text == 'cookie value:testcookie=cookie-val'
|
||||
|
||||
def test_fetch_page_with_html_title(self, fmod_sl):
|
||||
resp = self.get('/live/{0}http://localhost:%s/html-title' % self.header_test_serv.port, fmod_sl,
|
||||
@ -178,7 +178,7 @@ class TestLiveRewriter(HttpBinLiveTests, BaseConfigTest):
|
||||
|
||||
def test_deflate(self, fmod_sl):
|
||||
resp = self.get('/live/{0}http://httpbin.org/deflate', fmod_sl)
|
||||
assert b'"deflated": true' in resp.body
|
||||
assert b'"deflated":true' in resp.body
|
||||
|
||||
def test_live_origin_and_referrer(self, fmod_sl):
|
||||
headers = {'Referer': 'http://localhost:80/live/{0}http://example.com/test'.format(fmod_sl),
|
||||
|
@ -26,12 +26,12 @@ class TestRecordDedup(HttpBinLiveTests, CollsDirMixin, BaseConfigTest, FakeRedis
|
||||
|
||||
def test_record_1(self):
|
||||
res = self.testapp.get('/test-dedup/record/mp_/http://httpbin.org/get?A=B', headers={"Referer": "http://httpbin.org/"})
|
||||
assert '"A": "B"' in res.text
|
||||
assert '"A":"B"' in res.text
|
||||
|
||||
time.sleep(1.2)
|
||||
|
||||
res = self.testapp.get('/test-dedup/record/mp_/http://httpbin.org/get?A=B', headers={"Referer": "http://httpbin.org/"})
|
||||
assert '"A": "B"' in res.text
|
||||
assert '"A":"B"' in res.text
|
||||
|
||||
def test_single_redis_entry(self):
|
||||
res = self.redis.zrange("pywb:test-dedup:cdxj", 0, -1)
|
||||
|
@ -35,7 +35,7 @@ class TestRecordReplay(HttpBinLiveTests, CollsDirMixin, BaseConfigTest):
|
||||
|
||||
def test_record_1(self):
|
||||
res = self.testapp.get('/test/record/mp_/http://httpbin.org/get?A=B')
|
||||
assert '"A": "B"' in res.text
|
||||
assert '"A":"B"' in res.text
|
||||
|
||||
def test_record_head(self):
|
||||
res = self.testapp.head('/test/record/mp_/http://httpbin.org/get?A=B')
|
||||
@ -47,7 +47,7 @@ class TestRecordReplay(HttpBinLiveTests, CollsDirMixin, BaseConfigTest):
|
||||
|
||||
fmod_slash = fmod + '/' if fmod else ''
|
||||
res = self.get('/test/{0}http://httpbin.org/get?A=B', fmod_slash)
|
||||
assert '"A": "B"' in res.text
|
||||
assert '"A":"B"' in res.text
|
||||
|
||||
def test_replay_head(self, fmod):
|
||||
fmod_slash = fmod + '/' if fmod else ''
|
||||
@ -58,25 +58,25 @@ class TestRecordReplay(HttpBinLiveTests, CollsDirMixin, BaseConfigTest):
|
||||
|
||||
def test_record_2(self):
|
||||
res = self.testapp.get('/test2/record/mp_/http://httpbin.org/get?C=D')
|
||||
assert '"C": "D"' in res.text
|
||||
assert '"C":"D"' in res.text
|
||||
|
||||
def test_replay_2(self, fmod):
|
||||
self.ensure_empty()
|
||||
|
||||
fmod_slash = fmod + '/' if fmod else ''
|
||||
res = self.get('/test2/{0}http://httpbin.org/get?C=D', fmod_slash)
|
||||
assert '"C": "D"' in res.text
|
||||
assert '"C":"D"' in res.text
|
||||
|
||||
def test_record_again_1(self):
|
||||
res = self.testapp.get('/test/record/mp_/http://httpbin.org/get?C=D2')
|
||||
assert '"C": "D2"' in res.text
|
||||
assert '"C":"D2"' in res.text
|
||||
|
||||
def test_replay_again_1(self, fmod):
|
||||
self.ensure_empty()
|
||||
|
||||
fmod_slash = fmod + '/' if fmod else ''
|
||||
res = self.get('/test/{0}http://httpbin.org/get?C=D2', fmod_slash)
|
||||
assert '"C": "D2"' in res.text
|
||||
assert '"C":"D2"' in res.text
|
||||
|
||||
assert len(os.listdir(os.path.join(self.root_dir, '_test_colls', 'test', 'archive'))) == 1
|
||||
|
||||
@ -94,10 +94,10 @@ class TestRecordReplay(HttpBinLiveTests, CollsDirMixin, BaseConfigTest):
|
||||
fmod_slash = fmod + '/' if fmod else ''
|
||||
|
||||
res = self.get('/all/{0}http://httpbin.org/get?C=D', fmod_slash)
|
||||
assert '"C": "D"' in res.text
|
||||
assert '"C":"D"' in res.text
|
||||
|
||||
res = self.get('/all/mp_/http://httpbin.org/get?A=B', fmod_slash)
|
||||
assert '"A": "B"' in res.text
|
||||
assert '"A":"B"' in res.text
|
||||
|
||||
def test_cdx_all_coll(self):
|
||||
res = self.testapp.get('/all/cdx?url=http://httpbin.org/get*&output=json')
|
||||
@ -163,7 +163,7 @@ class TestRecordCustomConfig(HttpBinLiveTests, CollsDirMixin, BaseConfigTest):
|
||||
assert os.path.isdir(dir_name)
|
||||
|
||||
res = self.testapp.get('/test-new/record/mp_/http://httpbin.org/get?A=B')
|
||||
assert '"A": "B"' in res.text
|
||||
assert '"A":"B"' in res.text
|
||||
|
||||
names = os.listdir(dir_name)
|
||||
assert len(names) == 1
|
||||
@ -176,7 +176,7 @@ class TestRecordCustomConfig(HttpBinLiveTests, CollsDirMixin, BaseConfigTest):
|
||||
def test_no_brotli(self):
|
||||
res = self.testapp.get('/test-new/record/mp_/http://httpbin.org/get?C=D',
|
||||
headers={'Accept-Encoding': 'gzip, deflate, br'})
|
||||
assert '"C": "D"' in res.text
|
||||
assert '"C":"D"' in res.text
|
||||
|
||||
with open(self.warc_name, 'rb') as fh:
|
||||
for record in ArchiveIterator(fh):
|
||||
|
Loading…
x
Reference in New Issue
Block a user