Skip to content

Commit

Permalink
Add support for 2.10.5 (#23)
Browse files Browse the repository at this point in the history
- Add new elements to API response elements, per 2.10.5 Tautulli update: https://github.com/Tautulli/Tautulli/releases/tag/v2.10.5
- Update server version support calculation
- Test multiple server versions, multiple Python versions in CI
  • Loading branch information
nwithan8 authored Nov 11, 2022
1 parent 7e61f2f commit b06dda8
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 72 deletions.
67 changes: 23 additions & 44 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,74 +6,53 @@ on:
pull_request: ~

jobs:
unit-tests:
versions:
runs-on: ubuntu-latest
services:
tautulli-docker:
image: tautulli/tautulli
ports:
- 8001:8181

outputs:
server_versions: ${{ steps.set-server-versions.outputs.server_versions }}
python_versions: ${{ steps.set-python-versions.outputs.python_versions }}
steps:
- name: Sleep for 30 seconds
uses: jakejarvis/wait-action@master
with:
time: '30s'

- name: Checkout code
uses: actions/checkout@v2

- name: Make envfile
uses: SpicyPizza/create-envfile@v1
with:
envkey_T_URL: http://localhost:8001
file_name: .env

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
make install
- uses: actions/checkout@v2
- id: set-server-versions
run: echo "::set-output name=server_versions::$(cat tautulli/API_VERSIONS | jq -R -s -c 'split("\n")')"
- id: set-python-versions
run: echo "::set-output name=python_versions::$(cat tautulli/PYTHON_VERSIONS | jq -R -s -c 'split("\n")')"

- name: Test with pytest
run: make test

compatibility:
unit-tests:
needs: versions
runs-on: ubuntu-latest
strategy:
matrix:
image_version: ${{ fromJson(needs.versions.outputs.server_versions) }}
python_version: ${{ fromJson(needs.versions.outputs.python_versions) }}
services:
tautulli-docker:
image: tautulli/tautulli
image: tautulli/tautulli:v${{ matrix.image_version }}
ports:
- 8001:8181

steps:
- name: Matrix => (${{ matrix.image_version }} ${{ matrix.python_version}})
run: |
echo ${{ matrix.image_version }}
echo ${{ matrix.python_version }}
- name: Sleep for 30 seconds
uses: jakejarvis/wait-action@master
with:
time: '30s'

- name: Checkout code
uses: actions/checkout@v2

- name: Make envfile
uses: SpicyPizza/create-envfile@v1
with:
envkey_T_URL: http://localhost:8001
file_name: .env

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"

python-version: ${{ matrix.python_version }}
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
make install
- name: Test compatibility with tox
run: make test-compatibility
- name: Test with pytest
run: make test
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ install:
install-pypy:
$(PYTHON_BINARY) -m venv $(VIRTUAL_ENV)
$(VIRTUAL_BIN)/pip install -e ."[pypy_dev]"

## install-pyenv - Install pyenv
install-pyenv:
curl https://pyenv.run | bash

## change-python - Change the python version used by pyenv
# params:
# py-= The python version to use
change-python:
pyenv local $(py)

## isort - Sorts imports throughout the project
isort:
$(VIRTUAL_BIN)/isort $(PROJECT_NAME)/ $(TEST_DIR)/
Expand All @@ -66,10 +77,4 @@ mypy:
test:
$(VIRTUAL_BIN)/pytest --exitfirst --verbose --failed-first

## test-compatibility - Test the project against multiple Python versions
test-compatibility:
pyenv local 3.7.15 3.8.15 3.9.15 3.10.8 3.11.0 # install Python versions
$(VIRTUAL_BIN)/pip install tox
$(VIRTUAL_BIN)/tox

.PHONY: help build coverage clean black black-check format format-check install isort isort-check lint mypy test test-compatibility
.PHONY: help build coverage clean black black-check format format-check install install-pypy install-pyenv change-python isort isort-check lint mypy test
51 changes: 33 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@
with open("README.md", "r") as fh:
long_description = fh.read()


def python_versions():
"""Return a list of supported Python versions."""
with open("tautulli/PYTHON_VERSIONS") as f:
versions = f.read().splitlines()
version_strings = ['Programming Language :: Python :: 3']
for version in versions:
version_strings.append(f"Programming Language :: Python :: {version}")
return version_strings


def python3_range():
"""Return a string of the supported Python version range."""
with open("tautulli/PYTHON_VERSIONS") as f:
versions = f.read().splitlines()
return f">={versions[0]}, <4"


REQUIREMENTS = [
"objectrest==2.0.*",
"pydantic==1.10.*",
Expand All @@ -36,6 +54,19 @@
"vcrpy==4.*",
]

classifiers = [
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Development Status :: 4 - Beta',
# Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
'Intended Audience :: Developers', # Define that your audience are developers
'Topic :: Software Development :: Build Tools',
'Topic :: Multimedia :: Video',
'Topic :: Multimedia',
'Topic :: Internet :: WWW/HTTP',
'Operating System :: OS Independent'
]
classifiers.extend(python_versions())

setuptools.setup(
name=__title__,
packages=setuptools.find_packages(exclude=["tests"]),
Expand All @@ -54,22 +85,6 @@
"dev": DEV_REQUIREMENTS,
},
test_suite="test",
classifiers=[
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Development Status :: 4 - Beta',
# Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
'Intended Audience :: Developers', # Define that your audience are developers
'Topic :: Software Development :: Build Tools',
'Programming Language :: Python :: 3', # Specify which python versions that you want to support
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Multimedia :: Video',
'Topic :: Multimedia',
'Topic :: Internet :: WWW/HTTP',
'Operating System :: OS Independent'
],
python_requires='>=3.7, <4'
classifiers=classifiers,
python_requires=python3_range(),
)
3 changes: 3 additions & 0 deletions tautulli/API_VERSIONS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2.10.3
2.10.4
2.10.5
5 changes: 5 additions & 0 deletions tautulli/PYTHON_VERSIONS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
3.7
3.8
3.9
3.10
3.11
12 changes: 11 additions & 1 deletion tautulli/_info.py
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
__min_api_version__ = "2.10.3"
import os
from typing import List


