From 00d7f9e6d10050b4d39235bbe7b039522f4f0720 Mon Sep 17 00:00:00 2001 From: devfle <52854338+devfle@users.noreply.github.com> Date: Sat, 31 Dec 2022 14:55:17 +0000 Subject: [PATCH] tests: add additional unit tests for progress bar --- tests/test_main.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index a07a869..779921d 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -11,12 +11,32 @@ class TestDrawProgressBar(unittest.TestCase): """Tests the DrawProgressBar function""" @patch.dict(os.environ, {'INPUT_PROGRESS_BAR_CHAR_LENGTH': '30', - 'INPUT_EMPTY_BAR': '░', 'INPUT_FILLED_BAR': '█'}) + 'INPUT_EMPTY_BAR': '░', 'INPUT_FILLED_BAR': '█'}, clear=True) def test_draw_progress_bar(self): """Tests drawing the progress bar""" + progress_bar: str = draw_progress_bar(20) expected_progress_bar: str = "██████░░░░░░░░░░░░░░░░░░░░░░░░" + self.assertEqual(progress_bar, expected_progress_bar) + + progress_bar: str = draw_progress_bar(20.25) + self.assertEqual(progress_bar, expected_progress_bar) + + progress_bar: str = draw_progress_bar(100) + expected_progress_bar: str = "██████████████████████████████" + self.assertEqual(progress_bar, expected_progress_bar) + + progress_bar: str = draw_progress_bar(200) + self.assertEqual(progress_bar, expected_progress_bar) + + progress_bar: str = draw_progress_bar(0) + expected_progress_bar: str = "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░" + self.assertEqual(progress_bar, expected_progress_bar) + + progress_bar: str = draw_progress_bar(-10) + self.assertEqual(progress_bar, expected_progress_bar) + progress_bar: str = draw_progress_bar(-0) self.assertEqual(progress_bar, expected_progress_bar) if __name__ == '__main__':