Skip to content

Commit

Permalink
Simplified rss feed parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
bsuryadevara committed Jan 5, 2024
1 parent c8f95a1 commit 2af66b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion morpheus/controllers/rss_controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
13 changes: 5 additions & 8 deletions tests/controllers/test_rss_controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -21,7 +21,6 @@
import feedparser
import pandas as pd
import pytest
import requests

from _utils import TEST_DIRS
from morpheus.controllers.rss_controller import FeedStats
Expand Down Expand Up @@ -83,9 +82,8 @@ def test_parse_feed_valid_url(feed_input: list[str], mock_feed: feedparser.FeedP
controller = RSSController(feed_input=feed_input)

mock_feedparser_parse = patch("morpheus.controllers.rss_controller.feedparser.parse")
mock_get = patch.object(requests.Session, 'get')
with mock_feedparser_parse, mock_get:
mock_get.return_value = mock_get_response

with mock_feedparser_parse, patch("requests.Session.get", return_value=mock_get_response):
mock_feedparser_parse.return_value = mock_feed
feed = list(controller.parse_feeds())[0]
assert feed.entries
Expand Down Expand Up @@ -123,9 +121,8 @@ def test_fetch_dataframes_url(feed_input: str | list[str],
controller = RSSController(feed_input=feed_input)

mock_feedparser_parse = patch("morpheus.controllers.rss_controller.feedparser.parse")
mock_get = patch.object(requests.Session, 'get')
with mock_feedparser_parse, mock_get:
mock_get.return_value = mock_get_response

with mock_feedparser_parse, patch("requests.Session.get", return_value=mock_get_response):
mock_feedparser_parse.return_value = mock_feed
dataframes_generator = controller.fetch_dataframes()
dataframe = next(dataframes_generator, None)
Expand Down

0 comments on commit 2af66b3

Please sign in to comment.