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.
Files changed (21) hide show
  1. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/PKG-INFO +1 -1
  2. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/pyproject.toml +1 -1
  3. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/__init__.py +1 -1
  4. fastapi_toolsets-0.2.0/src/fastapi_toolsets/fixtures/__init__.py +27 -0
  5. fastapi_toolsets-0.2.0/src/fastapi_toolsets/fixtures/utils.py +26 -0
  6. fastapi_toolsets-0.1.0/src/fastapi_toolsets/fixtures/__init__.py +0 -17
  7. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/LICENSE +0 -0
  8. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/README.md +0 -0
  9. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/cli/__init__.py +0 -0
  10. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/cli/app.py +0 -0
  11. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/cli/commands/__init__.py +0 -0
  12. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/cli/commands/fixtures.py +0 -0
  13. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/crud.py +0 -0
  14. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/db.py +0 -0
  15. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/exceptions/__init__.py +0 -0
  16. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/exceptions/exceptions.py +0 -0
  17. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/exceptions/handler.py +0 -0
  18. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/fixtures/fixtures.py +0 -0
  19. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/fixtures/pytest_plugin.py +0 -0
  20. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/py.typed +0 -0
  21. {fastapi_toolsets-0.1.0 → fastapi_toolsets-0.2.0}/src/fastapi_toolsets/schemas.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-toolsets
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Reusable tools for FastAPI: async CRUD, fixtures, CLI, and standardized responses for SQLAlchemy + PostgreSQL
5
5
  Keywords: fastapi,sqlalchemy,postgresql
6
6
  Author: d3vyce
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fastapi-toolsets"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "Reusable tools for FastAPI: async CRUD, fixtures, CLI, and standardized responses for SQLAlchemy + PostgreSQL"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -21,4 +21,4 @@ Example usage:
21
21
  return Response(data={"user": user.username}, message="Success")
22
22
  """
23
23
 
24
- __version__ = "0.1.0"
24
+ __version__ = "0.2.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
- ]