def test_import_calendar_dates_txt(self): calendar_dates_txt = StringIO.StringIO("""\ service_id,date,exception_type S1,20120414,2 """) ServiceDate.import_txt(calendar_dates_txt, self.feed) service_date = ServiceDate.objects.get() self.assertEqual(service_date.date, date(2012, 4, 14)) self.assertEqual(service_date.service, self.service) self.assertEqual(service_date.exception_type, 2)
def test_import_calendar_dates_txt(self): calendar_dates_txt = StringIO("""\ service_id,date,exception_type S1,20120414,2 """) ServiceDate.import_txt(calendar_dates_txt, self.feed) service_date = ServiceDate.objects.get() self.assertEqual(service_date.date, date(2012, 4, 14)) self.assertEqual(service_date.service, self.service) self.assertEqual(service_date.exception_type, 2)
def test_export_calendar_dates_txt(self): ServiceDate.objects.create( date=date(2012, 8, 31), service=self.service, exception_type=2) ServiceDate.objects.create( date=date(2012, 9, 1), service=self.service, exception_type=1) cdates_txt = ServiceDate.export_txt(self.feed) self.assertEqual(cdates_txt, """\ service_id,date,exception_type S1,20120831,2 S1,20120901,1 """)
def test_export_calendar_dates_txt(self): ServiceDate.objects.create(date=date(2012, 8, 31), service=self.service, exception_type=2) ServiceDate.objects.create(date=date(2012, 9, 1), service=self.service, exception_type=1) cdates_txt = ServiceDate.export_txt(self.feed) self.assertEqual( cdates_txt, """\ service_id,date,exception_type S1,20120831,2 S1,20120901,1 """)
def test_export_calendar_dates_txt_none(self): cdates_txt = ServiceDate.export_txt(self.feed) self.assertFalse(cdates_txt)