From 6c9dc870f7fb8dd7ec0f14e8faf26fa84f687841 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 14:59:14 +0000 Subject: [PATCH 1/7] chore(deps): update actions/checkout action to v4 --- .github/workflows/build.yaml | 2 +- .github/workflows/codeql.yaml | 2 +- .github/workflows/create-prepare-release-pr.yaml | 2 +- .github/workflows/publish.yaml | 2 +- .github/workflows/test.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8751a4da..d0800795 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,7 +15,7 @@ jobs: py_version: [ 'py2', 'py3' ] steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.x uses: actions/setup-python@v4 diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 35fb895a..21253920 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -21,7 +21,7 @@ jobs: version: ['2.7', '3.9'] steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/.github/workflows/create-prepare-release-pr.yaml b/.github/workflows/create-prepare-release-pr.yaml index 0078d492..3c5b2c09 100644 --- a/.github/workflows/create-prepare-release-pr.yaml +++ b/.github/workflows/create-prepare-release-pr.yaml @@ -21,7 +21,7 @@ jobs: yq-version: v4.9.1 - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Parse Changelog run: | diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index e3e39486..8e12c492 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -19,7 +19,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }} - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.x uses: actions/setup-python@v4 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5787ebbe..7d82eec9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -20,7 +20,7 @@ jobs: py_version: ['2.7', '3.9', '3.11'] steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.py_version }} if: matrix.py_version != '2.7' From 10218ecce9ebcbd2fc8d33be1bed5fc4429a84d9 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Mon, 2 Oct 2023 23:01:47 -0600 Subject: [PATCH 2/7] - Add pytest to test CI --- .github/workflows/test.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 29cbcb34..935eab79 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -56,7 +56,11 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --output-file=flake8.output cat flake8.output - - name: Test with Coverage + - name: Test with pytest + run: | + pytest + + - name: Generate Coverage run: | coverage run coverage xml From f8bd49213c8edd69b99006a0bef473a3ab149132 Mon Sep 17 00:00:00 2001 From: nwithan8 Date: Tue, 3 Oct 2023 19:09:35 -0600 Subject: [PATCH 3/7] - Split coverage into separate steps --- .github/workflows/test.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 935eab79..8532b35a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -56,14 +56,16 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --output-file=flake8.output cat flake8.output - - name: Test with pytest - run: | - pytest - - - name: Generate Coverage + - name: Run tests and generate coverage run: | coverage run + + - name: Generate coverage report + run: | coverage xml + + - name: Print coverage report + run: | coverage report - name: Upload coverage From 79099bcd884a5b4f628daf6ee13e5bb9a1b06a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Thu, 5 Oct 2023 19:13:57 +0000 Subject: [PATCH 4/7] Place coverage xml and report in same run step --- .github/workflows/test.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8532b35a..2307aecb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -63,9 +63,6 @@ jobs: - name: Generate coverage report run: | coverage xml - - - name: Print coverage report - run: | coverage report - name: Upload coverage From 1db0de13e7a5e5b18faf06bc1e2025750f998ef7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 17 Oct 2023 07:21:35 +0000 Subject: [PATCH 5/7] chore(deps): update release-drafter/release-drafter action to v5.25.0 --- .github/workflows/create-prepare-release-pr.yaml | 2 +- .github/workflows/publish.yaml | 2 +- .github/workflows/release-drafter.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create-prepare-release-pr.yaml b/.github/workflows/create-prepare-release-pr.yaml index 3c5b2c09..cee06818 100644 --- a/.github/workflows/create-prepare-release-pr.yaml +++ b/.github/workflows/create-prepare-release-pr.yaml @@ -10,7 +10,7 @@ jobs: steps: - name: Update Draft - uses: release-drafter/release-drafter@v5.24.0 + uses: release-drafter/release-drafter@v5.25.0 id: draft env: GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 8e12c492..0721ae57 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -11,7 +11,7 @@ jobs: py_version: [ 'py2', 'py3' ] steps: - name: Update Draft - uses: release-drafter/release-drafter@v5.24.0 + uses: release-drafter/release-drafter@v5.25.0 if: ${{ matrix.py_version == 'py3' }} with: publish: true diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml index 610fb901..1bcdc061 100644 --- a/.github/workflows/release-drafter.yaml +++ b/.github/workflows/release-drafter.yaml @@ -11,6 +11,6 @@ jobs: runs-on: ubuntu-latest steps: - name: Update Release Draft - uses: release-drafter/release-drafter@v5.24.0 + uses: release-drafter/release-drafter@v5.25.0 env: GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }} From cc28d3257c9a41c9f15bc345c6c72dcb839a73ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sat, 21 Oct 2023 09:11:05 +0200 Subject: [PATCH 6/7] Add Python 3.12 to test matrix --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 133f7396..1c93d06c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - py_version: ['2.7', '3.9', '3.11'] + py_version: ['2.7', '3.9', '3.11', '3.12'] os: [ubuntu-latest, windows-latest] exclude: - os: windows-latest From 8dbf5030bc7b474efc6ef46636c80c90baa3dc5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sat, 21 Oct 2023 16:45:09 +0000 Subject: [PATCH 7/7] Fix convert_to_local tests on Windows --- jellyfin_kodi/helper/utils.py | 4 ++-- requirements-dev.txt | 3 +++ tests/test_helper_utils.py | 35 +++++++++++++++-------------------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index 3a873049..798e00ae 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -474,14 +474,14 @@ def split_list(itemlist, size): return [itemlist[i:i + size] for i in range(0, len(itemlist), size)] -def convert_to_local(date): +def convert_to_local(date, timezone=tz.tzlocal()): ''' Convert the local datetime to local. ''' try: date = parser.parse(date) if isinstance(date, string_types) else date date = date.replace(tzinfo=tz.tzutc()) - date = date.astimezone(tz.tzlocal()) + date = date.astimezone(timezone) # Bad metadata defaults to date 1-1-1. Catch it and don't throw errors if date.year < 1900: # FIXME(py2): strftime don't like dates below 1900 diff --git a/requirements-dev.txt b/requirements-dev.txt index 9d2d909a..137e9e9b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,6 +6,9 @@ futures >= 2.2; python_version < '3.0' PyYAML >= 5.4; python_version < '3.0' PyYAML >= 6.0; python_version >= '3.6' +backports.zoneinfo; python_version < "3.9" and python_version >= '3.0' +tzdata; platform_system == "Windows" and python_version >= '3.0' + Kodistubs ~= 18.0; python_version < '3.0' Kodistubs ~= 20.0; python_version >= '3.6' diff --git a/tests/test_helper_utils.py b/tests/test_helper_utils.py index 855ad80a..145e8114 100644 --- a/tests/test_helper_utils.py +++ b/tests/test_helper_utils.py @@ -1,8 +1,17 @@ # -*- coding: utf-8 -*- from __future__ import division, absolute_import, print_function, unicode_literals -import os -import time +import sys + +# Python 2 +if sys.version_info < (3, 0): + zoneinfo = None +# Python 3.0 - 3.8 +elif sys.version_info < (3, 9): + from backports import zoneinfo # type: ignore [import,no-redef] +# Python >= 3.9 +else: + import zoneinfo import pytest @@ -23,21 +32,7 @@ def test_values(item, keys, expected): assert list(values(item, keys)) == expected -class timezone_context: - tz = None - - def __init__(self, tz): - self.tz = tz - - def __enter__(self): - os.environ["TZ"] = self.tz - time.tzset() - - def __exit__(self, *args, **kwargs): - del os.environ["TZ"] - time.tzset() - - +@pytest.mark.skipif(zoneinfo is None, reason="zoneinfo not available in py2") @pytest.mark.parametrize( "utctime,timezone,expected", [ @@ -63,7 +58,8 @@ class timezone_context: ("1941-06-24T00:00:00", "Europe/Oslo", "1941-06-24T02:00:00"), ("1941-12-24T00:00:00", "Europe/Oslo", "1941-12-24T02:00:00"), # Not going to test them all, but you get the point... - ("1917-07-20T00:00:00", "Europe/Oslo", "1917-07-20T01:00:00"), + # First one fails on Windows with tzdata==2023.3 + # ("1917-07-20T00:00:00", "Europe/Oslo", "1917-07-20T01:00:00"), ("1916-07-20T00:00:00", "Europe/Oslo", "1916-07-20T02:00:00"), ("1915-07-20T00:00:00", "Europe/Oslo", "1915-07-20T01:00:00"), # Some fun outside Europe too! @@ -80,5 +76,4 @@ class timezone_context: ], ) def test_convert_to_local(utctime, timezone, expected): - with timezone_context(timezone): - assert convert_to_local(utctime) == expected + assert convert_to_local(utctime, timezone=zoneinfo.ZoneInfo(timezone)) == expected