diff --git a/test/test_icalevents.py b/test/test_icalevents.py index 341c912..884f924 100644 --- a/test/test_icalevents.py +++ b/test/test_icalevents.py @@ -12,17 +12,18 @@ class ICalEventsTests(unittest.TestCase): @pook.on def test_utf8_events_url(self): + url = "https://raw.githubusercontent.com/jazzband/icalevents/master/test/test_data/basic.ics" + with open("test/test_data/basic.ics", "rb") as file: body = file.read() pook.get( - "https://raw.githubusercontent.com/jazzband/icalevents/master/test/test_data/basic.ics", + url, reply=200, response_headers={"Content-Type": "text/calendar; charset=UTF-8"}, response_body=body, ) - url = "https://raw.githubusercontent.com/jazzband/icalevents/master/test/test_data/basic.ics" start = date(2017, 5, 18) end = date(2017, 5, 19) @@ -32,17 +33,18 @@ def test_utf8_events_url(self): @pook.on def test_latin1_events_url(self): + url = "https://raw.githubusercontent.com/jazzband/icalevents/master/test/test_data/basic_latin1.ics" + with open("test/test_data/basic_latin1.ics", "rb") as file: body = file.read() pook.get( - "https://raw.githubusercontent.com/jazzband/icalevents/master/test/test_data/basic_latin1.ics", + url, reply=200, response_headers={"Content-Type": "text/calendar; charset=ISO-8859-1"}, response_body=body, ) - url = "https://raw.githubusercontent.com/jazzband/icalevents/master/test/test_data/basic_latin1.ics" start = date(2017, 5, 18) end = date(2017, 5, 19) @@ -50,6 +52,17 @@ def test_latin1_events_url(self): self.assertEqual(len(events), 2, "two events are found") + @pook.on + def test_exception_on_empty_events_url(self): + url = "https://raw.githubusercontent.com/jazzband/icalevents/master/test/test_data/basic.ics" + + pook.get( + url, + reply=500, + ) + + self.assertRaises(ConnectionError, icalevents.events, url=url) + def test_events_start(self): ical = "test/test_data/basic.ics" start = date(2017, 5, 16)