Skip to content

Commit

Permalink
tests: add additional unit tests for progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
devfle committed Dec 31, 2022
1 parent 17df14a commit 00d7f9e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down

0 comments on commit 00d7f9e

Please sign in to comment.