class TestNewsMLSyndicationFeedAdapter(NewsMLBaseSyndicationTest):

    layer = INTEGRATION_TESTING

    def afterSetUp(self):
        super(TestNewsMLSyndicationFeedAdapter, self).afterSetUp()

        self.feed = INewsMLFeed(self.folder)
        self.feeddatnews1 = BaseNewsMLItem(self.news1, self.feed)
        self.feeddatnews2 = BaseNewsMLItem(self.news2, self.feed)

    def test_items(self):
        self.assertEqual(len(self.feed._brains()), 5)
        self.assertEqual(len([i for i in self.feed.items]), 2)

    def test_filter_body(self):
        output = '<p>Test text</p><p>Header</p><p>New Line</p><a href="http://www.google.com">Google</a><ul><li>one</li><li>two</li></ul><ul><li>one</li><li>two</li></ul>'
        self.assertEqual(self.feeddatnews1.body, output)
        output = '<p>Test text</p><p>Header</p><p>New Line</p><a href="http://www.google.com">Google</a><ul><li>one</li><li>two</li></ul><ul><li>one</li><li>two</li></ul>'
        self.assertEqual(self.feeddatnews2.body, output)

    def test_image_caption(self):
        self.news1.image = "Image"

        self.assertEqual(self.feeddatnews1.image_caption, "")

        self.news1.setDescription("News description")
        self.assertEqual(self.feeddatnews1.image_caption, "News description")

        self.news1.imageCaption = "Image caption"
        self.assertEqual(self.feeddatnews1.image_caption, "Image caption")

    def test_created_date(self):
        self.assertEqual(self.feeddatnews1.created, self.news1.created())
    def afterSetUp(self):
        super(TestNewsMLSyndicationFeedAdapter, self).afterSetUp()

        self.feed = INewsMLFeed(self.folder)
        self.feeddatnews1 = BaseNewsMLItem(self.news1, self.feed)
        self.feeddatnews2 = BaseNewsMLItem(self.news2, self.feed)