Testing/utils (#548)

* New unittest for utils.py

Unit test fetch in basic ways. Would have tested more fetches, but
downloading stuff for tests is annoying and mocking is more
dependencies.

* Remove unused imports
This commit is contained in:
Lucas Keller
2023-02-10 12:08:20 -06:00
committed by GitHub
parent 1257b0433a
commit 56a06280c5
2 changed files with 16 additions and 1 deletions

15
test/test_utils.py Normal file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env python
import unittest
from extra.utils import fetch
class TestUtils(unittest.TestCase):
def test_fetch_bad_http(self):
self.assertRaises(AssertionError, fetch, 'http://httpstat.us/500')
self.assertRaises(AssertionError, fetch, 'http://httpstat.us/404')
self.assertRaises(AssertionError, fetch, 'http://httpstat.us/400')
def test_fetch_small(self):
assert(len(fetch('https://google.com'))>0)
if __name__ == '__main__':
unittest.main()