diff --git a/libbmc/fetcher.py b/libbmc/fetcher.py index e6ff516..f7473e4 100644 --- a/libbmc/fetcher.py +++ b/libbmc/fetcher.py @@ -26,7 +26,7 @@ def download(url, proxies=[None]): associated content-type. Returns ``(None, None)`` if it was \ unable to download the document. - # TODO: Unittests + >>> download("http://arxiv.org/pdf/1312.4006.pdf") # doctest: +SKIP """ # Loop over all available connections for proxy in proxies: diff --git a/libbmc/papers/__init__.py b/libbmc/papers/__init__.py index 7ba1b1f..047cc01 100644 --- a/libbmc/papers/__init__.py +++ b/libbmc/papers/__init__.py @@ -1,7 +1,6 @@ from . import identifiers -# TODO: Include tearpages - __all__ = [ - "identifiers" + "identifiers", + "tearpages" ] diff --git a/libbmc/tests/test_fetcher.py b/libbmc/tests/test_fetcher.py new file mode 100644 index 0000000..746d03a --- /dev/null +++ b/libbmc/tests/test_fetcher.py @@ -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))