fix: add back news rss comps#10069
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds two new data components: NewsSearchComponent for Google News RSS-based searches and RSSReaderComponent for generic RSS fetching/parsing. Introduces corresponding unit tests validating success, empty, error, and missing-field scenarios. Components perform HTTP GET, parse XML with BeautifulSoup, and return DataFrames with standardized columns. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as Caller
participant NS as NewsSearchComponent
participant GN as Google News RSS
participant BS as XML Parser (BeautifulSoup)
U->>NS: search_news()
alt topic/location/query provided
NS->>NS: Build RSS URL (topic/location/keyword)
NS->>GN: HTTP GET (timeout)
alt HTTP OK
NS->>BS: Parse XML content
BS-->>NS: Items [title, link, pubDate, description]
alt Items found
NS-->>U: DataFrame[title, link, published, summary]
else No items
NS-->>U: DataFrame[{"title":"No articles found", ...}]
end
else Request/Parse error
NS-->>U: DataFrame[{"title":"Error", "summary": error}]
end
else no search parameter
NS-->>U: DataFrame[{"title":"Error", "summary":"No search parameter"}]
end
sequenceDiagram
autonumber
participant U as Caller
participant RSS as RSSReaderComponent
participant SRC as RSS Source
participant BS as XML Parser (BeautifulSoup)
U->>RSS: read_rss(rss_url, timeout)
RSS->>SRC: HTTP GET (timeout)
alt HTTP OK
RSS->>BS: Parse XML content
alt Valid XML with items
BS-->>RSS: Items [title, link, pubDate, description]
RSS-->>U: DataFrame[title, link, published, summary]
else No/invalid items
RSS-->>U: DataFrame[0 rows or error row per implementation]
end
else Request error
RSS-->>U: DataFrame[{"title":"Error", "summary": error}]
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (6 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (10)
src/lfx/src/lfx/components/data/rss.py (3)
47-52: Eliminate redundant XML parsing.The XML is parsed twice: once for validation (line 48) and again for extraction (line 52). This is inefficient and adds unnecessary overhead.
Apply this diff to remove the redundant validation parse:
- # Check if the response is valid XML - try: - BeautifulSoup(response.content, "xml") - except Exception as e: - msg = f"Invalid XML response: {e}" - raise ValueError(msg) from e soup = BeautifulSoup(response.content, "xml") + if soup is None: + msg = "Invalid XML response" + raise ValueError(msg) items = soup.find_all("item")
28-34: Validate timeout input range.The timeout input accepts any integer, but negative or zero values would cause issues with
requests.get.Consider adding validation in the
read_rssmethod:def read_rss(self) -> DataFrame: + if self.timeout <= 0: + self.status = "Timeout must be positive" + return DataFrame(pd.DataFrame([{"title": "Error", "link": "", "published": "", "summary": "Invalid timeout value"}])) try:
41-41: Consider adding URL validation.The component accepts any string as
rss_urlwithout validation. Malformed URLs will fail at request time, but early validation could provide better error messages.You could add basic URL validation before making the request:
from urllib.parse import urlparse # In read_rss(): parsed = urlparse(self.rss_url) if not parsed.scheme or not parsed.netloc: self.status = "Invalid RSS URL" return DataFrame(pd.DataFrame([{"title": "Error", "link": "", "published": "", "summary": "Invalid URL format"}]))src/backend/tests/unit/components/data/test_rss.py (1)
29-129: Consider adding tests for invalid XML and empty content.The component has specific handling for invalid XML (lines 47-51 in rss.py) and empty response content (lines 43-45), but these paths aren't tested.
Add these test cases:
def test_invalid_xml_response(self): """Test handling of non-XML response content.""" mock_response = Mock() mock_response.content = b"Not XML content" mock_response.raise_for_status = Mock() with patch("lfx.components.data.rss.requests.get", return_value=mock_response): component = RSSReaderComponent(rss_url="https://example.com/feed.xml") result = component.read_rss() assert isinstance(result, DataFrame) assert len(result) == 1 assert result.iloc[0]["title"] == "Error" assert "Invalid XML" in result.iloc[0]["summary"] def test_empty_response_content(self): """Test handling of empty response.""" mock_response = Mock() mock_response.content = b" " # Only whitespace mock_response.raise_for_status = Mock() with patch("lfx.components.data.rss.requests.get", return_value=mock_response): component = RSSReaderComponent(rss_url="https://example.com/feed.xml") result = component.read_rss() assert isinstance(result, DataFrame) assert len(result) == 1 assert result.iloc[0]["title"] == "Error" assert "Empty response" in result.iloc[0]["summary"]src/backend/tests/unit/components/data/test_news_search.py (2)
24-88: Add test coverage for missing input scenario.The component handles the case where no query, topic, or location is provided (lines 115-129 in news_search.py), but this isn't tested.
Add this test:
def test_no_search_parameters(self): """Test handling when no query, topic, or location is provided.""" component = NewsSearchComponent() result = component.search_news() assert isinstance(result, DataFrame) assert len(result) == 1 assert result.iloc[0]["title"] == "Error" assert "No search query, topic, or location provided" in result.iloc[0]["summary"]
24-88: Consider testing HTML cleaning functionality.The component uses
clean_html()on titles and summaries (lines 153, 156 in news_search.py), but tests don't verify HTML stripping works correctly.Add a test with HTML in the RSS content:
def test_html_cleaning_in_results(self): """Test that HTML tags are stripped from titles and summaries.""" mock_rss_content = """ <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <channel> <item> <title><b>Bold Title</b></title> <link>https://example.com/1</link> <pubDate>2024-03-20</pubDate> <description><p>HTML <em>content</em></p></description> </item> </channel> </rss> """ mock_response = Mock() mock_response.content = mock_rss_content.encode("utf-8") mock_response.raise_for_status = Mock() with patch("lfx.components.data.news_search.requests.get", return_value=mock_response): component = NewsSearchComponent(query="test") result = component.search_news() assert "<b>" not in result.iloc[0]["title"] assert "<p>" not in result.iloc[0]["summary"] assert "Bold Title" in result.iloc[0]["title"] assert "HTML content" in result.iloc[0]["summary"]src/lfx/src/lfx/components/data/news_search.py (4)
92-92: Fix potential IndexError when splitting language code.If
hlis a simple language code like"en"(without hyphen),hl.split('-')[0]works, but the logic assumes a hyphen exists. Whilesplitwon't fail, this could create unexpectedceidvalues.Apply this diff to handle both cases:
- ceid = getattr(self, "ceid", None) or f"{gl}:{hl.split('-')[0]}" + ceid = getattr(self, "ceid", None) or f"{gl}:{hl.split('-')[0] if '-' in hl else hl}"
111-112: Simplify redundant list wrapping and join.Creating a single-element list then joining it is unnecessary.
Apply this diff:
- query_parts = [query] - query_encoded = quote_plus(" ".join(query_parts)) + query_encoded = quote_plus(query)
166-167: Code duplication:clean_htmlduplicated across components.This method is identical to the one in
src/lfx/src/lfx/components/data/web_search.py(lines 149-151). Since both RSS/News components are legacy and will be replaced by WebSearch, this duplication is acceptable for now, but consider extracting to a shared utility if this pattern continues.Based on relevant code snippets showing the same method in web_search.py.
131-143: Consider adding XML validation like RSSReaderComponent.
RSSReaderComponentvalidates the XML response and checks for empty content (lines 43-51 in rss.py), butNewsSearchComponentdoesn't. This could lead to less informative error messages for malformed responses.Consider adding similar validation:
try: response = requests.get(rss_url, timeout=self.timeout) response.raise_for_status() + if not response.content.strip(): + msg = "Empty response received" + raise ValueError(msg) soup = BeautifulSoup(response.content, "xml") items = soup.find_all("item")
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/backend/tests/unit/components/data/test_news_search.py(1 hunks)src/backend/tests/unit/components/data/test_rss.py(1 hunks)src/lfx/src/lfx/components/data/news_search.py(1 hunks)src/lfx/src/lfx/components/data/rss.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
src/backend/tests/unit/components/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
src/backend/tests/unit/components/**/*.py: Mirror the component directory structure for unit tests in src/backend/tests/unit/components/
Use ComponentTestBaseWithClient or ComponentTestBaseWithoutClient as base classes for component unit tests
Provide file_names_mapping for backward compatibility in component tests
Create comprehensive unit tests for all new components
Files:
src/backend/tests/unit/components/data/test_news_search.pysrc/backend/tests/unit/components/data/test_rss.py
{src/backend/**/*.py,tests/**/*.py,Makefile}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code
Files:
src/backend/tests/unit/components/data/test_news_search.pysrc/backend/tests/unit/components/data/test_rss.py
src/backend/tests/unit/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Files:
src/backend/tests/unit/components/data/test_news_search.pysrc/backend/tests/unit/components/data/test_rss.py
src/backend/tests/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
src/backend/tests/**/*.py: Unit tests for backend code must be located in the 'src/backend/tests/' directory, with component tests organized by component subdirectory under 'src/backend/tests/unit/components/'.
Test files should use the same filename as the component under test, with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
Use the 'client' fixture (an async httpx.AsyncClient) for API tests in backend Python tests, as defined in 'src/backend/tests/conftest.py'.
When writing component tests, inherit from the appropriate base class in 'src/backend/tests/base.py' (ComponentTestBase, ComponentTestBaseWithClient, or ComponentTestBaseWithoutClient) and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping'.
Each test in backend Python test files should have a clear docstring explaining its purpose, and complex setups or mocks should be well-commented.
Test both sync and async code paths in backend Python tests, using '@pytest.mark.asyncio' for async tests.
Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.
Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.
Validate input/output behavior and test component initialization and configuration in backend Python tests.
Use the 'no_blockbuster' pytest marker to skip the blockbuster plugin in tests when necessary.
Be aware of ContextVar propagation in async tests; test both direct event loop execution and 'asyncio.to_thread' scenarios to ensure proper context isolation.
Test error handling by mocking internal functions using monkeypatch in backend Python tests.
Test resource cleanup in backend Python tests by using fixtures that ensure proper initialization and cleanup of resources.
Test timeout and performance constraints in backend Python tests using 'asyncio.wait_for' and timing assertions.
Test Langflow's Messag...
Files:
src/backend/tests/unit/components/data/test_news_search.pysrc/backend/tests/unit/components/data/test_rss.py
src/backend/**/components/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/icons.mdc)
In your Python component class, set the
iconattribute to a string matching the frontend icon mapping exactly (case-sensitive).
Files:
src/backend/tests/unit/components/data/test_news_search.pysrc/backend/tests/unit/components/data/test_rss.py
{**/test_*.py,**/*.test.{ts,tsx}}
📄 CodeRabbit inference engine (coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt)
{**/test_*.py,**/*.test.{ts,tsx}}: Warn when mocks replace testing real behavior/interactions in test files
Suggest using real objects or simpler test doubles when mocks become excessive
Ensure mocks are reserved for external dependencies, not core application logic, in tests
Test files should have descriptive test names that explain what is being validated
Organize tests logically with proper setup and teardown
Include edge cases and error conditions for comprehensive test coverage
Cover both positive and negative scenarios where appropriate
Tests must cover the main functionality being implemented
Avoid smoke-only tests; assert meaningful behavior and outcomes
Follow project testing frameworks (pytest for backend, Playwright for frontend)
For API endpoints, verify both success and error responses in tests
Files:
src/backend/tests/unit/components/data/test_news_search.pysrc/backend/tests/unit/components/data/test_rss.py
**/test_*.py
📄 CodeRabbit inference engine (coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt)
**/test_*.py: Backend test files must follow naming convention test_*.py
Backend tests should use proper pytest structure
For async Python code, use proper pytest async testing patterns (e.g., pytest-asyncio)
Files:
src/backend/tests/unit/components/data/test_news_search.pysrc/backend/tests/unit/components/data/test_rss.py
🧬 Code graph analysis (3)
src/backend/tests/unit/components/data/test_news_search.py (2)
src/lfx/src/lfx/components/data/news_search.py (2)
NewsSearchComponent(12-167)search_news(88-164)src/backend/tests/base.py (1)
ComponentTestBaseWithoutClient(166-167)
src/lfx/src/lfx/components/data/news_search.py (2)
src/lfx/src/lfx/custom/custom_component/component.py (1)
log(1475-1492)src/lfx/src/lfx/components/data/web_search.py (1)
clean_html(150-152)
src/backend/tests/unit/components/data/test_rss.py (2)
src/lfx/src/lfx/components/data/rss.py (2)
RSSReaderComponent(11-71)read_rss(39-71)src/backend/tests/base.py (1)
ComponentTestBaseWithoutClient(166-167)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Lint Backend / Run Mypy (3.12)
- GitHub Check: Lint Backend / Run Mypy (3.11)
- GitHub Check: Lint Backend / Run Mypy (3.10)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Test Starter Templates
- GitHub Check: Update Starter Projects
- GitHub Check: Validate PR
🔇 Additional comments (11)
src/backend/tests/unit/components/data/test_rss.py (5)
11-27: LGTM! Proper test class structure.Test class correctly inherits from
ComponentTestBaseWithoutClientand provides all required fixtures as per coding guidelines.
29-64: LGTM! Comprehensive success scenario test.Test properly mocks the external HTTP dependency and validates DataFrame structure, row count, columns, and data values. Well-structured and complete.
66-94: LGTM! Good edge case coverage.Test validates the component handles missing RSS fields gracefully by returning empty strings, which aligns with the safe extraction logic in the component.
96-107: LGTM! Proper error handling test.Test validates that network exceptions are caught and return a structured error DataFrame, matching the component's error handling behavior.
109-129: LGTM! Empty feed scenario well-tested.Test validates that an empty RSS feed returns an empty DataFrame with correct schema, ensuring schema consistency as implemented in the component.
src/backend/tests/unit/components/data/test_news_search.py (4)
11-22: LGTM! Proper test class structure.Test class correctly inherits from
ComponentTestBaseWithoutClientand provides all required fixtures as per coding guidelines.
24-57: LGTM! Comprehensive success scenario test.Test properly mocks the external HTTP dependency and validates DataFrame structure, row count, columns, and data values. Patch target is appropriate for module-level requests import.
59-67: LGTM! Proper error handling test.Test validates that network exceptions are caught and return a structured error DataFrame with appropriate error messaging.
69-88: LGTM! Empty results scenario well-tested.Test correctly validates that an empty news feed returns a single-row DataFrame with "No articles found", matching the component's implementation at lines 145-148 of news_search.py.
src/lfx/src/lfx/components/data/rss.py (1)
11-71: LGTM! Component implementation is solid.The RSS reader correctly handles fetching, parsing, error cases, and returns a well-structured DataFrame. The legacy flag and replacement reference are appropriate for this restoration.
src/lfx/src/lfx/components/data/news_search.py (1)
12-167: LGTM! Component implementation handles multiple search modes well.The NewsSearch component correctly handles topic, location, and keyword-based searches with proper error handling and HTML cleaning. The legacy flag and replacement reference are appropriate.
| mock_response.content = mock_rss_content.encode("utf-8") | ||
| mock_response.raise_for_status = Mock() | ||
|
|
||
| with patch("requests.get", return_value=mock_response): |
There was a problem hiding this comment.
Fix patch target to match component import.
The patch target should reference where the component imports requests, not the global module.
Apply this diff:
- with patch("requests.get", return_value=mock_response):
+ with patch("lfx.components.data.news_search.requests.get", return_value=mock_response):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| with patch("requests.get", return_value=mock_response): | |
| with patch("lfx.components.data.news_search.requests.get", return_value=mock_response): |
🤖 Prompt for AI Agents
In src/backend/tests/unit/components/data/test_news_search.py around line 49,
the test currently patches "requests.get" but must patch the name used inside
the component; change the patch target to the component's import path (e.g.
patch("backend.components.data.news_search.requests.get",
return_value=mock_response)) so the mock replaces requests.get where news_search
imports it.
| assert news_results_df.iloc[1]["title"] == "Test News 2" | ||
|
|
||
| def test_news_search_error(self): | ||
| with patch("requests.get", side_effect=requests.RequestException("Network error")): |
There was a problem hiding this comment.
Fix patch target to match component import.
Same issue as in test_successful_news_search.
Apply this diff:
- with patch("requests.get", side_effect=requests.RequestException("Network error")):
+ with patch("lfx.components.data.news_search.requests.get", side_effect=requests.RequestException("Network error")):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| with patch("requests.get", side_effect=requests.RequestException("Network error")): | |
| with patch("lfx.components.data.news_search.requests.get", side_effect=requests.RequestException("Network error")): |
🤖 Prompt for AI Agents
In src/backend/tests/unit/components/data/test_news_search.py around line 60,
the test patches "requests.get" but the component imports requests within its
module so the patch target must reference that module; change the patch target
to the module import path used by the code under test (e.g.
patch("src.backend.components.data.news.requests.get",
side_effect=requests.RequestException("Network error"))) so the mocked exception
is applied where the component actually calls requests.get.
| mock_response.content = mock_rss_content.encode("utf-8") | ||
| mock_response.raise_for_status = Mock() | ||
|
|
||
| with patch("requests.get", return_value=mock_response): |
There was a problem hiding this comment.
Fix patch target to match component import.
Same issue as in test_successful_news_search.
Apply this diff:
- with patch("requests.get", return_value=mock_response):
+ with patch("lfx.components.data.news_search.requests.get", return_value=mock_response):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| with patch("requests.get", return_value=mock_response): | |
| with patch("lfx.components.data.news_search.requests.get", return_value=mock_response): |
🤖 Prompt for AI Agents
In src/backend/tests/unit/components/data/test_news_search.py around line 82,
the patch target currently mocks "requests.get" but the component imports
requests from its module, so update the patch target to mock the requests.get
used by the module under test (e.g. patch
"src.backend.components.data.news_search.requests.get" to match how the
component imports requests) so the test actually intercepts the HTTP call.
| mock_response.content = mock_rss_content.encode("utf-8") | ||
| mock_response.raise_for_status = Mock() | ||
|
|
||
| with patch("requests.get", return_value=mock_response): |
There was a problem hiding this comment.
Fix patch target to match component import.
The patch target "requests.get" may not correctly intercept the call in RSSReaderComponent.read_rss(). Since the component imports requests directly (line 2 in rss.py), you should patch where the component uses it.
Apply this diff:
- with patch("requests.get", return_value=mock_response):
+ with patch("lfx.components.data.rss.requests.get", return_value=mock_response):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| with patch("requests.get", return_value=mock_response): | |
| with patch("lfx.components.data.rss.requests.get", return_value=mock_response): |
🤖 Prompt for AI Agents
In src/backend/tests/unit/components/data/test_rss.py around line 56, the patch
target "requests.get" won't intercept the call because rss.py imports requests
directly; change the patch target to the component import path (e.g.
"src.backend.components.data.rss.requests.get" or the exact module path used
when importing RSSReaderComponent) so the test patches the requests.get used
inside RSSReaderComponent.read_rss().
| mock_response.content = mock_rss_content.encode("utf-8") | ||
| mock_response.raise_for_status = Mock() | ||
|
|
||
| with patch("requests.get", return_value=mock_response): |
There was a problem hiding this comment.
Fix patch target to match component import.
Same issue as in test_successful_rss_fetch.
Apply this diff:
- with patch("requests.get", return_value=mock_response):
+ with patch("lfx.components.data.rss.requests.get", return_value=mock_response):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| with patch("requests.get", return_value=mock_response): | |
| with patch("lfx.components.data.rss.requests.get", return_value=mock_response): |
🤖 Prompt for AI Agents
In src/backend/tests/unit/components/data/test_rss.py around line 86, the test
patches "requests.get" but the component under test imports requests from its
module; change the patch target to the component's import path by replacing
patch("requests.get", return_value=mock_response) with
patch("backend.components.data.rss.requests.get", return_value=mock_response) so
the mocked GET is applied to the actual function used by the component.
|
|
||
| def test_rss_fetch_error(self): | ||
| # Mock a failed request | ||
| with patch("requests.get", side_effect=requests.RequestException("Network error")): |
There was a problem hiding this comment.
Fix patch target to match component import.
Same issue as in test_successful_rss_fetch.
Apply this diff:
- with patch("requests.get", side_effect=requests.RequestException("Network error")):
+ with patch("lfx.components.data.rss.requests.get", side_effect=requests.RequestException("Network error")):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| with patch("requests.get", side_effect=requests.RequestException("Network error")): | |
| with patch("lfx.components.data.rss.requests.get", side_effect=requests.RequestException("Network error")): |
🤖 Prompt for AI Agents
In src/backend/tests/unit/components/data/test_rss.py around line 98, the test
patches "requests.get" but the component imports requests locally, so update the
patch target to the component's import path (e.g. patch
"backend.components.data.rss.requests.get" to match the module under test) so
the mocked exception is applied where the code actually calls requests.get.
| mock_response.content = mock_rss_content.encode("utf-8") | ||
| mock_response.raise_for_status = Mock() | ||
|
|
||
| with patch("requests.get", return_value=mock_response): |
There was a problem hiding this comment.
Fix patch target to match component import.
Same issue as in test_successful_rss_fetch.
Apply this diff:
- with patch("requests.get", return_value=mock_response):
+ with patch("lfx.components.data.rss.requests.get", return_value=mock_response):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| with patch("requests.get", return_value=mock_response): | |
| with patch("lfx.components.data.rss.requests.get", return_value=mock_response): |
🤖 Prompt for AI Agents
In src/backend/tests/unit/components/data/test_rss.py around line 123, the test
patches "requests.get" but the component under test imports requests from its
module, so the patch target must match that import; change the patch call to
target the component's requests import (e.g.
backend.components.data.rss.requests.get) so the mock replaces the function
actually used by the RSS fetcher.
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (47.24%) is below the target coverage (55.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #10069 +/- ##
==========================================
- Coverage 24.21% 24.21% -0.01%
==========================================
Files 1091 1091
Lines 40014 40013 -1
Branches 5543 5542 -1
==========================================
- Hits 9690 9689 -1
Misses 30153 30153
Partials 171 171
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|



These components were accidentally removed instead of being deprecated first; this just adds them back until we decide to eventually clean up the deprecated components.
Original PR: #9975
Summary by CodeRabbit
New Features
Tests