예제 #1
0
 def test_save(self):
     event_to_save = Mock(date=datetime.today().date().isoformat())
     events_in_memory_repo = EventsInMemoryRepo()
     events_in_memory_repo.save(event_to_save)
     events_result = events_in_memory_repo.find_all()
     self.assertEqual(len(events_result.events), 9)
     events_result = events_in_memory_repo.get_from_date(datetime.today()\
                                                         .date().isoformat())
     self.assertEqual(len(events_result.events), 1)
예제 #2
0
 def test_save(self):
     event_to_save = Event(uuid='asdf', \
         date=datetime.today().date().isoformat(), \
         time=datetime.today().time().isoformat('seconds'), \
         event_type='entrada')
     events_in_memory_repo = EventsInMemoryRepo()
     saved = events_in_memory_repo.save(event_to_save)
     self.assertTrue(saved)
     events_results = events_in_memory_repo.find_all()
     self.assertEqual(len(events_results.events), 9)
     events = events_in_memory_repo.get_from_date(datetime.today().date()\
                                                  .isoformat())
     self.assertEqual(len(events.events), 1)
     event = events.events[0]
     self.assertEqual(event, event_to_save)
예제 #3
0
 def test_get_from_date_more_events(self):
     events_in_memory_repo = EventsInMemoryRepo()
     events_result = events_in_memory_repo.get_from_date('2019-10-15')
     self.assertEqual(len(events_result.events), 5)
예제 #4
0
 def test_get_from_date_one_event(self):
     event = Event('zxcv', '2019-10-16', '07:05:30', 'entrada')
     events = Events([event])
     events_in_memory_repo = EventsInMemoryRepo()
     events_result = events_in_memory_repo.get_from_date('2019-10-16')
     self.assertEqual(events_result, events)
예제 #5
0
 def test_get_from_date_more_events(self, events_mock, event_mock: Mock):
     events_in_memory_repo = EventsInMemoryRepo()
     events_in_memory_repo.get_from_date('2019-10-15')
     self.assertEqual(event_mock.call_count, 5)
     args, kwargs = events_mock.call_args
     self.assertEqual(len(args[0]), 5)
예제 #6
0
 def test_get_from_date_one_event(self, events_mock, event_mock):
     events_in_memory_repo = EventsInMemoryRepo()
     events_in_memory_repo.get_from_date('2019-10-16')
     event_mock.assert_called_once()
     args, kwargs = events_mock.call_args
     self.assertEqual(len(args[0]), 1)