forked from MIT-Emerging-Talent/ET6-practice-code-review
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Delete solutions/tests/test_Time_Conversion.py"
This reverts commit 3eb1709.
- Loading branch information
1 parent
6d6d843
commit 9ff0f66
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
""" | ||
Test module for Time Conversion function. | ||
Contains intentionally buggy tests for debugging practice. | ||
Created on 2024-01-09 | ||
Author: Safaa Osman | ||
""" | ||
|
||
import unittest | ||
from ..Time_Conversion import Time_Conversion | ||
|
||
|
||
class TestTimeConversion(unittest.TestCase): | ||
"""Test suite for the Time Conversion function""" | ||
|
||
def test_equal_minutes_hours(self): | ||
"""It should return the time conversion properly""" | ||
self.assertEqual(Time_Conversion("12:12"), "20:12") | ||
|
||
def test_regular_time(self): | ||
"""It should return the time conversion properly""" | ||
self.assertEqual(Time_Conversion("08:00"), "16:00") | ||
|
||
# Boundary cases | ||
|
||
def test_minimum_time(self): | ||
"""It should return the time conversion properly""" | ||
self.assertEqual(Time_Conversion("00:00"), "08:00") | ||
|
||
def test_maximum_time(self): | ||
"""It should return the time conversion properly""" | ||
self.assertEqual(Time_Conversion("23:59"), "07:59") | ||
|
||
# Defensive cases | ||
|
||
def test_not_string(self): | ||
"""It should raise AssertionError for input not string""" | ||
with self.assertRaises(AssertionError): | ||
Time_Conversion(1230) | ||
|
||
def test_hours_out_of_range(self): | ||
"""It should raise ValueError for hours are out of range""" | ||
with self.assertRaises(ValueError): | ||
Time_Conversion("25:30") | ||
|
||
def test_minutes_out_of_range(self): | ||
"""It should raise ValueError for minutes are out of range""" | ||
with self.assertRaises(ValueError): | ||
Time_Conversion("12:69") | ||
|
||
def test_empty_string(self): | ||
"""It should raise AssertionError for string is empty""" | ||
with self.assertRaises(AssertionError): | ||
Time_Conversion("") | ||
|
||
def test_mix_types(self): | ||
"""It should raise AssertionError for string is mix types""" | ||
with self.assertRaises(AssertionError): | ||
Time_Conversion("hg:45") | ||
|
||
def test_invalid_minutes(self): | ||
"""It should raise ValueError for minutes are out of range""" | ||
with self.assertRaises(ValueError): | ||
Time_Conversion("00:60") | ||
|
||
def test_invalid_hours(self): | ||
"""It should raise ValueError for minutes are out of range""" | ||
with self.assertRaises(ValueError): | ||
Time_Conversion("24:00") |