fix linting; add some tests
- ID
0deb9c3- date
2024-02-14 23:17:43+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
5087700- message
fix linting; add some tests- changed files
3 files, 20 additions, 1 deletion
Changed files
.github/workflows/test.yml (1190) → .github/workflows/test.yml (1233)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 3171640..6356a05 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -44,3 +44,4 @@ jobs:
py.test aws/test_s3tree.py
py.test text/test_fix_twitter_thread.py
py.test textexpander/test_get_mastodon_text.py
+ py.test web/test_save_ao3_links.py
web/save_ao3_links.py (2160) → web/save_ao3_links.py (2160)
diff --git a/web/save_ao3_links.py b/web/save_ao3_links.py
index e8a9208..b1d9f37 100755
--- a/web/save_ao3_links.py
+++ b/web/save_ao3_links.py
@@ -17,7 +17,7 @@ def get_ao3_id(url: str) -> str:
# e.g. 'https://archiveofourown.org/works/1234' ~> '1234'
u = hyperlink.DecodedURL.from_text(url)
- if u.path[0] == 'works' and u.path[1].isnumeric():
+ if u.path[0] == "works" and u.path[1].isnumeric():
return u.path[1]
else:
raise ValueError(url)
web/test_save_ao3_links.py (0) → web/test_save_ao3_links.py (451)
diff --git a/web/test_save_ao3_links.py b/web/test_save_ao3_links.py
new file mode 100644
index 0000000..b3b5b92
--- /dev/null
+++ b/web/test_save_ao3_links.py
@@ -0,0 +1,18 @@
+import pytest
+
+from save_ao3_links import get_ao3_id
+
+
+@pytest.mark.parametrize(
+ ["url", "ao3_id"],
+ [
+ ("https://archiveofourown.org/works/1234", "1234"),
+ ("https://archiveofourown.org/works/1234?view_adult=true", "1234"),
+ (
+ "https://archiveofourown.org/works/1234/chapters/5678?view_adult=true",
+ "1234",
+ ),
+ ],
+)
+def test_get_ao3_id(url, ao3_id):
+ assert get_ao3_id(url) == ao3_id