-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add api/www unit tests - simpler filtering mode
- Loading branch information
Showing
15 changed files
with
296 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "yourss" | ||
version = "0.5.0" | ||
version = "0.5.1" | ||
description = "Simple youtube browser based on RSS feeds" | ||
homepage = "https://github.com/essembeh/yourss" | ||
authors = ["Sébastien MB <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import asyncio | ||
import pytest_asyncio | ||
from fastapi.testclient import TestClient | ||
|
||
import pytest | ||
from yourss.webapp import app | ||
from yourss.youtube import YoutubeWebClient | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def event_loop(): | ||
try: | ||
loop = asyncio.get_running_loop() | ||
except RuntimeError: | ||
loop = asyncio.new_event_loop() | ||
yield loop | ||
loop.close() | ||
@pytest_asyncio.fixture | ||
async def yt_client(): | ||
yield YoutubeWebClient() | ||
|
||
|
||
@pytest_asyncio.fixture | ||
async def yourss_client(): | ||
yield TestClient(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from .test_youtube import CHANNEL_ID, SLUG, USER | ||
|
||
|
||
def test_version(yourss_client): | ||
resp = yourss_client.get("/api/version") | ||
resp.raise_for_status() | ||
|
||
|
||
def test_api_avatar_slug(yourss_client): | ||
resp = yourss_client.get(f"/api/avatar/{SLUG}", follow_redirects=False) | ||
assert 300 <= resp.status_code < 400 | ||
|
||
|
||
def test_api_avatar_channel(yourss_client): | ||
resp = yourss_client.get(f"/api/avatar/{CHANNEL_ID}", follow_redirects=False) | ||
assert 300 <= resp.status_code < 400 | ||
|
||
|
||
def test_api_avatar_user(yourss_client): | ||
resp = yourss_client.get(f"/api/avatar/{USER}", follow_redirects=False) | ||
assert 300 <= resp.status_code < 400 | ||
|
||
|
||
def test_api_rss_slug(yourss_client): | ||
resp = yourss_client.get(f"/api/rss/{SLUG}", follow_redirects=False) | ||
assert 300 <= resp.status_code < 400 | ||
|
||
|
||
def test_api_rss_channel(yourss_client): | ||
resp = yourss_client.get(f"/api/rss/{CHANNEL_ID}", follow_redirects=False) | ||
assert 300 <= resp.status_code < 400 | ||
|
||
|
||
def test_api_rss_user(yourss_client): | ||
resp = yourss_client.get(f"/api/rss/{USER}", follow_redirects=False) | ||
assert 300 <= resp.status_code < 400 | ||
|
||
|
||
def test_homepage(yourss_client): | ||
resp = yourss_client.get("/") | ||
assert resp.status_code == 200 | ||
|
||
|
||
def test_page(yourss_client): | ||
resp = yourss_client.get("/@jonnygiger") | ||
assert resp.status_code == 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,2 @@ | ||
def parse_channel_names( | ||
text: str, delimiter: str = ",", disabled_prefix: str = "-" | ||
) -> dict[str, bool]: | ||
return { | ||
s.removeprefix(disabled_prefix): not s.startswith(disabled_prefix) | ||
for s in filter( | ||
lambda x: len(x.removeprefix(disabled_prefix)) > 0, text.split(delimiter) | ||
) | ||
} | ||
def parse_channel_names(text: str, delimiter: str = ",") -> set[str]: | ||
return set(filter(None, text.split(delimiter))) |
Oops, something went wrong.