Fix warnings; use httpx2 and authors_str
This commit is contained in:
parent
1065838ef7
commit
c481c7c88f
14 changed files with 65 additions and 49 deletions
|
|
@ -42,6 +42,7 @@ def make_feed() -> SimpleNamespace:
|
|||
return SimpleNamespace(
|
||||
added=None,
|
||||
author="Feed Author",
|
||||
authors_str="Entry Author",
|
||||
last_exception=None,
|
||||
last_updated=None,
|
||||
link="https://example.com/feed",
|
||||
|
|
@ -60,6 +61,7 @@ def make_entry(summary: str) -> SimpleNamespace:
|
|||
return SimpleNamespace(
|
||||
added=None,
|
||||
author="Entry Author",
|
||||
authors_str="Entry Author",
|
||||
content=[],
|
||||
feed=feed,
|
||||
feed_url=feed.url,
|
||||
|
|
|
|||
|
|
@ -792,7 +792,7 @@ def test_get_ttvdrops_campaign_api_url_from_campaign_page() -> None:
|
|||
("https://ttvdrops.lovinator.space/twitch/feed.xml?hide_paid=0&hide_paid=1", False),
|
||||
],
|
||||
)
|
||||
@patch("discord_rss_bot.feeds.httpx.get")
|
||||
@patch("discord_rss_bot.feeds.httpx2.get")
|
||||
def test_fetch_ttvdrops_campaign_media_items_extracts_reward_alt_text(
|
||||
mock_get: MagicMock,
|
||||
feed_url: str,
|
||||
|
|
@ -1351,8 +1351,8 @@ def test_execute_webhook_does_not_record_when_feed_tracking_disabled(mock_send_w
|
|||
reader.set_tag.assert_not_called()
|
||||
|
||||
|
||||
@patch("discord_rss_bot.feeds.httpx.request")
|
||||
def test_send_webhook_message_posts_components_with_httpx(mock_request: MagicMock) -> None:
|
||||
@patch("discord_rss_bot.feeds.httpx2.request")
|
||||
def test_send_webhook_message_posts_components_with_httpx2(mock_request: MagicMock) -> None:
|
||||
response = MagicMock(status_code=200, text='{"id": "message-1"}')
|
||||
mock_request.return_value = response
|
||||
components: list[feeds.JsonValue] = [
|
||||
|
|
@ -1383,7 +1383,7 @@ def test_send_webhook_message_posts_components_with_httpx(mock_request: MagicMoc
|
|||
}
|
||||
|
||||
|
||||
@patch("discord_rss_bot.feeds.httpx.request")
|
||||
@patch("discord_rss_bot.feeds.httpx2.request")
|
||||
def test_send_webhook_message_uploads_files_as_multipart(mock_request: MagicMock) -> None:
|
||||
response = MagicMock(status_code=200, text='{"id": "message-2"}')
|
||||
mock_request.return_value = response
|
||||
|
|
@ -1462,7 +1462,7 @@ def test_update_sent_webhooks_for_modified_entries_edits_changed_payload(
|
|||
|
||||
assert updated_count == 1
|
||||
mock_edit_sent_webhook_message.assert_called_once()
|
||||
edit_payload = mock_edit_sent_webhook_message.call_args.args[3]
|
||||
edit_payload = mock_edit_sent_webhook_message.call_args.kwargs["payload"]
|
||||
assert edit_payload == {"content": "New title"}
|
||||
records = state["sent_webhooks"]
|
||||
assert isinstance(records, list)
|
||||
|
|
@ -1533,7 +1533,7 @@ def test_update_sent_webhook_record_preserves_existing_embed_image_when_updated_
|
|||
|
||||
assert record_changed is True
|
||||
assert message_was_edited is True
|
||||
edit_payload = mock_edit_sent_webhook_message.call_args.args[3]
|
||||
edit_payload = mock_edit_sent_webhook_message.call_args.kwargs["payload"]
|
||||
assert isinstance(edit_payload["embeds"], list)
|
||||
assert edit_payload["embeds"][0]["image"] == previous_image
|
||||
assert isinstance(updated_record["payload"], dict)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ if TYPE_CHECKING:
|
|||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from httpx import Response
|
||||
from httpx2 import Response
|
||||
from reader import Entry
|
||||
from reader import Reader
|
||||
|
||||
|
|
@ -330,6 +330,7 @@ def test_blacklist_preview_uses_50_entry_limit() -> None:
|
|||
title: str
|
||||
summary: str
|
||||
author: str
|
||||
authors_str: str
|
||||
link: str
|
||||
published: datetime | None
|
||||
content: list[DummyContent] = field(default_factory=lambda: [DummyContent("content")])
|
||||
|
|
@ -347,6 +348,7 @@ def test_blacklist_preview_uses_50_entry_limit() -> None:
|
|||
title=f"Entry {index}",
|
||||
summary=f"Summary {index}",
|
||||
author="Author",
|
||||
authors_str="Author",
|
||||
link=f"https://example.com/entry-{index}",
|
||||
published=datetime(2024, 1, 1, tzinfo=UTC),
|
||||
),
|
||||
|
|
@ -403,6 +405,7 @@ def test_blacklist_preview_shows_labeled_field_values_for_substring_match() -> N
|
|||
title: str
|
||||
summary: str
|
||||
author: str
|
||||
authors_str: str
|
||||
link: str
|
||||
published: datetime | None
|
||||
content: list[DummyContent] = field(default_factory=list)
|
||||
|
|
@ -419,6 +422,7 @@ def test_blacklist_preview_shows_labeled_field_values_for_substring_match() -> N
|
|||
title="World of Warcraft",
|
||||
summary="<p>Massive MMO news update</p>",
|
||||
author="Blizzard",
|
||||
authors_str="Blizzard",
|
||||
link="https://example.com/wow-1",
|
||||
published=datetime(2024, 1, 1, tzinfo=UTC),
|
||||
content=[DummyContent("<p>The expansion launches soon.</p>")],
|
||||
|
|
@ -1461,6 +1465,7 @@ def test_create_html_marks_entries_from_another_feed(monkeypatch: pytest.MonkeyP
|
|||
link: str = "https://example.com/post"
|
||||
title: str = "Example title"
|
||||
author: str = "Author"
|
||||
authors_str: str = "Author"
|
||||
summary: str = "Summary"
|
||||
content: list[DummyContent] = field(default_factory=lambda: [DummyContent("Content")])
|
||||
published: None = None
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from fastapi.testclient import TestClient
|
|||
from discord_rss_bot.main import app
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from httpx import Response
|
||||
from httpx2 import Response
|
||||
|
||||
client: TestClient = TestClient(app)
|
||||
webhook_name: str = "Test Webhook for Update Interval"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue