diff --git a/.github/workflows/ci-windows.yaml b/.github/workflows/ci-windows.yaml index 5d0b23a9..42d45131 100644 --- a/.github/workflows/ci-windows.yaml +++ b/.github/workflows/ci-windows.yaml @@ -31,7 +31,7 @@ jobs: python -m pip install -e .[test] python -m pytest --reruns 3 --reruns-delay 5 tests/unit - test-soundcloud: + test-integration: runs-on: windows-latest permissions: contents: read @@ -44,7 +44,7 @@ jobs: with: python-version: "3.10" - - name: Run e2e soundcloud tests with coverage + - name: Run integration tests with coverage run: | curl.exe -L -o ffmpeg.zip https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip tar -xf ffmpeg.zip @@ -52,9 +52,10 @@ jobs: move "ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" "ffprobe.exe" python -m pip install -e .[test] - python -m pytest --reruns 3 --reruns-delay 5 tests/e2e/soundcloud + python -m pytest --reruns 3 --reruns-delay 5 tests/integration --ignore tests/integration/prebuilt_presets - test-bandcamp: + + test-integration-prebuilt-presets: runs-on: windows-latest permissions: contents: read @@ -67,31 +68,7 @@ jobs: with: python-version: "3.10" - - name: Run e2e soundcloud tests with coverage - run: | - curl.exe -L -o ffmpeg.zip https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip - tar -xf ffmpeg.zip - move "ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe" "ffmpeg.exe" - move "ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" "ffprobe.exe" - - python -m pip install -e .[test] - python -m pytest --reruns 3 --reruns-delay 5 tests/e2e/bandcamp - - - test-youtube: - runs-on: windows-latest - permissions: - contents: read - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - - name: Run e2e youtube tests with coverage + - name: Run prebuilt preset integration tests with coverage run: | curl.exe -L -o ffmpeg.zip https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip tar -xf ffmpeg.zip @@ -99,9 +76,9 @@ jobs: move "ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" "ffprobe.exe" python -m pip install -e .[test] - python -m pytest --reruns 3 --reruns-delay 5 tests/e2e/youtube + python -m pytest --reruns 3 --reruns-delay 5 tests/integration/prebuilt_presets - test-plugins: + test-e2e: runs-on: windows-latest permissions: contents: read @@ -114,7 +91,7 @@ jobs: with: python-version: "3.10" - - name: Run e2e plugin tests with coverage + - name: Run e2e tests with coverage run: | curl.exe -L -o ffmpeg.zip https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip tar -xf ffmpeg.zip @@ -122,4 +99,4 @@ jobs: move "ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" "ffprobe.exe" python -m pip install -e .[test] - python -m pytest --reruns 3 --reruns-delay 5 tests/e2e/plugins + python -m pytest tests/e2e diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b2452fdf..84a53f94 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -52,7 +52,7 @@ jobs: path: /opt/coverage/unit key: ${{github.sha}}-coverage-unit - test-soundcloud: + test-integration: runs-on: ubuntu-22.04 permissions: contents: read @@ -65,40 +65,20 @@ jobs: with: python-version: "3.10" - - name: Run e2e soundcloud tests with coverage + - name: Run integration tests with coverage run: | pip install -e .[test] sudo apt-get update sudo apt-get install -y ffmpeg - coverage run -m pytest --reruns 3 --reruns-delay 5 tests/e2e/soundcloud && coverage xml -o /opt/coverage/soundcloud/coverage.xml - - test-bandcamp: - runs-on: ubuntu-22.04 - permissions: - contents: read - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - - name: Run e2e soundcloud tests with coverage - run: | - pip install -e .[test] - sudo apt-get update - sudo apt-get install -y ffmpeg - coverage run -m pytest --reruns 3 --reruns-delay 5 tests/e2e/bandcamp && coverage xml -o /opt/coverage/bandcamp/coverage.xml + coverage run -m pytest --reruns 3 --reruns-delay 5 tests/integration --ignore tests/integration/prebuilt_presets && coverage xml -o /opt/coverage/integration/coverage.xml - name: Save coverage uses: actions/cache@v3 with: - path: /opt/coverage/bandcamp - key: ${{github.sha}}-coverage-bandcamp + path: /opt/coverage/integration + key: ${{github.sha}}-coverage-integration - test-youtube: + test-integration-prebuilt-presets: runs-on: ubuntu-22.04 permissions: contents: read @@ -111,20 +91,20 @@ jobs: with: python-version: "3.10" - - name: Run e2e youtube tests with coverage + - name: Run prebuilt preset integration tests with coverage run: | pip install -e .[test] sudo apt-get update sudo apt-get install -y ffmpeg - coverage run -m pytest --reruns 3 --reruns-delay 5 tests/e2e/youtube && coverage xml -o /opt/coverage/youtube/coverage.xml + coverage run -m pytest --reruns 3 --reruns-delay 5 tests/integration/prebuilt_presets && coverage xml -o /opt/coverage/integration-prebuilt-presets/coverage.xml - name: Save coverage uses: actions/cache@v3 with: - path: /opt/coverage/youtube - key: ${{github.sha}}-coverage-youtube + path: /opt/coverage/integration-prebuilt-presets + key: ${{github.sha}}-coverage-integration-prebuilt-presets - test-plugins: + test-e2e: runs-on: ubuntu-22.04 permissions: contents: read @@ -137,27 +117,20 @@ jobs: with: python-version: "3.10" - - name: Run e2e plugin tests with coverage + - name: Run e2e tests with coverage run: | pip install -e .[test] sudo apt-get update sudo apt-get install -y ffmpeg - coverage run -m pytest --reruns 3 --reruns-delay 5 tests/e2e/plugins && coverage xml -o /opt/coverage/plugins/coverage.xml - - - name: Save coverage - uses: actions/cache@v3 - with: - path: /opt/coverage/plugins - key: ${{github.sha}}-coverage-plugins + coverage run -m pytest tests/e2e && coverage xml -o /opt/coverage/e2e/coverage.xml codecov-upload: runs-on: ubuntu-22.04 needs: [ test-unit, - test-soundcloud, - test-bandcamp, - test-youtube, - test-plugins + test-integration, + test-integration-prebuilt-presets, + test-e2e ] permissions: contents: read @@ -169,32 +142,26 @@ jobs: path: /opt/coverage/unit key: ${{github.sha}}-coverage-unit - - name: Restore soundcloud test coverage + - name: Restore integration test coverage uses: actions/cache@v3 with: - path: /opt/coverage/soundcloud - key: ${{github.sha}}-coverage-soundcloud + path: /opt/coverage/integration + key: ${{github.sha}}-coverage-integration - - name: Restore bandcamp test coverage + - name: Restore integration prebuilt presets test coverage uses: actions/cache@v3 with: - path: /opt/coverage/bandcamp - key: ${{github.sha}}-coverage-bandcamp + path: /opt/coverage/integration-prebuilt-presets + key: ${{github.sha}}-coverage-integration-prebuilt-presets - - name: Restore youtube test coverage + - name: Restore e2e test coverage uses: actions/cache@v3 with: - path: /opt/coverage/youtube - key: ${{github.sha}}-coverage-youtube - - - name: Restore plugins test coverage - uses: actions/cache@v3 - with: - path: /opt/coverage/plugins - key: ${{github.sha}}-coverage-plugins + path: /opt/coverage/e2e + key: ${{github.sha}}-coverage-e2e - name: Upload code coverage to codecov.io uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} - files: /opt/coverage/unit/coverage.xml,/opt/coverage/soundcloud/coverage.xml,/opt/coverage/bandcamp/coverage.xml,/opt/coverage/youtube/coverage.xml,/opt/coverage/plugins/coverage.xml \ No newline at end of file + files: /opt/coverage/unit/coverage.xml,/opt/coverage/integration/coverage.xml,/opt/coverage/integration-prebuilt-presets/coverage.xml,/opt/coverage/e2e/coverage.xml \ No newline at end of file diff --git a/tests/unit/plugins/__init__.py b/tests/integration/__init__.py similarity index 100% rename from tests/unit/plugins/__init__.py rename to tests/integration/__init__.py diff --git a/tests/unit/prebuilt_presets/__init__.py b/tests/integration/cli/__init__.py similarity index 100% rename from tests/unit/prebuilt_presets/__init__.py rename to tests/integration/cli/__init__.py diff --git a/tests/unit/cli/conftest.py b/tests/integration/cli/conftest.py similarity index 100% rename from tests/unit/cli/conftest.py rename to tests/integration/cli/conftest.py diff --git a/tests/unit/cli/test_entrypoint.py b/tests/integration/cli/test_entrypoint.py similarity index 100% rename from tests/unit/cli/test_entrypoint.py rename to tests/integration/cli/test_entrypoint.py diff --git a/tests/unit/cli/test_output_transaction_log.py b/tests/integration/cli/test_output_transaction_log.py similarity index 100% rename from tests/unit/cli/test_output_transaction_log.py rename to tests/integration/cli/test_output_transaction_log.py diff --git a/tests/unit/conftest.py b/tests/integration/conftest.py similarity index 100% rename from tests/unit/conftest.py rename to tests/integration/conftest.py diff --git a/tests/unit/validators/conftest.py b/tests/integration/plugins/__init__.py similarity index 100% rename from tests/unit/validators/conftest.py rename to tests/integration/plugins/__init__.py diff --git a/tests/unit/plugins/test_chapters.py b/tests/integration/plugins/test_chapters.py similarity index 100% rename from tests/unit/plugins/test_chapters.py rename to tests/integration/plugins/test_chapters.py diff --git a/tests/unit/plugins/test_file_convert.py b/tests/integration/plugins/test_file_convert.py similarity index 100% rename from tests/unit/plugins/test_file_convert.py rename to tests/integration/plugins/test_file_convert.py diff --git a/tests/unit/plugins/test_filter.py b/tests/integration/plugins/test_filter.py similarity index 100% rename from tests/unit/plugins/test_filter.py rename to tests/integration/plugins/test_filter.py diff --git a/tests/unit/plugins/test_music_tags.py b/tests/integration/plugins/test_music_tags.py similarity index 100% rename from tests/unit/plugins/test_music_tags.py rename to tests/integration/plugins/test_music_tags.py diff --git a/tests/unit/plugins/test_nfo_tags.py b/tests/integration/plugins/test_nfo_tags.py similarity index 98% rename from tests/unit/plugins/test_nfo_tags.py rename to tests/integration/plugins/test_nfo_tags.py index 06a36698..7172753a 100644 --- a/tests/unit/plugins/test_nfo_tags.py +++ b/tests/integration/plugins/test_nfo_tags.py @@ -1,6 +1,5 @@ import pytest from expected_transaction_log import assert_transaction_log_matches -from unit.conftest import mock_download_collection_entries from ytdl_sub.subscriptions.subscription import Subscription diff --git a/tests/unit/plugins/test_output_options.py b/tests/integration/plugins/test_output_options.py similarity index 100% rename from tests/unit/plugins/test_output_options.py rename to tests/integration/plugins/test_output_options.py diff --git a/tests/unit/plugins/test_throttle_protection.py b/tests/integration/plugins/test_throttle_protection.py similarity index 100% rename from tests/unit/plugins/test_throttle_protection.py rename to tests/integration/plugins/test_throttle_protection.py diff --git a/tests/integration/prebuilt_presets/__init__.py b/tests/integration/prebuilt_presets/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/prebuilt_presets/test_prebuilt_presets.py b/tests/integration/prebuilt_presets/test_prebuilt_presets.py similarity index 100% rename from tests/unit/prebuilt_presets/test_prebuilt_presets.py rename to tests/integration/prebuilt_presets/test_prebuilt_presets.py diff --git a/tests/unit/prebuilt_presets/test_prebuilt_presets_packaged.py b/tests/integration/prebuilt_presets/test_prebuilt_presets_packaged.py similarity index 100% rename from tests/unit/prebuilt_presets/test_prebuilt_presets_packaged.py rename to tests/integration/prebuilt_presets/test_prebuilt_presets_packaged.py diff --git a/tests/unit/cli/test_working_directory_lock.py b/tests/unit/cli/test_working_directory_lock.py index 8787ac78..1e69433a 100644 --- a/tests/unit/cli/test_working_directory_lock.py +++ b/tests/unit/cli/test_working_directory_lock.py @@ -9,28 +9,21 @@ from ytdl_sub.utils.file_lock import working_directory_lock from ytdl_sub.utils.system import IS_WINDOWS -@pytest.fixture -def config() -> ConfigFile: - return ConfigFile( - name="config", value={"configuration": {"working_directory": "test"}, "presets": {}} - ) - - -def test_working_directory_lock(config: ConfigFile): +def test_working_directory_lock(default_config: ConfigFile): if IS_WINDOWS: return new_pid = os.fork() if new_pid == 0: # is child - with working_directory_lock(config=config): + with working_directory_lock(config=default_config): time.sleep(3) return time.sleep(1) with pytest.raises(ValidationException, match="Cannot run two instances of ytdl-sub"): - with working_directory_lock(config=config): + with working_directory_lock(config=default_config): time.sleep(1) time.sleep(3) - with working_directory_lock(config=config): + with working_directory_lock(config=default_config): pass