Skip to content

Commit

Permalink
melhorando o teste da função add_event
Browse files Browse the repository at this point in the history
  • Loading branch information
welli7ngton committed Oct 9, 2023
1 parent f7d09b5 commit 6cc5ef5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions TDD/test_to_do_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,30 @@ class TestToDoList(unittest.TestCase):
# type checking tests
def test_if_title_is_an_str_instance_getting_an_assertion_error(self):
with self.assertRaises(Exception) as ex:
ToDoList.add_item(0, '11/11/1111', '00:00', None)
ToDoList.add_event(0, '11/11/1111', '00:00', None)
self.assertEqual(ex.exception.args[0], 'Title is not an str instance.')

def test_if_date_is_an_str_instance_getting_an_assertion_error(self):
with self.assertRaises(Exception) as ex:
ToDoList.add_item('title', 1, '00:00', None)
ToDoList.add_event('title', 1, '00:00', None)
self.assertEqual(ex.exception.args[0], 'Date is not an str instance.')

def test_if_time_is_an_str_instance_getting_an_assertion_error(self):
with self.assertRaises(Exception) as ex:
ToDoList.add_item('title', '11/11/1111', 0, None)
ToDoList.add_event('title', '11/11/1111', 0, None)
self.assertEqual(ex.exception.args[0], 'Time is not an str instance.')


def test_if_description_is_an_str_instance_or_none_value_getting_an_assertion_error(self):
with self.assertRaises(Exception) as ex:
ToDoList.add_item('title', '11/11/1111', '00:00', 0)
ToDoList.add_event('title', '11/11/1111', '00:00', 0)
self.assertEqual(ex.exception.args[0], 'Description is not an str instance or none value.')

def test_if_date_can_be_converted_to_datetime_with_strptime_function_raises_an_error(self):
def test__converting_str_to_date_function_getting_an_assertion_error(self):
with self.assertRaises(Exception) as ex:
self.assertEqual(ToDoList.add_item('test_item', '11|11|1111', '00:00', None), 'time data does not march with the default format.')
self.assertEqual(ToDoList.add_event('test_item', '1111/11/11', '00:00', None), 'Date does not match with the default format.')

def test_creating_a_dictionare_for_each_event(self):
self.assertTrue(isinstance(ToDoList.add_event('event test', '11/11/1111', '00:00', 'a test event'), dict))


if __name__ == '__main__':
Expand Down

0 comments on commit 6cc5ef5

Please sign in to comment.