Skip to content

Commit

Permalink
Commit missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
kutu-dev committed Sep 15, 2023
1 parent a133d6f commit 70c2aa6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
16 changes: 16 additions & 0 deletions src/knuckles/system.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from dataclasses import dataclass

from .api import Api
from .models.system import License, SubsonicResponse


@dataclass
class OpenSubsonicExtension:
name: str
versions: list[int]


class System:
"""Class that contains all the methods needed to interact
with the systems calls in the Subsonic API.
Expand Down Expand Up @@ -34,3 +42,11 @@ def get_license(self) -> License:
response = self.api.request("getLicense")["license"]

return License(**response)

def get_open_subsonic_extensions(self) -> list[OpenSubsonicExtension]:
response = self.api.request("getOpenSubsonicExtensions")[
"openSubsonicExtensions"
]
return [
OpenSubsonicExtension(name, versions) for name, versions in response.items()
]
6 changes: 4 additions & 2 deletions tests/api/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ def test_auth_without_token(
def test_get_open_subsonic_extensions(
subsonic: Subsonic,
mock_get_open_subsonic_extensions: Response,
open_subsonic_extensions: dict[str, Any],
open_subsonic_extension_name: str,
open_subsonic_extension_versions: list[int],
) -> None:
responses.add(mock_get_open_subsonic_extensions)

response = subsonic.system.get_open_subsonic_extensions()

assert response == open_subsonic_extensions
assert response[0].name == open_subsonic_extension_name
assert response[0].versions == open_subsonic_extension_versions
16 changes: 14 additions & 2 deletions tests/mocks/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,20 @@ def mock_auth_without_token(mock_generator: MockGenerator, password: str) -> Res


@pytest.fixture
def open_subsonic_extensions() -> dict[str, Any]:
return {"template": [1, 2], "extension2": [2, 3]}
def open_subsonic_extension_name() -> str:
return "extensionName"


@pytest.fixture
def open_subsonic_extension_versions() -> list[int]:
return [1, 2]


@pytest.fixture
def open_subsonic_extensions(
open_subsonic_extension_name: str, open_subsonic_extension_versions: list[int]
) -> dict[str, Any]:
return {open_subsonic_extension_name: open_subsonic_extension_versions}


@pytest.fixture
Expand Down

0 comments on commit 70c2aa6

Please sign in to comment.