def test_broken_get_items_calls(self): """Test that invalid calls to get_items doesn't fail. """ self.assertEqual( get_items(None, TestRequest(), 10), []) self.assertEqual( get_items('viewer', TestRequest(), 10), [])
def test_news_item_no_text_news_item_reference(self): """Test the NewsitemReference for a NewsItem """ # Publish news item so we see it. IPublicationWorkflow(self.root.news.testing).publish() version = self.root.news.testing.get_viewable() items = get_items(self.root.news.index, TestRequest(), 10) self.assertEqual(len(items), 1) item = items[0] self.assertTrue(verifyObject(INewsItemReference, item)) self.assertEqual(item.context, version) self.assertEqual(item.id(), 'testing') self.assertEqual(item.title(), 'Testing of a code source') self.assertEqual(item.description(), '') self.assertEqual(item.thumbnail(), '') self.assertEqual(item.thumbnail_url(), '') self.assertEqual(item.image_url(), '') # XXX Later empty introduction should return an empty string. self.assertEqual(item.introduction(), '<p></p>') self.assertEqual(item.link(), 'http://localhost/root/news/testing') self.assertEqual(item.creation_datetime(), version.get_display_datetime()) self.assertEqual(item.start_datetime(), None) self.assertEqual(item.end_datetime(), None) self.assertEqual(item.location(), None)
def test_agenda_item_news_item_reference(self): """Test specific implementation of NewsItemReference for AgendaItem. """ IPublicationWorkflow(self.root.news.debugging).publish() version = self.root.news.debugging.get_viewable() items = get_items(self.root.news.index, TestRequest(), 10) self.assertEqual(len(items), 1) item = items[0] self.assertTrue(verifyObject(INewsItemReference, item)) self.assertEqual(item.context, version) self.assertEqual(item.id(), 'debugging') self.assertEqual(item.title(), 'Debugging of a code source') self.assertEqual( item.start_datetime(), DateTime('2012/07/10 08:00:00 GMT+2')) self.assertEqual( item.end_datetime(), DateTime('2012/07/15 18:00:00 GMT+2')) self.assertEqual( item.location(), u'Rotterdam')
def test_news_item_with_text_news_item_reference(self): """Test the NewsitemReference for a NewsItem """ version = self.root.news.testing.get_editable() version.body.save( version, TestRequest(), u""" <h1>Testing of a code source</h1> <h2>Today is the day of the Internet!</h2> <h3>Yes it is</h3> <p> This the day of free internet ! The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite (often called TCP/IP, although not all applications use TCP) to serve billions of users worldwide. It is a network of networks that consists of millions of private, public, academic, business, and government networks, of local to global scope, that are linked by a broad array of electronic, wireless and optical networking technologies. The Internet carries an extensive range of information resources and services, such as the inter-linked hypertext documents of the World Wide Web (WWW) and the infrastructure to support email. </p> <div class="image"> <img src="foo" data-silva-reference="news" data-silva-target="%s" /> </div> <p> I am not kidding. </p> """ % (get_content_id(self.root.listing))) binding = getUtility(IMetadataService).getMetadata(version) binding.setValues( 'silva-extra', {'content_description': 'This is an exciting news item about the Interwebs.'}) # Publish news item so we see it. IPublicationWorkflow(self.root.news.testing).publish() version = self.root.news.testing.get_viewable() items = get_items(self.root.news.index, TestRequest(), 10) self.assertEqual(len(items), 1) item = items[0] self.assertTrue(verifyObject(INewsItemReference, item)) self.assertEqual(item.context, version) self.assertEqual(item.id(), 'testing') self.assertEqual( item.title(), 'Testing of a code source') self.assertEqual( item.description(), 'This is an exciting news item about the Interwebs.') self.assertEqual( item.description(10), 'This is an') self.assertEqual( item.thumbnail_url(), 'http://localhost/root/listing?thumbnail') self.assertEqual( item.image_url(), 'http://localhost/root/listing') tests.assertXMLEqual( item.thumbnail(), u"""<div class="inv_thumbnail"> <a class="newsitemthumbnaillink" href="http://localhost/root/news/testing"> <img src="http://localhost/root/listing?thumbnail" width="120" height="75" class="thumbnail" /> </a> </div>""") tests.assertXMLEqual( item.introduction(), u""" <p> This the day of free internet ! The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite (often called TCP/IP, although not all applications use TCP) to serve billions of users worldwide. It is a network of networks that consists of millions of private, public, academic, business, and government networks, of local to global scope, that are linked by a broad array of electronic, wireless and optical networking technologies. The Internet carries an extensive range of information resources and services, such as the inter-linked hypertext documents of the World Wide Web (WWW) and the infrastructure to support email. </p>""") tests.assertXMLEqual( item.introduction(128), u""" <p> This the day of free internet ! The Internet is a global system of interconnected computer networks that use the standard Inter… </p>""") self.assertEqual(item.link(), 'http://localhost/root/news/testing') self.assertEqual(item.start_datetime(), None) self.assertEqual(item.end_datetime(), None) self.assertEqual(item.location(), None)