Skip to content
Snippets Groups Projects
Verified Commit e189d1f5 authored by Georg Krause's avatar Georg Krause
Browse files

Fix all favorite test case

parent c31aa7fe
No related branches found
No related tags found
1 merge request!1Add basic model tests
Pipeline #23713 failed
......@@ -3,7 +3,7 @@ from typing import Any, Dict, Optional
import httpx
from ...client import AuthenticatedClient
from ...models.user_track_favorite import UserTrackFavorite
from ...models.all_favorite import AllFavorite
from ...types import Response
......@@ -25,15 +25,15 @@ def _get_kwargs(
}
def _parse_response(*, response: httpx.Response) -> Optional[UserTrackFavorite]:
def _parse_response(*, response: httpx.Response) -> Optional[AllFavorite]:
if response.status_code == 200:
response_200 = UserTrackFavorite.from_dict(response.json())
response_200 = AllFavorite.from_dict(response.json())
return response_200
return None
def _build_response(*, response: httpx.Response) -> Response[UserTrackFavorite]:
def _build_response(*, response: httpx.Response) -> Response[AllFavorite]:
return Response(
status_code=response.status_code,
content=response.content,
......@@ -45,13 +45,13 @@ def _build_response(*, response: httpx.Response) -> Response[UserTrackFavorite]:
def sync_detailed(
*,
client: AuthenticatedClient,
) -> Response[UserTrackFavorite]:
) -> Response[AllFavorite]:
"""Return all the favorites of the current user, with only limited data
to have a performant endpoint and avoid lots of queries just to display
favorites status in the UI
Returns:
Response[UserTrackFavorite]
Response[AllFavorite]
"""
kwargs = _get_kwargs(
......@@ -69,13 +69,13 @@ def sync_detailed(
def sync(
*,
client: AuthenticatedClient,
) -> Optional[UserTrackFavorite]:
) -> Optional[AllFavorite]:
"""Return all the favorites of the current user, with only limited data
to have a performant endpoint and avoid lots of queries just to display
favorites status in the UI
Returns:
Response[UserTrackFavorite]
Response[AllFavorite]
"""
return sync_detailed(
......@@ -86,13 +86,13 @@ def sync(
async def asyncio_detailed(
*,
client: AuthenticatedClient,
) -> Response[UserTrackFavorite]:
) -> Response[AllFavorite]:
"""Return all the favorites of the current user, with only limited data
to have a performant endpoint and avoid lots of queries just to display
favorites status in the UI
Returns:
Response[UserTrackFavorite]
Response[AllFavorite]
"""
kwargs = _get_kwargs(
......@@ -108,13 +108,13 @@ async def asyncio_detailed(
async def asyncio(
*,
client: AuthenticatedClient,
) -> Optional[UserTrackFavorite]:
) -> Optional[AllFavorite]:
"""Return all the favorites of the current user, with only limited data
to have a performant endpoint and avoid lots of queries just to display
favorites status in the UI
Returns:
Response[UserTrackFavorite]
Response[AllFavorite]
"""
return (
......
......@@ -12,6 +12,7 @@ from .album_create import AlbumCreate
from .album_create_request import AlbumCreateRequest
from .album_request import AlbumRequest
from .albums_list_ordering_item import AlbumsListOrderingItem
from .all_favorite import AllFavorite
from .allow_list_stat import AllowListStat
from .api_actor import APIActor
from .api_actor_request import APIActorRequest
......@@ -253,6 +254,7 @@ from .scopes import Scopes
from .services import Services
from .simple_artist import SimpleArtist
from .simple_artist_request import SimpleArtistRequest
from .simple_favorite import SimpleFavorite
from .software import Software
from .subscription import Subscription
from .tag import Tag
......
from typing import Any, Dict, List, Type, TypeVar
import attr
from ..models.simple_favorite import SimpleFavorite
T = TypeVar("T", bound="AllFavorite")
@attr.s(auto_attribs=True)
class AllFavorite:
"""
Attributes:
results (List[SimpleFavorite]):
count (int):
"""
results: List[SimpleFavorite]
count: int
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
results = []
for results_item_data in self.results:
results_item = results_item_data.to_dict()
results.append(results_item)
count = self.count
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"results": results,
"count": count,
}
)
return field_dict
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
d = src_dict.copy()
results = []
_results = d.pop("results")
for results_item_data in _results:
results_item = SimpleFavorite.from_dict(results_item_data)
results.append(results_item)
count = d.pop("count")
all_favorite = cls(
results=results,
count=count,
)
all_favorite.additional_properties = d
return all_favorite
@property
def additional_keys(self) -> List[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties
from typing import Any, Dict, List, Type, TypeVar
import attr
T = TypeVar("T", bound="SimpleFavorite")
@attr.s(auto_attribs=True)
class SimpleFavorite:
"""
Attributes:
id (int):
track (int):
"""
id: int
track: int
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
id = self.id
track = self.track
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"id": id,
"track": track,
}
)
return field_dict
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
d = src_dict.copy()
id = d.pop("id")
track = d.pop("track")
simple_favorite = cls(
id=id,
track=track,
)
simple_favorite.additional_properties = d
return simple_favorite
@property
def additional_keys(self) -> List[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties
from funkwhale_api_client.models.all_favorite import AllFavorite
def test_AllFavorite(load_data):
response = load_data("favorites_all")
favorites: AllFavorite = AllFavorite.from_dict(response)
assert isinstance(favorites, AllFavorite)
from funkwhale_api_client.models.user_track_favorite import UserTrackFavorite
def test_UserTrackFavorite(load_data):
response = load_data("favorites_all")
favorites: UserTrackFavorite = UserTrackFavorite.from_dict(response)
assert isinstance(favorites, UserTrackFavorite)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment