From e063138585afc1c8c5e6407101733b8102a8e954 Mon Sep 17 00:00:00 2001 From: Nate Marti Date: Wed, 24 Apr 2024 18:23:20 +0100 Subject: [PATCH] add some utils tests --- .coverage | Bin 53248 -> 53248 bytes tests/test_utils.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/.coverage b/.coverage index a388473b38455acb2306df93a633bbcb81eb114b..0a97323eb8ad86af9814d0d81f40ea1210abded6 100644 GIT binary patch delta 77 zcmV-T0J8sppaX!Q1F!~w0kD$?fFuF1vk?%43?3X31OW*;629f#_kG`cZ`=0X_wMbz j_a5GMySd-pv(Ai}0S!NYw*C3H2Vmpg2y79vbdHQcGSnr% delta 74 zcmV-Q0JZ;spaX!Q1F!~w0ke|_fFuF4vk?%73>z5|1OW*&625u&ec$)q+qQl0-rjrf g;m!T-2D8qLnE?#}1A+h;5C8xHKmY&`vviJ(L17vldH?_b diff --git a/tests/test_utils.py b/tests/test_utils.py index 1724d98d..0b9d09fe 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -7,6 +7,8 @@ import config import utils +URLOBJ = utils.UrlProps('http://ip.me') + class TestUtils(unittest.TestCase): def test_check_logos_release_version_false(self): @@ -71,6 +73,16 @@ def test_file_exists_none(self): def test_file_exists_true(self): self.assertTrue(utils.file_exists('~/.bashrc')) + def test_fileprops_get_size(self): + f = Path(__file__).parent / 'data' / 'config_empty.json' + fo = utils.FileProps(f) + self.assertEqual(fo.size, 4) + + def test_fileprops_get_md5(self): + f = Path(__file__).parent / 'data' / 'config_empty.json' + fo = utils.FileProps(f) + self.assertEqual(fo.get_md5(), 'W3aw7vmviiMAZz4FU/YJ+Q==') + def test_filter_versions(self): allvers = ['1.0', '1.1', '1.2', '1.3', '1.4', '1.5'] valvers = ['1.0', '1.1', '1.2', '1.3',] @@ -130,6 +142,23 @@ def test_get_winebincode_system(self): def test_have_lib(self): self.assertTrue(utils.have_lib('libgcc', None)) + def test_urlprops_get_headers(self): + self.assertIsNotNone(URLOBJ.headers) + + def test_urlprops_get_headers_none(self): + urlobj = utils.UrlProps() + self.assertIsNone(urlobj.headers) + + def test_urlprops_get_size(self): + self.assertIsNotNone(URLOBJ.size) + + def test_urlprops_get_size_none(self): + urlobj = utils.UrlProps() + self.assertIsNone(urlobj.size) + + def test_urlprops_get_md5(self): + self.assertIsNone(URLOBJ.md5) + class TestUtilsConfigFile(unittest.TestCase): def setUp(self):