Example #1
0
    def test_parse_for_invalid_url(self, _, value):
        # Given: an empty RSS feed URL to be parsed
        obj_under_test = RssUrlParser(value)

        # When: the URL is parsed
        with self.assertRaises(RssParserError) as error:
            obj_under_test.parse()
        self.assertIn("Error parsing for URL", str(error.exception))
Example #2
0
    def test_parse_for_invalid_rss_channel(self, _, value, mock_response):
        # Given: an RSS feed URL to be parsed
        url = "https://www.fiercewireless.com/rss/xml"
        obj_under_test = RssUrlParser(url)
        mock_response.return_value = value

        # When: the URL is parsed
        with self.assertRaises(RssParserError) as error:
            obj_under_test.parse()
        self.assertIn("Invalid RSS channel data", error.exception.message)
Example #3
0
def fetch_content_for_feed_url(rss_feed_url):
    """
    Returns the feed content for a provided RSS feed url.
    :param rss_feed_url:
    :return:
    """
    feed_content = "No RSS feed content to display"
    rss_url_parser = RssUrlParser(rss_feed_url)
    try:
        feed_content = rss_url_parser.parse()
    except RssParserError as error:
        print(error.message)
    return feed_content
Example #4
0
    def test_parse_rss_dataset_1(self, mock_response):
        # Given: an RSS feed URL to be parsed
        url = "https://www.fiercewireless.com/rss/xml"
        obj_under_test = RssUrlParser(url)

        file_reader = JsonFileReader(TESTDATA_FILENAME_1)
        mock_response.return_value = file_reader.read()

        # When: the URL is parsed
        feed_content = obj_under_test.parse()

        # Then: the channel details are returned
        self.assertIn("FierceWireless", feed_content)

        # And: the Item details are returned
        self.assertIn("Industry Voices", feed_content)
        self.assertIn("Stefan Pongratz", feed_content)
Example #5
0
    def test_parse_rss_dataset_2(self, mock_response):
        # Given: an RSS feed URL to be parsed
        url = "https://martinfowler.com/feed.atom"
        obj_under_test = RssUrlParser(url)

        file_reader = JsonFileReader(TESTDATA_FILENAME_2)
        mock_response.return_value = file_reader.read()

        # When: the URL is parsed
        feed_content = obj_under_test.parse()

        # Then: the channel details are returned
        self.assertIn("Martin Fowler", feed_content)

        # And: the Item details are returned
        self.assertIn("Reviewed Commits", feed_content)
        self.assertIn("Comparing Feature Branching and Continuous Integration",
                      feed_content)
Example #6
0
    def test_parse_rss_with_no_entries(self, mock_response):
        # Given: an RSS feed URL to be parsed
        url = "https://www.fiercewireless.com/rss/xml"
        obj_under_test = RssUrlParser(url)
        mock_response.return_value = {
            "feed": {
                "title": "FierceWireless",
                "link": "some link",
                "description": "blah"
            },
            "entries": []
        }
        # When: the URL is parsed
        feed_content = obj_under_test.parse()

        # Then: the channel details are returned
        self.assertIn("FierceWireless", feed_content)

        # And: the Item details are empty
        self.assertIn("RSS feed is empty", feed_content)