Beispiel #1
0
 def test_entry_feed_enclosure(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEquals(feed.item_enclosure_url(entry),
                       'http://example.com/image.jpg')
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     entry.content = 'My test content with image <img src="image.jpg" />'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry),
                       'http://example.com/image.jpg')
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     entry.content = 'My test content with image ' \
                     '<img src="http://test.com/image.jpg" />'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry),
                       'http://test.com/image.jpg')
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     path = default_storage.save('enclosure.png', ContentFile('Content'))
     entry.image = path
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry),
                       urljoin('http://example.com', entry.image.url))
     self.assertEquals(feed.item_enclosure_length(entry), '7')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/png')
     default_storage.delete(path)
     entry.image = 'invalid_image_without_extension'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry),
                       urljoin('http://example.com', entry.image.url))
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
Beispiel #2
0
 def test_entry_feed_enclosure(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEquals(
         feed.item_enclosure_url(entry), 'http://example.com/image.jpg')
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     entry.content = 'My test content with image <img src="image.jpg" />'
     entry.save()
     self.assertEquals(
         feed.item_enclosure_url(entry), 'http://example.com/image.jpg')
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     entry.content = 'My test content with image ' \
                     '<img src="http://test.com/image.jpg" />'
     entry.save()
     self.assertEquals(
         feed.item_enclosure_url(entry), 'http://test.com/image.jpg')
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     path = default_storage.save('enclosure.png', ContentFile('Content'))
     entry.image = path
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry),
                       urljoin('http://example.com', entry.image.url))
     self.assertEquals(feed.item_enclosure_length(entry), '7')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/png')
     default_storage.delete(path)
     entry.image = 'invalid_image_without_extension'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry),
                       urljoin('http://example.com', entry.image.url))
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
Beispiel #3
0
 def test_entry_feed_enclosure(self):
     original_feeds_format = feeds.FEEDS_FORMAT
     feeds.FEEDS_FORMAT = ''
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEquals(
         feed.item_enclosure_url(entry), 'http://example.com/image.jpg')
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     entry.content = 'My test content with image <img src="image.jpg" />'
     entry.save()
     self.assertEquals(
         feed.item_enclosure_url(entry), 'http://example.com/image.jpg')
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     entry.content = 'My test content with image ' \
                     '<img src="http://test.com/image.jpg" />'
     entry.save()
     self.assertEquals(
         feed.item_enclosure_url(entry), 'http://test.com/image.jpg')
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     entry.image = 'image_field.png'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry),
                       urljoin('http://example.com', entry.image.url))
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/png')
     entry.image = 'image_without_extension'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry),
                       urljoin('http://example.com', entry.image.url))
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     feeds.FEEDS_FORMAT = original_feeds_format
 def test_entry_feed_enclosure(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEqual(feed.item_enclosure_url(entry), "http://example.com/image.jpg")
     self.assertEqual(feed.item_enclosure_length(entry), "100000")
     self.assertEqual(feed.item_enclosure_mime_type(entry), "image/jpeg")
     entry.content = 'My test content with image <img src="image.jpg" />'
     entry.save()
     self.assertEqual(feed.item_enclosure_url(entry), "http://example.com/image.jpg")
     self.assertEqual(feed.item_enclosure_length(entry), "100000")
     self.assertEqual(feed.item_enclosure_mime_type(entry), "image/jpeg")
     entry.content = "My test content with image " '<img src="http://test.com/image.jpg" />'
     entry.save()
     self.assertEqual(feed.item_enclosure_url(entry), "http://test.com/image.jpg")
     self.assertEqual(feed.item_enclosure_length(entry), "100000")
     self.assertEqual(feed.item_enclosure_mime_type(entry), "image/jpeg")
     path = default_storage.save("enclosure.png", ContentFile("Content"))
     entry.image = path
     entry.save()
     self.assertEqual(feed.item_enclosure_url(entry), urljoin("http://example.com", entry.image.url))
     self.assertEqual(feed.item_enclosure_length(entry), "7")
     self.assertEqual(feed.item_enclosure_mime_type(entry), "image/png")
     default_storage.delete(path)
     entry.image = "invalid_image_without_extension"
     entry.save()
     self.assertEqual(feed.item_enclosure_url(entry), urljoin("http://example.com", entry.image.url))
     self.assertEqual(feed.item_enclosure_length(entry), "100000")
     self.assertEqual(feed.item_enclosure_mime_type(entry), "image/jpeg")
 def test_feed_entry(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEquals(feed.item_pubdate(entry), entry.creation_date)
     self.assertEquals(feed.item_categories(entry), [self.category.title])
     self.assertEquals(feed.item_author_name(entry), self.author.username)
     self.assertEquals(feed.item_author_email(entry), self.author.email)
     self.assertEquals(feed.item_author_link(entry),
                       'http://example.com/authors/%s/' % self.author.username)
     self.assertEquals(feed.item_enclosure_url(entry), 'http://example.com/image.jpg')
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
Beispiel #6
0
 def test_feed_entry(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEquals(feed.item_pubdate(entry), entry.creation_date)
     self.assertEquals(feed.item_categories(entry), [self.category.title])
     self.assertEquals(feed.item_author_name(entry), self.author.username)
     self.assertEquals(feed.item_author_email(entry), self.author.email)
     self.assertEquals(
         feed.item_author_link(entry),
         'http://example.com/authors/%s/' % self.author.username)
     self.assertEquals(feed.item_enclosure_url(entry),
                       'http://example.com/image.jpg')
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
Beispiel #7
0
 def test_entry_feed_enclosure(self):
     original_feeds_format = feeds.FEEDS_FORMAT
     feeds.FEEDS_FORMAT = ""
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEquals(feed.item_enclosure_url(entry), "http://example.com/image.jpg")
     entry.content = 'My test content with image <img src="image.jpg" />'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry), "http://example.com/image.jpg")
     entry.content = "My test content with image " '<img src="http://test.com/image.jpg" />'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry), "http://test.com/image.jpg")
     entry.image = "image_field.jpg"
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry), urljoin("http://example.com", entry.image.url))
     self.assertEquals(feed.item_enclosure_length(entry), "100000")
     self.assertEquals(feed.item_enclosure_mime_type(entry), "image/jpeg")
     feeds.FEEDS_FORMAT = original_feeds_format