def __supported_api_versions__() -> List[str]:
with open(os.path.join(os.path.dirname(__file__), "API_VERSIONS")) as f:
return f.read().splitlines()


def __min_api_version__() -> str:
return __supported_api_versions__()[0]
5 changes: 3 additions & 2 deletions tautulli/api/json_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ def __init__(self, base_url: str, api_key: str, verbose: bool = False, verify: b
self._session = objectrest.Session()
logging.basicConfig(format='%(levelname)s:%(message)s', level=(logging.DEBUG if verbose else logging.ERROR))
self._logger = logging.getLogger("tautulli")
if verify and not self._verify_compatibility(min_version=__min_api_version__):
warnings.warn(f"Tautulli API is older than {__min_api_version__}, things may not work as expected.")
min_api_version = __min_api_version__()
if verify and not self._verify_compatibility(min_version=min_api_version):
warnings.warn(f"Tautulli API is older than {min_api_version}, things may not work as expected.")

def __str__(self):
return f"RawAPI(url={self._redacted_url})"
Expand Down
1 change: 1 addition & 0 deletions tautulli/models/children_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ChildrenListItem(BaseModel):
directors: Optional[List]
duration: Optional[str]
full_title: Optional[str]
collections: Optional[List]
genres: Optional[List]
grandparent_rating_key: Optional[str]
grandparent_thumb: Optional[str]
Expand Down
1 change: 1 addition & 0 deletions tautulli/models/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Datum(BaseModel):
user_id: Optional[int]
user: Optional[str]
friendly_name: Optional[str]
user_thumb: Optional[str]
platform: Optional[str]
product: Optional[str]
player: Optional[str]
Expand Down
1 change: 1 addition & 0 deletions tautulli/models/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class Data(BaseModel):
grandparent_title: Optional[str]
original_title: Optional[str]
sort_title: Optional[str]
edition_title: Optional[str]
media_index: Optional[str]
parent_media_index: Optional[str]
studio: Optional[str]
Expand Down

0 comments on commit b06dda8

Please sign in to comment.