Esempio n. 1
0
 def test_entry_feed_enclosure_issue_134(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     entry.content = 'My test content with image <img xsrc="image.jpg" />'
     entry.save()
     self.assertEqual(
         feed.item_enclosure_url(entry), None)
Esempio n. 2
0
 def test_entry_feed_enclosure_issue_134(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     entry.content = 'My test content with image <img xsrc="image.jpg" />'
     entry.save()
     self.assertEquals(
         feed.item_enclosure_url(entry), None)
Esempio n. 3
0
 def test_entry_feed_enclosure_without_image(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     entry.content = 'My test content without image '
     entry.save()
     self.assertEqual(
         feed.item_enclosure_url(entry), None)
Esempio n. 4
0
 def test_entry_feed_no_authors(self):
     original_feeds_format = feeds.FEEDS_FORMAT
     feeds.FEEDS_FORMAT = ''
     entry = self.create_published_entry()
     entry.authors.clear()
     feed = EntryFeed()
     self.assertEquals(feed.item_author_name(entry), None)
     feeds.FEEDS_FORMAT = original_feeds_format
Esempio n. 5
0
 def test_entry_feed_no_authors(self):
     original_feeds_format = feeds.FEEDS_FORMAT
     feeds.FEEDS_FORMAT = ''
     entry = self.create_published_entry()
     entry.authors.clear()
     feed = EntryFeed()
     self.assertEquals(feed.item_author_name(entry), None)
     feeds.FEEDS_FORMAT = original_feeds_format
Esempio n. 6
0
 def test_entry_feed_enclosure_issue_134(self):
     original_feeds_format = feeds.FEEDS_FORMAT
     feeds.FEEDS_FORMAT = ""
     entry = self.create_published_entry()
     feed = EntryFeed()
     entry.content = 'My test content with image <img xsrc="image.jpg" />'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry), None)
     feeds.FEEDS_FORMAT = original_feeds_format
Esempio n. 7
0
 def test_entry_feed_enclosure_issue_134(self):
     original_feeds_format = feeds.FEEDS_FORMAT
     feeds.FEEDS_FORMAT = ''
     entry = self.create_published_entry()
     feed = EntryFeed()
     entry.content = 'My test content with image <img xsrc="image.jpg" />'
     entry.save()
     self.assertEquals(feed.item_enclosure_url(entry), None)
     feeds.FEEDS_FORMAT = original_feeds_format
Esempio n. 8
0
 def test_entry_feed_enclosure_replace_https_in_rss(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     entry.content = 'My test content with image in https ' \
                     '<img src="https://test.com/image.jpg" />'
     entry.save()
     self.assertEqual(feed.item_enclosure_url(entry),
                      'http://test.com/image.jpg')
     feed.protocol = 'https'
     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')
     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))
     original_feed_format = LastEntries.feed_format
     LastEntries.feed_format = 'atom'
     feed = LastEntries()
     feed.protocol = 'https'
     self.assertEqual(feed.item_enclosure_url(entry),
                      urljoin('https://example.com', entry.image.url))
     LastEntries.feed_format = original_feed_format
     default_storage.delete(path)
Esempio n. 9
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')
Esempio n. 10
0
 def test_entry_feed_enclosure_replace_https_in_rss(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     entry.content = 'My test content with image in https ' \
                     '<img src="https://test.com/image.jpg" />'
     entry.save()
     self.assertEqual(
         feed.item_enclosure_url(entry), 'http://test.com/image.jpg')
     feed.protocol = 'https'
     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')
     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))
     original_feed_format = LastEntries.feed_format
     LastEntries.feed_format = 'atom'
     feed = LastEntries()
     feed.protocol = 'https'
     self.assertEqual(feed.item_enclosure_url(entry),
                      urljoin('https://example.com', entry.image.url))
     LastEntries.feed_format = original_feed_format
     default_storage.delete(path)
Esempio n. 11
0
 def test_entry_feed(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEqual(feed.item_pubdate(entry), entry.creation_date)
     self.assertEqual(feed.item_categories(entry), [self.category.title])
     self.assertEqual(feed.item_author_name(entry), self.author.__str__())
     self.assertEqual(feed.item_author_email(entry), self.author.email)
     self.assertEqual(
         feed.item_author_link(entry),
         '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(entry)
     self.assertEqual(feed.item_author_link(entry), 'http://example.com')
Esempio n. 12
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')
Esempio n. 13
0
 def test_entry_feed(self):
     original_feeds_format = feeds.FEEDS_FORMAT
     feeds.FEEDS_FORMAT = ''
     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.author.username = '******'  # Test a NoReverseMatch for item_author_link
     self.author.save()
     feed.item_author_name(entry)
     self.assertEquals(feed.item_author_link(entry), 'http://example.com')
     feeds.FEEDS_FORMAT = original_feeds_format
Esempio n. 14
0
 def test_entry_feed(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEqual(feed.item_pubdate(entry), entry.creation_date)
     self.assertEqual(feed.item_categories(entry), [self.category.title])
     self.assertEqual(feed.item_author_name(entry), six.text_type(self.author))
     self.assertEqual(feed.item_author_email(entry), self.author.email)
     self.assertEqual(feed.item_author_link(entry), "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(entry)
     self.assertEqual(feed.item_author_link(entry), "http://example.com")
Esempio n. 15
0
 def test_entry_feed(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     self.assertEqual(feed.item_pubdate(entry), entry.publication_date)
     self.assertEqual(feed.item_updateddate(entry), entry.last_update)
     self.assertEqual(feed.item_categories(entry), [self.category.title])
     self.assertEqual(feed.item_author_name(entry),
                      self.author.__str__())
     self.assertEqual(feed.item_author_email(entry), self.author.email)
     self.assertEqual(
         feed.item_author_link(entry),
         '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(entry)
     self.assertEqual(feed.item_author_link(entry), 'http://example.com')
Esempio n. 16
0
 def test_entry_feed(self):
     original_feeds_format = feeds.FEEDS_FORMAT
     feeds.FEEDS_FORMAT = ""
     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)
     # Test a NoReverseMatch for item_author_link
     self.author.username = "******"
     self.author.save()
     feed.item_author_name(entry)
     self.assertEquals(feed.item_author_link(entry), "http://example.com")
     feeds.FEEDS_FORMAT = original_feeds_format
Esempio n. 17
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
Esempio n. 18
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
Esempio n. 19
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
Esempio n. 20
0
 def test_entry_feed_no_authors(self):
     entry = self.create_published_entry()
     entry.authors.clear()
     feed = EntryFeed()
     self.assertEquals(feed.item_author_name(entry), None)
Esempio n. 21
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')
Esempio n. 22
0
 def test_entry_feed_no_authors(self):
     entry = self.create_published_entry()
     entry.authors.clear()
     feed = EntryFeed()
     self.assertEquals(feed.item_author_name(entry), None)
Esempio n. 23
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')
Esempio n. 24
0
 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")
Esempio n. 25
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