Skip to content

Bulk asynchronous downloader for multiple file hosts

test: update tests scope (#1011)

NTFSvolume12d6311f8dc4
diff --git a/.github/workflows/apprise.yml b/.github/workflows/apprise.yml
new file mode 100644
index 000000000..98d4316ae
--- /dev/null
+++ b/.github/workflows/apprise.yml
@@ -0,0 +1,40 @@
+name: CI
+
+on:
+ push:
+ paths:
+ - cyberdrop_dl/utils/apprise.py
+ branches:
+ - master
+ pull_request:
+ paths:
+ - cyberdrop_dl/utils/apprise.py
+ branches:
+ - master
+ workflow_dispatch:
+
+jobs:
+ test_apprise:
+ env:
+ APPRISE_TEST_EMAIL_URL: ${{ secrets.APPRISE_TEST_EMAIL_URL }}
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set up Python 3.11
+ uses: actions/setup-python@v5
+ with:
+ python-version: 3.11
+
+ - name: Install Poetry
+ uses: snok/install-poetry@v1
+
+ - name: Install dependencies
+ run: |
+ poetry install
+
+ - name: Run pytest
+ run: |
+ poetry run pytest --cov
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6ec399d6b..5232258fb 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -7,6 +7,7 @@ on:
pull_request:
branches:
- master
+ - dev
workflow_dispatch:
jobs:
@@ -41,30 +42,3 @@ jobs:
- name: Run pytest
run: |
poetry run pytest -v --cov --ignore=tests/test_apprise.py
-
- test_apprise:
- env:
- APPRISE_TEST_EMAIL_URL: ${{ secrets.APPRISE_TEST_EMAIL_URL }}
- runs-on: ubuntu-latest
-
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Set up Python 3.11
- uses: actions/setup-python@v5
- with:
- python-version: 3.11
-
- - name: Install Poetry
- run: |
- curl -sSL https://install.python-poetry.org | python3 -
- export PATH="$HOME/.poetry/bin:$PATH"
-
- - name: Install dependencies
- run: |
- poetry install
-
- - name: Run pytest
- run: |
- poetry run pytest --cov
diff --git a/README.md b/README.md
index 648f8310a..f8a70f33c 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,7 @@
[![Docs](https://img.shields.io/badge/docs-wiki-blue?link=https%3A%2F%2Fscript-ware.gitbook.io%2Fcyberdrop-dl)](https://script-ware.gitbook.io/cyberdrop-dl)
[![GitHub License](https://img.shields.io/github/license/jbsparrow/CyberDropDownloader)](https://github.com/jbsparrow/CyberDropDownloader/blob/master/LICENSE)
[![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/jbsparrow/CyberDropDownloader/actions/workflows/ruff.yaml)
+[![tests](https://github.com/jbsparrow/CyberDropDownloader/actions/workflows/ci.yml/badge.svg?branch=dev)](https://github.com/jbsparrow/CyberDropDownloader/actions/workflows/ci.yml)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/cyberdrop-dl-patched)](https://pypistats.org/packages/cyberdrop-dl-patched)
[![Discord](https://discordapp.com/api/guilds/1070206871564197908/widget.png?style=banner2)](https://discord.com/invite/P5nsbKErwy)
diff --git a/poetry.lock b/poetry.lock
index da2ed9253..4b95f191b 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -2745,4 +2745,4 @@ propcache = ">=0.2.1"
[metadata]
lock-version = "2.1"
python-versions = ">=3.11,<4"
-content-hash = "70619b741c995f47c2afe39d331eb88f42ded0193c0e4a64e756a336607b9f39"
+content-hash = "a5914cb1806ce52d5c3e8fa134f248415b672c099d085be39b95dac45bcb6466"
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 000000000..ee56eb9e3
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,8 @@
+from pathlib import Path
+
+import pytest
+
+
[email protected](autouse=True)
+def test_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.chdir(tmp_path)
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 480ab1c31..5a8e5c568 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -2,13 +2,16 @@ import sys
import pytest
-from cyberdrop_dl.main import main
+from cyberdrop_dl.main import run
-def test_help(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]):
+def test_help(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]) -> None:
# This is just to test that cyberdrop is able to run in the current python version
monkeypatch.setattr(sys, "argv", ["pytest", "--help"])
- main(profiling=True, ask=False)
+ try:
+ run()
+ except SystemExit:
+ pass
captured = capsys.readouterr()
output = captured.out
assert "Bulk asynchronous downloader for multiple file hosts" in output
diff --git a/tests/test_m3u8.py b/tests/test_m3u8.py
index a5c763c3b..ada5974b2 100644
--- a/tests/test_m3u8.py
+++ b/tests/test_m3u8.py
@@ -1,14 +1,15 @@
from datetime import timedelta
+from typing import LiteralString
import pytest
from yarl import URL
-from cyberdrop_dl.clients.errors import InvalidURLError
+from cyberdrop_dl.exceptions import InvalidURLError
from cyberdrop_dl.utils import m3u8
@pytest.fixture
-def m3u8_content():
+def m3u8_content() -> LiteralString:
return """
#EXTM3U
#EXT-X-VERSION:3
@@ -26,7 +27,7 @@ def m3u8_content():
@pytest.fixture
-def m3u8_master_content():
+def m3u8_master_content() -> LiteralString:
return """
#EXTM3U
#EXT-X-VERSION:3
@@ -43,7 +44,7 @@ def m3u8_master_content():
@pytest.fixture
-def m3u8_master_content2():
+def m3u8_master_content2() -> LiteralString:
return """
#EXTM3U
#EXT-X-VERSION:4
diff --git a/tests/test_startup.py b/tests/test_startup.py
index d97229e74..6ec1fe29c 100644
--- a/tests/test_startup.py
+++ b/tests/test_startup.py
@@ -1,17 +1,9 @@
-import sys
-from pathlib import Path
-
import pytest
from cyberdrop_dl.main import run
from cyberdrop_dl.ui.program_ui import ProgramUI
[email protected](autouse=True)
-def test_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
- monkeypatch.chdir(tmp_path)
-
-
def test_startup(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]) -> None:
# This is just to test that cyberdrop is able to run in the current python version
msg = "main UI started successfully"
@@ -19,7 +11,7 @@ def test_startup(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[
def main_ui(*_) -> None:
print(msg)
- monkeypatch.setattr(sys, "argv", ["pytest", "--disable-cache"])
+ monkeypatch.setattr("sys.argv", ["pytest", "--disable-cache"])
monkeypatch.setattr(ProgramUI, "__init__", main_ui)
run()
captured = capsys.readouterr()
@@ -28,7 +20,7 @@ def test_startup(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[
def test_async_startup(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]) -> None:
- monkeypatch.setattr(sys, "argv", ["pytest", "--download"])
+ monkeypatch.setattr("sys.argv", ["pytest", "--download"])
run()
captured = capsys.readouterr()
output = captured.out