def test_getting_homepage(self): req = self.rf.get('/yay/') page = mommy.make(Page, is_homepage=True) with self.assertNumQueries(1): result = get_homepage(request=req) self.assertIn('HOMEPAGE', result) self.assertIsNotNone(result['HOMEPAGE']) self.assertEqual(page, result['HOMEPAGE'])
def test_admin_prevents_putting_into_context(self): admin_index = reverse('admin:index') req = self.rf.get('{admin}/some/other/app/'.format(admin=admin_index)) mommy.make(Page, is_homepage=True) with self.assertNumQueries(0): result = get_homepage(request=req) self.assertIn('HOMEPAGE', result) self.assertIsNone(result['HOMEPAGE'])
def test_getting_nonexistant_homepage_when_developing(self): req = self.rf.get('/yay/') with self.assertNumQueries(1): with self.assertRaises(ObjectDoesNotExist): get_homepage(request=req)
def test_getting_nonexistant_homepage(self): req = self.rf.get('/yay/') with self.assertNumQueries(1): result = get_homepage(request=req) self.assertIn('HOMEPAGE', result) self.assertIsNone(result['HOMEPAGE'])