def test_default_timetable_no_public_timetable(self): site = mommy.make(Site, domain=self.server_name) timetable = mommy.make('timetable.Timetable', public=False) timetable_site = mommy.make('timetable.TimetableSite', default=True, timetable=timetable, site=site) request = self.request_factory.get("/", SERVER_NAME=self.server_name) with self.assertRaises(IndexError): default_timetable(request) site.delete()
def test_default_timetable_normal(self): site = mommy.make(Site, domain=self.server_name) timetable = mommy.make('timetable.Timetable', public=True) timetable_site = mommy.make('timetable.TimetableSite', default=True, timetable=timetable, site=site) request = self.request_factory.get("/", SERVER_NAME=self.server_name) self.assertEqual(default_timetable(request), timetable, "The default timetable is not the right one") site.delete()
def test_default_timetable_multiple(self): # Get the one that starts later site = mommy.make(Site, domain=self.server_name) timetable1 = mommy.make('timetable.Timetable', public=True, start=datetime.now()) timetable2 = mommy.make('timetable.Timetable', public=True, start=datetime.now() + timedelta(123456)) timetable_site = mommy.make('timetable.TimetableSite', default=True, timetable=timetable1, site=site) timetable_site = mommy.make('timetable.TimetableSite', default=True, timetable=timetable2, site=site) request = self.request_factory.get("/", SERVER_NAME=self.server_name) self.assertEqual(default_timetable(request), timetable2, "The default timetable is not the right one") site.delete()
def main_redirect(request): timetable = default_timetable(request) return _main_redirect_helper(request, timetable.slug)
def test_default_timetable_no_timetable_site(self): site = mommy.make(Site, domain=self.server_name) request = self.request_factory.get("/", SERVER_NAME=self.server_name) with self.assertRaises(IndexError): default_timetable(request) site.delete()
def test_default_timetable_no_site(self): request = self.request_factory.get("/", SERVER_NAME="koala.lumpur.si") with self.assertRaises(Site.DoesNotExist): default_timetable(request)