Unittests for fetcher

This commit is contained in:
Lucas Verney 2016-01-30 16:51:30 +01:00
parent 69e9414742
commit 6c5b69a23d
3 changed files with 18 additions and 4 deletions

View File

@ -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:

View File

@ -1,7 +1,6 @@
from . import identifiers from . import identifiers
# TODO: Include tearpages
__all__ = [ __all__ = [
"identifiers" "identifiers",
"tearpages"
] ]

View 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))