def test_objecttype_feed_no_authors(self): original_feeds_format = feeds.FEEDS_FORMAT feeds.FEEDS_FORMAT = '' objecttype = self.create_published_objecttype() objecttype.authors.clear() feed = ObjecttypeFeed() self.assertEquals(feed.item_author_name(objecttype), None) feeds.FEEDS_FORMAT = original_feeds_format
def test_objecttype_feed(self): original_feeds_format = feeds.FEEDS_FORMAT feeds.FEEDS_FORMAT = '' objecttype = self.create_published_objecttype() feed = ObjecttypeFeed() self.assertEquals(feed.item_pubdate(objecttype), objecttype.creation_date) self.assertEquals(feed.item_metatypes(objecttype), [self.metatype.title]) self.assertEquals(feed.item_author_name(objecttype), self.author.username) self.assertEquals(feed.item_author_email(objecttype), self.author.email) self.assertEquals( feed.item_author_link(objecttype), 'http://example.com/authors/%s/' % self.author.username) # Test a NoReverseMatch for item_author_link self.author.username = '******' self.author.save() feed.item_author_name(objecttype) self.assertEquals(feed.item_author_link(objecttype), 'http://example.com') feeds.FEEDS_FORMAT = original_feeds_format
def test_objecttype_feed_enclosure(self): original_feeds_format = feeds.FEEDS_FORMAT feeds.FEEDS_FORMAT = '' objecttype = self.create_published_objecttype() feed = ObjecttypeFeed() self.assertEquals( feed.item_enclosure_url(objecttype), 'http://example.com/image.jpg') objecttype.content = 'My test content with image <img src="image.jpg" />', objecttype.save() self.assertEquals( feed.item_enclosure_url(objecttype), 'http://example.com/image.jpg') objecttype.content = 'My test content with image ' \ '<img src="http://test.com/image.jpg" />' objecttype.save() self.assertEquals( feed.item_enclosure_url(objecttype), 'http://test.com/image.jpg') objecttype.image = 'image_field.jpg' objecttype.save() self.assertEquals(feed.item_enclosure_url(objecttype), '%simage_field.jpg' % settings.MEDIA_URL) self.assertEquals(feed.item_enclosure_length(objecttype), '100000') self.assertEquals(feed.item_enclosure_mime_type(objecttype), 'image/jpeg') feeds.FEEDS_FORMAT = original_feeds_format