Fix all the bugs

This commit is contained in:
2024-05-18 04:05:05 +02:00
parent 9c63916716
commit 73cf7c489c
33 changed files with 831 additions and 396 deletions

View File

@ -1,3 +1,5 @@
from __future__ import annotations
import tempfile
from pathlib import Path
from typing import TYPE_CHECKING

View File

@ -40,7 +40,7 @@ def test_entry_is_whitelisted() -> None:
custom_reader.update_feed("https://lovinator.space/rss_test.xml")
# whitelist_title
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "whitelist_title", "fvnnnfnfdnfdnfd") # type: ignore # noqa: E501
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "whitelist_title", "fvnnnfnfdnfdnfd") # type: ignore
for entry in custom_reader.get_entries():
if entry_is_whitelisted(entry) is True:
assert entry.title == "fvnnnfnfdnfdnfd"
@ -48,7 +48,7 @@ def test_entry_is_whitelisted() -> None:
custom_reader.delete_tag("https://lovinator.space/rss_test.xml", "whitelist_title")
# whitelist_summary
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "whitelist_summary", "fvnnnfnfdnfdnfd") # type: ignore # noqa: E501
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "whitelist_summary", "fvnnnfnfdnfdnfd") # type: ignore
for entry in custom_reader.get_entries():
if entry_is_whitelisted(entry) is True:
assert entry.summary == "fvnnnfnfdnfdnfd"
@ -56,7 +56,7 @@ def test_entry_is_whitelisted() -> None:
custom_reader.delete_tag("https://lovinator.space/rss_test.xml", "whitelist_summary")
# whitelist_content
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "whitelist_content", "fvnnnfnfdnfdnfd") # type: ignore # noqa: E501
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "whitelist_content", "fvnnnfnfdnfdnfd") # type: ignore
for entry in custom_reader.get_entries():
if entry_is_whitelisted(entry) is True:
assert entry.content[0].value == "<p>ffdnfdnfdnfdnfdndfn</p>"
@ -81,7 +81,7 @@ def test_entry_is_blacklisted() -> None:
custom_reader.update_feed("https://lovinator.space/rss_test.xml")
# blacklist_title
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "blacklist_title", "fvnnnfnfdnfdnfd") # type: ignore # noqa: E501
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "blacklist_title", "fvnnnfnfdnfdnfd") # type: ignore
for entry in custom_reader.get_entries():
if entry_is_blacklisted(entry) is True:
assert entry.title == "fvnnnfnfdnfdnfd"
@ -89,7 +89,7 @@ def test_entry_is_blacklisted() -> None:
custom_reader.delete_tag("https://lovinator.space/rss_test.xml", "blacklist_title")
# blacklist_summary
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "blacklist_summary", "fvnnnfnfdnfdnfd") # type: ignore # noqa: E501
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "blacklist_summary", "fvnnnfnfdnfdnfd") # type: ignore
for entry in custom_reader.get_entries():
if entry_is_blacklisted(entry) is True:
assert entry.summary == "fvnnnfnfdnfdnfd"
@ -97,7 +97,7 @@ def test_entry_is_blacklisted() -> None:
custom_reader.delete_tag("https://lovinator.space/rss_test.xml", "blacklist_summary")
# blacklist_content
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "blacklist_content", "fvnnnfnfdnfdnfd") # type: ignore # noqa: E501
custom_reader.set_tag("https://lovinator.space/rss_test.xml", "blacklist_content", "fvnnnfnfdnfdnfd") # type: ignore
for entry in custom_reader.get_entries():
if entry_is_blacklisted(entry) is True:
assert entry.content[0].value == "<p>ffdnfdnfdnfdnfdndfn</p>"

View File

@ -1,3 +1,5 @@
from __future__ import annotations
import os
import tempfile
from pathlib import Path

View File

