Unittests for fetcher
This commit is contained in:
parent
69e9414742
commit
6c5b69a23d
@ -26,7 +26,7 @@ def download(url, proxies=[None]):
|
|||||||
associated content-type. Returns ``(None, None)`` if it was \
|
associated content-type. Returns ``(None, None)`` if it was \
|
||||||
unable to download the document.
|
unable to download the document.
|
||||||
|
|
||||||
# TODO: Unittests
|
>>> download("http://arxiv.org/pdf/1312.4006.pdf") # doctest: +SKIP
|
||||||
"""
|
"""
|
||||||
# Loop over all available connections
|
# Loop over all available connections
|
||||||
for proxy in proxies:
|
for proxy in proxies:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from . import identifiers
|
from . import identifiers
|
||||||
|
|
||||||
# TODO: Include tearpages
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"identifiers"
|
"identifiers",
|
||||||
|
"tearpages"
|
||||||
]
|
]
|
||||||
|
15
libbmc/tests/test_fetcher.py
Normal file
15
libbmc/tests/test_fetcher.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import unittest
|
||||||
|
from libbmc.fetcher import *
|
||||||
|
|
||||||
|
|
||||||
|
class TestFetcher(unittest.TestCase):
|
||||||
|
def test_download(self):
|
||||||
|
dl, contenttype = download('http://arxiv.org/pdf/1312.4006.pdf')
|
||||||
|
self.assertIn(contenttype, ['pdf', 'djvu'])
|
||||||
|
self.assertNotEqual(dl, '')
|
||||||
|
|
||||||
|
def test_download_invalid_type(self):
|
||||||
|
self.assertEqual(download('http://phyks.me/'), (None, None))
|
||||||
|
|
||||||
|
def test_download_invalid_url(self):
|
||||||
|
self.assertEqual(download('a'), (None, None))
|
Loading…
Reference in New Issue
Block a user