-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_working.py
26 lines (24 loc) · 977 Bytes
/
test_working.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from working import convert
import pytest
def test_convert_positive():
assert convert("9:00 AM to 5:00 PM") == "09:00 to 17:00"
assert convert("9 AM to 5 PM") == "09:00 to 17:00"
assert convert("10:30 PM to 8:50 AM") == "22:30 to 08:50"
assert convert("10 PM to 8 AM") == "22:00 to 08:00"
assert convert("12:00 PM to 12:00 AM") == "12:00 to 00:00"
assert convert("12:00 AM to 12:00 PM") == "00:00 to 12:00"
def test_convert_negative():
with pytest.raises(ValueError):
convert("9:60 AM to 5:60 PM")
with pytest.raises(ValueError):
convert("9:60 AM to 5:00 PM")
with pytest.raises(ValueError):
convert("13:00 PM to 5:00 PM")
with pytest.raises(ValueError):
convert("9 AM - 5 PM")
with pytest.raises(ValueError):
convert("09:00 AM - 17:00 PM")
with pytest.raises(ValueError):
convert("Invalid time format")
with pytest.raises(ValueError):
convert("Missing time period")