Beispiel #8
0
 def test_entry_feed_enclosure(self):
     original_feeds_format = feeds.FEEDS_FORMAT
     feeds.FEEDS_FORMAT = ''
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEquals(feed.item_enclosure_url(entry), 'http://example.com/image.jpg')
     entry.content = 'My test content with image <img src="image.jpg" />',
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry), 'http://example.com/image.jpg')
     entry.content = 'My test content with image <img src="http://test.com/image.jpg" />',
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry), 'http://test.com/image.jpg')
     entry.image = 'image_field.jpg'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry),
                       '%simage_field.jpg' % settings.MEDIA_URL)
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     feeds.FEEDS_FORMAT = original_feeds_format
Beispiel #9
0
 def test_entry_feed_enclosure(self):
     original_feeds_format = feeds.FEEDS_FORMAT
     feeds.FEEDS_FORMAT = ''
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEquals(feed.item_enclosure_url(entry), 'http://example.com/image.jpg')
     entry.content = 'My test content with image <img src="image.jpg" />',
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry), 'http://example.com/image.jpg')
     entry.content = 'My test content with image <img src="http://test.com/image.jpg" />',
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry), 'http://test.com/image.jpg')
     entry.image = 'image_field.jpg'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry),
                       '%simage_field.jpg' % settings.MEDIA_URL)
     self.assertEquals(feed.item_enclosure_length(entry), '100000')
     self.assertEquals(feed.item_enclosure_mime_type(entry), 'image/jpeg')
     feeds.FEEDS_FORMAT = original_feeds_format