Skip to content

Commit

Permalink
httpbin adjustments
Browse files Browse the repository at this point in the history
Use the latest httpbin from psf/httpbin and adjust some json responses
since the formatting has changed slightly.
  • Loading branch information
edsu committed Sep 22, 2023
1 parent 5b72d96 commit 0bdc968
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
30 changes: 15 additions & 15 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 @@ -262,7 +262,7 @@ def test_record_skip_wrong_coll(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 All @@ -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 All @@ -542,7 +542,7 @@ def test_record_multiple_writes_rollover_idle(self):
'/get?goo=bar', '&param.recorder.coll=GOO')

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

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

Expand Down
6 changes: 3 additions & 3 deletions pywb/warcserver/test/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_live_resource(self):
assert resp.headers['Memento-Datetime'] != ''

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 'ResErrors' not in resp.headers

Expand All @@ -178,7 +178,7 @@ def test_live_post_resource(self):
assert resp.headers['Memento-Datetime'] != ''

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 'ResErrors' not in resp.headers

Expand Down Expand Up @@ -288,7 +288,7 @@ def test_agg_live_postreq(self):
assert resp.headers['Memento-Datetime'] != ''

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 json.loads(resp.headers['ResErrors']) == {"rhiz": "NotFoundException('https://webenact.rhizome.org/vvork/http://httpbin.org/get?foo=bar',)"}
assert "NotFoundException('https://webenact.rhizome.org/vvork/" in json.loads(resp.headers['ResErrors'])['rhiz']
Expand Down
2 changes: 1 addition & 1 deletion test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ urllib3
flask
ujson
lxml
httpbin @ git+https://github.com/aaronhmiller/httpbin.git
httpbin

0 comments on commit 0bdc968

Please sign in to comment.