Skip to content

Commit

Permalink
Spaces in test responses
Browse files Browse the repository at this point in the history
It seems like JSON in responses is now minimized without spaces? I'm not
sure what changed in the stack to do that.
  • Loading branch information
edsu committed Jun 29, 2023
1 parent e824ffd commit 5b72d96
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions tests/test_live_rewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down Expand Up @@ -76,14 +76,14 @@ def test_live_live_post(self, fmod_sl):
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

Expand Down Expand Up @@ -125,18 +125,18 @@ def test_domain_cookie(self, fmod_sl):
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,
Expand Down Expand Up @@ -178,7 +178,7 @@ def test_live_video_info(self):

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),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_record_dedup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def test_init_coll(self):

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)
Expand Down
20 changes: 10 additions & 10 deletions tests/test_record_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_init_coll(self):

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')
Expand All @@ -47,7 +47,7 @@ def test_replay_1(self, fmod):

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 ''
Expand All @@ -58,25 +58,25 @@ def test_replay_head(self, fmod):

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

Expand All @@ -94,10 +94,10 @@ def test_replay_all_coll(self, fmod):
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')
Expand Down Expand Up @@ -163,7 +163,7 @@ def test_init_and_rec(self):
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
Expand All @@ -176,7 +176,7 @@ def test_init_and_rec(self):
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):
Expand Down

0 comments on commit 5b72d96

Please sign in to comment.