def test_save_session(self): session = Session(None) session.parsed_data = { 'event_id': '111', 'place_id': '222', 'start': timezone.now(), 'finish': timezone.now(), } session.save(self.parser_info) self.assertEqual(ScheduledEvent.objects.all().count(), 1)
def test_parse_session(self): string = ''' <session date="2015-10-11" event="93959" place="12549" time="19:00"/> ''' elt = etree.fromstring(string) session = Session(elt) session.parse() parsed = session.parsed_data self.assertEqual(parsed['event_id'], '93959') self.assertEqual(parsed['place_id'], '12549') start = parsed['start'] self.assertTupleEqual( (start.year, start.month, start.day, start.hour, start.minute), (2015, 10, 11, 19, 0) ) self.assertEqual(parsed['finish'], None)