@ -19,27 +19,30 @@ def test_search() -> None:
# Remove the feed if it already exists before we run the test.
feeds: Response = client.get("/")
if feed_url in feeds.text:
client.post("/remove", data={"feed_url": feed_url})
client.post("/remove", data={"feed_url": encoded_feed_url})
client.post(url="/remove", data={"feed_url": feed_url})
client.post(url="/remove", data={"feed_url": encoded_feed_url})
# Delete the webhook if it already exists before we run the test.
response: Response = client.post("/delete_webhook", data={"webhook_url": webhook_url})
response: Response = client.post(url="/delete_webhook", data={"webhook_url": webhook_url})
# Add the webhook.
response: Response = client.post("/add_webhook", data={"webhook_name": webhook_name, "webhook_url": webhook_url})
response: Response = client.post(
url="/add_webhook",
data={"webhook_name": webhook_name, "webhook_url": webhook_url},
)
assert response.status_code == 200
# Add the feed.
response: Response = client.post("/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
response: Response = client.post(url="/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
assert response.status_code == 200
# Check that the feed was added.
response = client.get("/")
response = client.get(url="/")
assert response.status_code == 200
assert feed_url in response.text
# Search for an entry.
response: Response = client.get("/search/?query=a")
response: Response = client.get(url="/search/?query=a")
assert response.status_code == 200
@ -53,14 +56,17 @@ def test_encode_url() -> None:
def test_add_webhook() -> None:
"""Test the /add_webhook page."""
# Delete the webhook if it already exists before we run the test.
response: Response = client.post("/delete_webhook", data={"webhook_url": webhook_url})
response: Response = client.post(url="/delete_webhook", data={"webhook_url": webhook_url})
# Add the webhook.
response: Response = client.post("/add_webhook", data={"webhook_name": webhook_name, "webhook_url": webhook_url})
response: Response = client.post(
url="/add_webhook",
data={"webhook_name": webhook_name, "webhook_url": webhook_url},
)
assert response.status_code == 200
# Check that the webhook was added.
response = client.get("/webhooks")
response = client.get(url="/webhooks")
assert response.status_code == 200
assert webhook_name in response.text
@ -68,17 +74,17 @@ def test_add_webhook() -> None:
def test_create_feed() -> None:
"""Test the /create_feed page."""
# Remove the feed if it already exists before we run the test.
feeds: Response = client.get("/")
feeds: Response = client.get(url="/")
if feed_url in feeds.text:
client.post("/remove", data={"feed_url": feed_url})
client.post("/remove", data={"feed_url": encoded_feed_url})
client.post(url="/remove", data={"feed_url": feed_url})
client.post(url="/remove", data={"feed_url": encoded_feed_url})
# Add the feed.
response: Response = client.post("/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
response: Response = client.post(url="/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
assert response.status_code == 200
# Check that the feed was added.
response = client.get("/")
response = client.get(url="/")
assert response.status_code == 200
assert feed_url in response.text
@ -88,11 +94,11 @@ def test_get() -> None:
# Remove the feed if it already exists before we run the test.
feeds: Response = client.get("/")
if feed_url in feeds.text:
client.post("/remove", data={"feed_url": feed_url})
client.post("/remove", data={"feed_url": encoded_feed_url})
client.post(url="/remove", data={"feed_url": feed_url})
client.post(url="/remove", data={"feed_url": encoded_feed_url})
# Add the feed.
response: Response = client.post("/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
response: Response = client.post(url="/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
assert response.status_code == 200
# Check that the feed was added.
@ -100,57 +106,60 @@ def test_get() -> None:
assert response.status_code == 200
assert feed_url in response.text
response: Response = client.get("/add")
response: Response = client.get(url="/add")
assert response.status_code == 200
response: Response = client.get("/add_webhook")
response: Response = client.get(url="/add_webhook")
assert response.status_code == 200
response: Response = client.get("/blacklist", params={"feed_url": encoded_feed_url})
response: Response = client.get(url="/blacklist", params={"feed_url": encoded_feed_url})
assert response.status_code == 200
response: Response = client.get("/custom", params={"feed_url": encoded_feed_url})
response: Response = client.get(url="/custom", params={"feed_url": encoded_feed_url})
assert response.status_code == 200
response: Response = client.get("/embed", params={"feed_url": encoded_feed_url})
response: Response = client.get(url="/embed", params={"feed_url": encoded_feed_url})
assert response.status_code == 200
response: Response = client.get("/feed", params={"feed_url": encoded_feed_url})
response: Response = client.get(url="/feed", params={"feed_url": encoded_feed_url})
assert response.status_code == 200
response: Response = client.get("/")
response: Response = client.get(url="/feed_more", params={"feed_url": encoded_feed_url})
assert response.status_code == 200
response: Response = client.get("/webhooks")
response: Response = client.get(url="/")
assert response.status_code == 200
response: Response = client.get("/whitelist", params={"feed_url": encoded_feed_url})
response: Response = client.get(url="/webhooks")
assert response.status_code == 200
response: Response = client.get(url="/whitelist", params={"feed_url": encoded_feed_url})
assert response.status_code == 200
def test_pause_feed() -> None:
"""Test the /pause_feed page."""
# Remove the feed if it already exists before we run the test.
feeds: Response = client.get("/")
feeds: Response = client.get(url="/")
if feed_url in feeds.text:
client.post("/remove", data={"feed_url": feed_url})
client.post("/remove", data={"feed_url": encoded_feed_url})
client.post(url="/remove", data={"feed_url": feed_url})
client.post(url="/remove", data={"feed_url": encoded_feed_url})
# Add the feed.
response: Response = client.post("/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
response: Response = client.post(url="/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
# Unpause the feed if it is paused.
feeds: Response = client.get("/")
feeds: Response = client.get(url="/")
if "Paused" in feeds.text:
response: Response = client.post("/unpause", data={"feed_url": feed_url})
response: Response = client.post(url="/unpause", data={"feed_url": feed_url})
assert response.status_code == 200
# Pause the feed.
response: Response = client.post("/pause", data={"feed_url": feed_url})
response: Response = client.post(url="/pause", data={"feed_url": feed_url})
assert response.status_code == 200
# Check that the feed was paused.
response = client.get("/")
response = client.get(url="/")
assert response.status_code == 200
assert feed_url in response.text
@ -160,24 +169,24 @@ def test_unpause_feed() -> None:
# Remove the feed if it already exists before we run the test.
feeds: Response = client.get("/")
if feed_url in feeds.text:
client.post("/remove", data={"feed_url": feed_url})
client.post("/remove", data={"feed_url": encoded_feed_url})
client.post(url="/remove", data={"feed_url": feed_url})
client.post(url="/remove", data={"feed_url": encoded_feed_url})
# Add the feed.
response: Response = client.post("/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
response: Response = client.post(url="/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
# Pause the feed if it is unpaused.
feeds: Response = client.get("/")
feeds: Response = client.get(url="/")
if "Paused" not in feeds.text:
response: Response = client.post("/pause", data={"feed_url": feed_url})
response: Response = client.post(url="/pause", data={"feed_url": feed_url})
assert response.status_code == 200
# Unpause the feed.
response: Response = client.post("/unpause", data={"feed_url": feed_url})
response: Response = client.post(url="/unpause", data={"feed_url": feed_url})
assert response.status_code == 200
# Check that the feed was unpaused.
response = client.get("/")
response = client.get(url="/")
assert response.status_code == 200
assert feed_url in response.text
@ -185,20 +194,20 @@ def test_unpause_feed() -> None:
def test_remove_feed() -> None:
"""Test the /remove page."""
# Remove the feed if it already exists before we run the test.
feeds: Response = client.get("/")
feeds: Response = client.get(url="/")
if feed_url in feeds.text:
client.post("/remove", data={"feed_url": feed_url})
client.post("/remove", data={"feed_url": encoded_feed_url})
client.post(url="/remove", data={"feed_url": feed_url})
client.post(url="/remove", data={"feed_url": encoded_feed_url})
# Add the feed.
response: Response = client.post("/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
response: Response = client.post(url="/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name})
# Remove the feed.
response: Response = client.post("/remove", data={"feed_url": feed_url})
response: Response = client.post(url="/remove", data={"feed_url": feed_url})
assert response.status_code == 200
# Check that the feed was removed.
response = client.get("/")
response = client.get(url="/")
assert response.status_code == 200
assert feed_url not in response.text
@ -206,18 +215,21 @@ def test_remove_feed() -> None:
def test_delete_webhook() -> None:
"""Test the /delete_webhook page."""
# Remove the feed if it already exists before we run the test.
feeds: Response = client.get("/webhooks")
feeds: Response = client.get(url="/webhooks")
if webhook_url in feeds.text:
client.post("/delete_webhook", data={"webhook_url": webhook_url})
client.post(url="/delete_webhook", data={"webhook_url": webhook_url})
# Add the webhook.
response: Response = client.post("/add_webhook", data={"webhook_name": webhook_name, "webhook_url": webhook_url})
response: Response = client.post(
url="/add_webhook",
data={"webhook_name": webhook_name, "webhook_url": webhook_url},
)
# Delete the webhook.
response: Response = client.post("/delete_webhook", data={"webhook_url": webhook_url})
response: Response = client.post(url="/delete_webhook", data={"webhook_url": webhook_url})
assert response.status_code == 200
# Check that the webhook was added.
response = client.get("/webhooks")
response = client.get(url="/webhooks")
assert response.status_code == 200
assert webhook_name not in response.text

View File

@ -57,13 +57,13 @@ def test_convert_to_md() -> None:
'<div class="field field-name-field-short-description field-type-text-long field-label-hidden">'
'<div class="field-items"><div class="field-item even">Plus new options to mirror your camera and take a selfie.</div>' # noqa: E501
'</div></div><div class="field field-name-field-thumbnail-image field-type-image field-label-hidden">'
'<div class="field-items"><div class="field-item even"><a href="https://www.nvidia.com/en-us/geforce/news/jan-2023-nvidia-broadcast-update/">' # noqa: E501
'<img width="210" src="https://www.nvidia.com/content/dam/en-zz/Solutions/geforce/news/jan-2023-nvidia-broadcast-update/broadcast-owned-asset-625x330-newsfeed.png"' # noqa: E501
'<div class="field-items"><div class="field-item even"><a href="https://www.nvidia.com/en-us/geforce/news/jan-2023-nvidia-broadcast-update/">'
'<img width="210" src="https://www.nvidia.com/content/dam/en-zz/Solutions/geforce/news/jan-2023-nvidia-broadcast-update/broadcast-owned-asset-625x330-newsfeed.png"'
' title="NVIDIA Broadcast 1.4 Adds Eye Contact and Vignette Effects With Virtual Background Enhancements" '
'alt="NVIDIA Broadcast 1.4 Adds Eye Contact and Vignette Effects With Virtual Background Enhancements"></a></div></div></div>' # noqa: E501
)
assert (
convert_html_to_md(nvidia_entry)
== "[NVIDIA Broadcast 1.4 Adds Eye Contact and Vignette Effects With Virtual Background Enhancements](https://www.nvidia.com/en-us/geforce/news/jan-2023-nvidia-broadcast-update/)\n" # noqa: E501
== "[NVIDIA Broadcast 1.4 Adds Eye Contact and Vignette Effects With Virtual Background Enhancements](https://www.nvidia.com/en-us/geforce/news/jan-2023-nvidia-broadcast-update/)\n"
"Plus new options to mirror your camera and take a selfie."
)

View File

@ -1,3 +1,5 @@
from __future__ import annotations
import tempfile
from pathlib import Path
from typing import TYPE_CHECKING