class GetFrontpageDocumentsTestCase(TestCase): """Tests for the ``get_frontpage_documents`` templatetag.""" longMessage = True def setUp(self): super(GetFrontpageDocumentsTestCase, self).setUp() # Two documents that should be on the front page self.en_doc = DocumentFactory( language_code='en', is_published=True, is_on_front_page=True) self.de_doc = self.en_doc.translate('de') self.de_doc.is_published = True self.de_doc.save() # And one that should not be on the front page DocumentFactory() def test_tag(self): req = RequestFactory().get('/') req.LANGUAGE_CODE = 'en' context = RequestContext(req) result = tags.get_frontpage_documents(context) self.assertEqual(result.count(), 1, msg=( 'It should only return one document.')) self.assertEqual(result[0], self.en_doc, msg=( 'Should return the one english document that has' ' is_on_fron_page=True')) req.LANGUAGE_CODE = 'de' context = RequestContext(req) result = tags.get_frontpage_documents(context) self.assertEqual(result.count(), 1, msg=( 'It should only return one document.')) self.assertEqual(result[0], self.de_doc, msg=( 'Should return the one german document that has' ' is_on_fron_page=True'))
def setUp(self): super(GetFrontpageDocumentsTestCase, self).setUp() # Two documents that should be on the front page self.en_doc = DocumentFactory( language_code='en', is_published=True, is_on_front_page=True) self.de_doc = self.en_doc.translate('de') self.de_doc.is_published = True self.de_doc.save() # And one that should not be on the front page DocumentFactory()