Skip to content

Commit

Permalink
Revert spacing changes for older 3.7-supporting werkzeug
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed Apr 1, 2024
1 parent b51c0bb commit 3b554fb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
26 changes: 13 additions & 13 deletions pywb/recorder/test/test_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_record_warc_1(self):

resp = self._test_warc_write(recorder_app, 'httpbin.org', '/get?foo=bar')
assert b'HTTP/1.1 200 OK' in resp.body
assert b'"foo":"bar"' in resp.body
assert b'"foo": "bar"' in resp.body

self._test_all_warcs('/warcs/', 1)

Expand All @@ -160,7 +160,7 @@ def test_record_warc_2(self):

resp = self._test_warc_write(recorder_app, 'httpbin.org', '/get?foo=bar')
assert b'HTTP/1.1 200 OK' in resp.body
assert b'"foo":"bar"' in resp.body
assert b'"foo": "bar"' in resp.body

self._test_all_warcs('/warcs/', 2)

Expand Down Expand Up @@ -279,7 +279,7 @@ def test_record_param_user_coll(self):
resp = self._test_warc_write(recorder_app, 'httpbin.org', '/user-agent',
'&param.recorder.user=USER&param.recorder.coll=COLL')

assert '"user-agent":"{0}"'.format(UA) in resp.text
assert '"user-agent": "{0}"'.format(UA) in resp.text
#assert b'HTTP/1.1 200 OK' in resp.body
#assert b'"foo": "bar"' in resp.body

Expand Down Expand Up @@ -312,12 +312,12 @@ def test_record_param_user_coll_same_dir(self):
resp = self._test_warc_write(recorder_app, 'httpbin.org',
'/get?foo=bar', '&param.recorder.user=USER2&param.recorder.coll=COLL2')
assert b'HTTP/1.1 200 OK' in resp.body
assert b'"foo":"bar"' in resp.body
assert b'"foo": "bar"' in resp.body

resp = self._test_warc_write(recorder_app, 'httpbin.org',
'/get?foo=bar', '&param.recorder.user=USER2&param.recorder.coll=COLL3')
assert b'HTTP/1.1 200 OK' in resp.body
assert b'"foo":"bar"' in resp.body
assert b'"foo": "bar"' in resp.body

self._test_all_warcs('/warcs2', 2)

Expand All @@ -334,7 +334,7 @@ def test_record_param_user_coll_revisit(self):
resp = self._test_warc_write(recorder_app, 'httpbin.org', '/user-agent',
'&param.recorder.user=USER&param.recorder.coll=COLL')

assert '"user-agent":"{0}"'.format(UA) in resp.text
assert '"user-agent": "{0}"'.format(UA) in resp.text
#assert b'HTTP/1.1 200 OK' in resp.body
#assert b'"foo": "bar"' in resp.body

Expand Down Expand Up @@ -387,7 +387,7 @@ def test_record_param_user_coll_skip(self):
resp = self._test_warc_write(recorder_app, 'httpbin.org', '/user-agent',
'&param.recorder.user=USER&param.recorder.coll=COLL')

assert '"user-agent":"{0}"'.format(UA) in resp.text
assert '"user-agent": "{0}"'.format(UA) in resp.text
#assert b'HTTP/1.1 200 OK' in resp.body
#assert b'"foo": "bar"' in resp.body
self._test_all_warcs('/warcs/USER/COLL/', 2)
Expand All @@ -409,7 +409,7 @@ def test_record_param_user_coll_write_dupe_no_revisit(self):
resp = self._test_warc_write(recorder_app, 'httpbin.org',
'/get?foo=bar', '&param.recorder.user=USER&param.recorder.coll=COLL')
assert b'HTTP/1.1 200 OK' in resp.body
assert b'"foo":"bar"' in resp.body
assert b'"foo": "bar"' in resp.body

self._test_all_warcs('/warcs/USER/COLL/', 3)

Expand All @@ -432,7 +432,7 @@ def test_record_file_warc_keep_open(self):

resp = self._test_warc_write(recorder_app, 'httpbin.org', '/get?foo=bar')
assert b'HTTP/1.1 200 OK' in resp.body
assert b'"foo":"bar"' in resp.body
assert b'"foo": "bar"' in resp.body

assert os.path.isfile(path)
assert len(writer.fh_cache) == 1
Expand All @@ -455,15 +455,15 @@ def test_record_multiple_writes_keep_open(self):
'/get?foo=bar', '&param.recorder.coll=FOO')

assert b'HTTP/1.1 200 OK' in resp.body
assert b'"foo":"bar"' in resp.body
assert b'"foo": "bar"' in resp.body


# Second Record
resp = self._test_warc_write(recorder_app, 'httpbin.org',
'/get?boo=far', '&param.recorder.coll=FOO')

assert b'HTTP/1.1 200 OK' in resp.body
assert b'"boo":"far"' in resp.body
assert b'"boo": "far"' in resp.body

self._test_all_warcs('/warcs/FOO/', 1)

Expand Down Expand Up @@ -523,14 +523,14 @@ def test_record_multiple_writes_rollover_idle(self):
'/get?foo=bar', '&param.recorder.coll=GOO')

assert b'HTTP/1.1 200 OK' in resp.body
assert b'"foo":"bar"' in resp.body
assert b'"foo": "bar"' in resp.body

# Second Record
resp = self._test_warc_write(recorder_app, 'httpbin.org',
'/get?boo=far', '&param.recorder.coll=GOO')

assert b'HTTP/1.1 200 OK' in resp.body
assert b'"boo":"far"' in resp.body
assert b'"boo": "far"' in resp.body

self._test_all_warcs('/warcs/GOO/', 1)

Expand Down
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 @@ -128,18 +128,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 @@ -181,7 +181,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 3b554fb

Please sign in to comment.