fastapi-toolsets 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/PKG-INFO +1 -1
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/pyproject.toml +1 -1
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/__init__.py +1 -1
- fastapi_toolsets-0.2.0/src/fastapi_toolsets/fixtures/__init__.py +27 -0
- fastapi_toolsets-0.2.0/src/fastapi_toolsets/fixtures/utils.py +26 -0
- fastapi_toolsets-0.1.0/src/fastapi_toolsets/fixtures/__init__.py +0 -17
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/LICENSE +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/README.md +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/cli/__init__.py +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/cli/app.py +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/cli/commands/__init__.py +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/cli/commands/fixtures.py +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/crud.py +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/db.py +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/exceptions/__init__.py +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/exceptions/exceptions.py +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/exceptions/handler.py +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/fixtures/fixtures.py +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/fixtures/pytest_plugin.py +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/py.typed +0 -0
- {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/schemas.py +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from .fixtures import (
|
|
2
|
+
Context,
|
|
3
|
+
FixtureRegistry,
|
|
4
|
+
LoadStrategy,
|
|
5
|
+
load_fixtures,
|
|
6
|
+
load_fixtures_by_context,
|
|
7
|
+
)
|
|
8
|
+
from .utils import get_obj_by_attr
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"Context",
|
|
12
|
+
"FixtureRegistry",
|
|
13
|
+
"LoadStrategy",
|
|
14
|
+
"get_obj_by_attr",
|
|
15
|
+
"load_fixtures",
|
|
16
|
+
"load_fixtures_by_context",
|
|
17
|
+
"register_fixtures",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# We lazy-load register_fixtures to avoid needing pytest when using fixtures CLI
|
|
22
|
+
def __getattr__(name: str):
|
|
23
|
+
if name == "register_fixtures":
|
|
24
|
+
from .pytest_plugin import register_fixtures
|
|
25
|
+
|
|
26
|
+
return register_fixtures
|
|
27
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from collections.abc import Callable, Sequence
|
|
2
|
+
from typing import Any, TypeVar
|
|
3
|
+
|
|
4
|
+
from sqlalchemy.orm import DeclarativeBase
|
|
5
|
+
|
|
6
|
+
T = TypeVar("T", bound=DeclarativeBase)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_obj_by_attr(
|
|
10
|
+
fixtures: Callable[[], Sequence[T]], attr_name: str, value: Any
|
|
11
|
+
) -> T:
|
|
12
|
+
"""Get a SQLAlchemy model instance by matching an attribute value.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
fixtures: A fixture function registered via ``@registry.register``
|
|
16
|
+
that returns a sequence of SQLAlchemy model instances.
|
|
17
|
+
attr_name: Name of the attribute to match against.
|
|
18
|
+
value: Value to match.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
The first model instance where the attribute matches the given value.
|
|
22
|
+
|
|
23
|
+
Raises:
|
|
24
|
+
StopIteration: If no matching object is found.
|
|
25
|
+
"""
|
|
26
|
+
return next(obj for obj in fixtures() if getattr(obj, attr_name) == value)
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
from .fixtures import (
|
|
2
|
-
Context,
|
|
3
|
-
FixtureRegistry,
|
|
4
|
-
LoadStrategy,
|
|
5
|
-
load_fixtures,
|
|
6
|
-
load_fixtures_by_context,
|
|
7
|
-
)
|
|
8
|
-
from .pytest_plugin import register_fixtures
|
|
9
|
-
|
|
10
|
-
__all__ = [
|
|
11
|
-
"Context",
|
|
12
|
-
"FixtureRegistry",
|
|
13
|
-
"LoadStrategy",
|
|
14
|
-
"load_fixtures",
|
|
15
|
-
"load_fixtures_by_context",
|
|
16
|
-
"register_fixtures",
|
|
17
|
-
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/cli/commands/__init__.py
RENAMED
|
File without changes
|
{fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/cli/commands/fixtures.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/exceptions/__init__.py
RENAMED
|
File without changes
|
{fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/exceptions/exceptions.py
RENAMED
|
File without changes
|
{fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/exceptions/handler.py
RENAMED
|
File without changes
|
|
File without changes
|
{fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/fixtures/pytest_plugin.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|