-
Notifications
You must be signed in to change notification settings - Fork 0
/
CalendarTestDeleteEvents.py
40 lines (29 loc) · 1.12 KB
/
CalendarTestDeleteEvents.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import unittest
from unittest.mock import Mock, patch
import Calendar
# NOTE: ALL THE TESTS HERE ARE FOR THE delete_events METHOD IN Calendar.py
# Test Strategy : Branch Coverage
class CalendarTestDeleteEvents(unittest.TestCase):
@patch("Calendar.get_calendar_api")
def test_none_event_id(self, api):
event = None
with self.assertRaises(TypeError):
Calendar.delete_events(api, event)
@patch("Calendar.get_calendar_api")
def test_empty_event_id(self, api):
event = {}
with self.assertRaises(ValueError):
Calendar.delete_events(api, event)
event = {}
with self.assertRaises(ValueError):
Calendar.delete_events(api, event)
def test_events_deleted(self):
api = Mock()
event = {"id": "test123"}
Calendar.delete_events(api, event)
self.assertEqual(api.events.return_value.delete.return_value.execute.call_count, 1)
def main():
suite = unittest.TestLoader().loadTestsFromTestCase(CalendarTestDeleteEvents)
# This will run the test suite.
unittest.TextTestRunner(verbosity=2).run(suite)
main()