mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
tests: zipnum: better test coverage for incorrect idx or loc files, add invalid sample files zipnum-bad{.idx, .loc}, #112
This commit is contained in:
parent
2b9e1b97c3
commit
27212488e3
@ -142,6 +142,22 @@ org,iana)/time-zones 20140126200737 zipnum 9631 166 38
|
|||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
NotFoundException: No Captures found for: http://aaa.zz/ (domain query)
|
NotFoundException: No Captures found for: http://aaa.zz/ (domain query)
|
||||||
|
|
||||||
|
# Invalid .idx filesor or missing loc
|
||||||
|
|
||||||
|
>>> zip_test_err(url='http://example.com/', matchType='exact')
|
||||||
|
Traceback (most recent call last):
|
||||||
|
Exception: No Locations Found for: foo
|
||||||
|
|
||||||
|
|
||||||
|
>>> zip_test_err(url='http://iana.org/x', matchType='exact')
|
||||||
|
Traceback (most recent call last):
|
||||||
|
IOError: [Errno 2] No such file or directory: './sample_archive/invalid'
|
||||||
|
|
||||||
|
|
||||||
|
>>> zip_test_err(url='http://example.zz/x', matchType='exact')
|
||||||
|
Traceback (most recent call last):
|
||||||
|
Exception: No Locations Found for: foo2
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from test_cdxops import cdx_ops_test
|
from test_cdxops import cdx_ops_test
|
||||||
@ -161,6 +177,10 @@ def zip_ops_test(url, **kwargs):
|
|||||||
sources = test_zipnum
|
sources = test_zipnum
|
||||||
cdx_ops_test(url, sources, **kwargs)
|
cdx_ops_test(url, sources, **kwargs)
|
||||||
|
|
||||||
|
def zip_test_err(url, **kwargs):
|
||||||
|
sources = get_test_dir() + 'zipcdx/zipnum-bad.idx'
|
||||||
|
cdx_ops_test(url, sources, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def test_zip_prefix_load():
|
def test_zip_prefix_load():
|
||||||
|
|
||||||
|
@ -290,6 +290,11 @@ class ZipNumCluster(CDXSource):
|
|||||||
last_exc = None
|
last_exc = None
|
||||||
last_traceback = None
|
last_traceback = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
locations = self.loc_resolver(blocks.part, query)
|
||||||
|
except:
|
||||||
|
raise Exception('No Locations Found for: ' + blocks.part)
|
||||||
|
|
||||||
for location in self.loc_resolver(blocks.part, query):
|
for location in self.loc_resolver(blocks.part, query):
|
||||||
try:
|
try:
|
||||||
return self.load_blocks(location, blocks, ranges, query)
|
return self.load_blocks(location, blocks, ranges, query)
|
||||||
@ -299,9 +304,9 @@ class ZipNumCluster(CDXSource):
|
|||||||
last_traceback = sys.exc_info()[2]
|
last_traceback = sys.exc_info()[2]
|
||||||
|
|
||||||
if last_exc:
|
if last_exc:
|
||||||
raise exc, None, last_traceback
|
raise last_exc, None, last_traceback
|
||||||
else:
|
else:
|
||||||
raise Exception('No Locations Found for: ' + block.part)
|
raise Exception('No Locations Found for: ' + blocks.part)
|
||||||
|
|
||||||
def load_blocks(self, location, blocks, ranges, query):
|
def load_blocks(self, location, blocks, ranges, query):
|
||||||
""" Load one or more blocks of compressed cdx lines, return
|
""" Load one or more blocks of compressed cdx lines, return
|
||||||
|
3
sample_archive/zipcdx/zipnum-bad.idx
Normal file
3
sample_archive/zipcdx/zipnum-bad.idx
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
com,example)/ 20140127171200 foo 0 275 1
|
||||||
|
org,iana)/ 20140127171238 bar 275 328 2
|
||||||
|
zz,example)/ 20140127171238 foo2 275 328 2
|
3
sample_archive/zipcdx/zipnum-bad.loc
Normal file
3
sample_archive/zipcdx/zipnum-bad.loc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
bar ./sample_archive/invalid
|
||||||
|
foo2
|
||||||
|
zipnum ./sample_archive/x-bad-path-to-ignore-x ./sample_archive/zipcdx/zipnum-sample.cdx.gz
|
Loading…
x
Reference in New Issue
Block a user