mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 05:25:26 +02:00
* fix #1144 * fix type checks * refactor test routes package * fix #1208 * unify test routes into module
This commit is contained in:
parent
07f6446526
commit
68f7efc177
23 changed files with 189 additions and 148 deletions
6
tests/utils/routes/__init__.py
Normal file
6
tests/utils/routes/__init__.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from . import routes_admin as admin
|
||||
from . import routes_organizers as organizers
|
||||
from . import routes_recipes as recipes
|
||||
from . import routes_seeders as seeders
|
||||
from . import routes_user as user
|
||||
from ._base import RoutesBase
|
17
tests/utils/routes/_base.py
Normal file
17
tests/utils/routes/_base.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from pydantic import UUID4
|
||||
|
||||
|
||||
def v1(route: str) -> str:
|
||||
return f"/api{route}"
|
||||
|
||||
|
||||
class RoutesBase:
|
||||
prefix = "/api"
|
||||
base = f"{prefix}/"
|
||||
|
||||
def __init__(self) -> None:
|
||||
raise NotImplementedError("This class is not meant to be instantiated.")
|
||||
|
||||
@classmethod
|
||||
def item(cls, item_id: int | str | UUID4) -> str:
|
||||
return f"{cls.base}/{item_id}"
|
5
tests/utils/routes/routes_admin.py
Normal file
5
tests/utils/routes/routes_admin.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from ._base import RoutesBase, v1
|
||||
|
||||
|
||||
class AdminUsers(RoutesBase):
|
||||
base = v1("/admin/users")
|
19
tests/utils/routes/routes_organizers.py
Normal file
19
tests/utils/routes/routes_organizers.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from ._base import RoutesBase, v1
|
||||
|
||||
|
||||
class RoutesOrganizerBase(RoutesBase):
|
||||
@classmethod
|
||||
def slug(cls, slug: str) -> str:
|
||||
return f"{cls.base}/slug/{slug}"
|
||||
|
||||
|
||||
class Tools(RoutesOrganizerBase):
|
||||
base = v1("/organizers/tools")
|
||||
|
||||
|
||||
class Tags(RoutesOrganizerBase):
|
||||
base = v1("/organizers/tags")
|
||||
|
||||
|
||||
class Categories(RoutesOrganizerBase):
|
||||
base = v1("/organizers/categories")
|
13
tests/utils/routes/routes_recipes.py
Normal file
13
tests/utils/routes/routes_recipes.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from ._base import RoutesBase, v1
|
||||
|
||||
|
||||
class Foods(RoutesBase):
|
||||
base = v1("/foods")
|
||||
|
||||
|
||||
class Units(RoutesBase):
|
||||
base = v1("/units")
|
||||
|
||||
|
||||
class Recipe(RoutesBase):
|
||||
base = v1("/recipes")
|
9
tests/utils/routes/routes_seeders.py
Normal file
9
tests/utils/routes/routes_seeders.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from ._base import RoutesBase, v1
|
||||
|
||||
|
||||
class Seeders(RoutesBase):
|
||||
base = v1("/groups/seeders")
|
||||
|
||||
foods = f"{base}/foods"
|
||||
units = f"{base}/units"
|
||||
labels = f"{base}/labels"
|
6
tests/utils/routes/routes_user.py
Normal file
6
tests/utils/routes/routes_user.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from ._base import RoutesBase, v1
|
||||
|
||||
|
||||
class Users(RoutesBase):
|
||||
base = v1("/users")
|
||||
self = f"{base}/self"
|
Loading…
Add table
Add a link
Reference in a new issue