mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
rewrite_content: add a few tests for cs_, js_, remove redundant except
This commit is contained in:
parent
2600d870d7
commit
923421d637
@ -94,7 +94,7 @@ class RewriteContent:
|
||||
if isinstance(stream, ChunkedDataReader):
|
||||
stream.set_decomp('gzip')
|
||||
else:
|
||||
stream = DecompressingBufferedReader(stream, decomp_type='gzip')
|
||||
stream = DecompressingBufferedReader(stream)
|
||||
|
||||
if rewritten_headers.charset:
|
||||
encoding = rewritten_headers.charset
|
||||
@ -109,10 +109,7 @@ class RewriteContent:
|
||||
|
||||
rule = self.ruleset.get_first_match(urlkey)
|
||||
|
||||
try:
|
||||
rewriter_class = rule.rewriters[text_type]
|
||||
except KeyError:
|
||||
raise Exception('Unknown Text Type for Rewrite: ' + text_type)
|
||||
rewriter_class = rule.rewriters[text_type]
|
||||
|
||||
# for html, need to perform header insert, supply js, css, xml
|
||||
# rewriters
|
||||
|
@ -151,6 +151,17 @@ class TestWb:
|
||||
resp = self.testapp.get('/pywb/20140126200654/http://www.iana.org/_img/2013.1/rir-map.svg')
|
||||
assert resp.headers['Content-Length'] == str(len(resp.body))
|
||||
|
||||
def test_replay_css_mod(self):
|
||||
resp = self.testapp.get('/pywb/20140127171239cs_/http://www.iana.org/_css/2013.1/screen.css')
|
||||
assert resp.status_int == 200
|
||||
assert resp.content_type == 'text/css'
|
||||
|
||||
def test_replay_js_mod(self):
|
||||
# an empty js file
|
||||
resp = self.testapp.get('/pywb/20140126201054js_/http://www.iana.org/_js/2013.1/iana.js')
|
||||
assert resp.status_int == 200
|
||||
assert resp.content_length == 0
|
||||
assert resp.content_type == 'application/x-javascript'
|
||||
|
||||
def test_redirect_1(self):
|
||||
resp = self.testapp.get('/pywb/20140127171237/http://www.iana.org/')
|
||||
|
Loading…
x
Reference in New Issue
Block a user