Exemple #1
0
    def test_back_reference(self):
        # Create some feeds
        feed_url1 = 'https://www.my-feeds.com/'
        feed_url2 = 'https://www.my-feeds2.com/'
        feed_url3 = 'https://www.my-feeds3.com/'

        feed_dict1 = make_fake_feedparser_dict(feed_url1)
        feed_dict2 = make_fake_feedparser_dict(feed_url2)
        feed_dict3 = make_fake_feedparser_dict(feed_url3)

        feed1 = None
        feed2 = None
        feed3 = None
        with patch('feeds.models.fetch_feedparser_dict') as mock_feed:
            mock_feed.side_effect = [feed_dict1, feed_dict2, feed_dict3]
            feed1 = Feed.objects.create(link=feed_url1)
            feed2 = Feed.objects.create(link=feed_url2)
            feed3 = Feed.objects.create(link=feed_url3)

        # Create an entry and assign to feeds 1 and 2
        entry = Entry.objects.create()
        feed1.entries.add(entry)
        feed2.entries.add(entry)

        self.assertEqual(entry.feeds.count(), 2)
        self.assertIn(feed1, entry.feeds.all())
        self.assertIn(feed2, entry.feeds.all())
        self.assertNotIn(feed3, entry.feeds.all())
Exemple #2
0
    def setUp(self):
        # Create a feed
        self.feed_url = 'https://www.my-feeds.com/'
        self.total_entries = 30
        self.feed_dict = make_fake_feedparser_dict(feed_url=self.feed_url,
                                                   n_items=self.total_entries)
        self.feed = None
        with patch('feeds.models.fetch_feedparser_dict') as mock_feed:
            mock_feed.return_value = self.feed_dict
            self.feed = Feed.objects.create(link=self.feed_url)

        # Create list of processed entries
        self.parsed_entries = make_preprocessed_entries_list(
            n_items=self.total_entries, feed_url=self.feed_url)
Exemple #3
0
    def setUp(self):
        self.feed_url = 'https://www.samplefeeds.com/rss'  # fake URL

        # Create and set a valid FeedParserDict object
        # to be used or overridden in the tests
        self.feedparser_dict = make_fake_feedparser_dict(self.feed_url)

        # Patch the fetch_feedparser_dict utility function
        patcher = patch('feeds.models.fetch_feedparser_dict',
                        return_value=self.feedparser_dict)
        self.mock_fetch_feedparser_dict = patcher.start()

        # To ensure patch gets cleaned up during tearDown:
        self.addCleanup(patcher.stop)
 def setUp(self):
     self.feed_url = 'https://www.rssfeedstoday.com'
     self.feedparser_dict = make_fake_feedparser_dict(self.feed_url)
     self.feed_entries_list = self.feedparser_dict.entries
     self.entry_item = self.feed_entries_list[0]  # get a sample item
    def setUp(self):
        self.feed_url = 'https://www.samplefeeds.com/rss'  # fake URL

        # Create and set a valid FeedParserDict object
        # to be used or overridden in the tests
        self.feedparser_dict = make_fake_feedparser_dict(self.feed_url)