assertical 0.2.0__tar.gz → 0.2.1__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.
- {assertical-0.2.0/src/assertical.egg-info → assertical-0.2.1}/PKG-INFO +1 -1
- {assertical-0.2.0 → assertical-0.2.1}/pyproject.toml +1 -1
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/fake/generator.py +9 -5
- {assertical-0.2.0 → assertical-0.2.1/src/assertical.egg-info}/PKG-INFO +1 -1
- {assertical-0.2.0 → assertical-0.2.1}/LICENSE.txt +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/README.md +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/setup.cfg +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/__init__.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/asserts/__init__.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/asserts/generator.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/asserts/pandas.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/asserts/time.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/asserts/type.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/fake/__init__.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/fake/asyncio.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/fake/http.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/fake/sqlalchemy.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/fixtures/__init__.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/fixtures/environment.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/fixtures/fastapi.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/fixtures/generator.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/fixtures/postgres.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/py.typed +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical/snapshot.py +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical.egg-info/SOURCES.txt +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical.egg-info/dependency_links.txt +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical.egg-info/requires.txt +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/src/assertical.egg-info/top_level.txt +0 -0
- {assertical-0.2.0 → assertical-0.2.1}/tests/test_snapshot.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: assertical
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Assertical - a modular library for helping write (async) integration/unit tests for fastapi/sqlalchemy/postgres projects
|
|
5
5
|
Author: Battery Storage and Grid Integration Program
|
|
6
6
|
Project-URL: Homepage, https://github.com/bsgip/assertical
|
|
@@ -30,7 +30,7 @@ build-backend = "setuptools.build_meta"
|
|
|
30
30
|
|
|
31
31
|
[project]
|
|
32
32
|
name = "assertical"
|
|
33
|
-
version = "0.2.
|
|
33
|
+
version = "0.2.1"
|
|
34
34
|
description = "Assertical - a modular library for helping write (async) integration/unit tests for fastapi/sqlalchemy/postgres projects"
|
|
35
35
|
authors = [{ name = "Battery Storage and Grid Integration Program" }]
|
|
36
36
|
readme = "README.md"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import sys
|
|
2
1
|
import inspect
|
|
2
|
+
import sys
|
|
3
3
|
from dataclasses import dataclass, fields, is_dataclass
|
|
4
4
|
from datetime import datetime, time, timedelta, timezone
|
|
5
5
|
from decimal import Decimal
|
|
@@ -9,6 +9,7 @@ from typing import (
|
|
|
9
9
|
Callable,
|
|
10
10
|
Generator,
|
|
11
11
|
Optional,
|
|
12
|
+
TypeVar,
|
|
12
13
|
Union,
|
|
13
14
|
cast,
|
|
14
15
|
get_args,
|
|
@@ -84,6 +85,9 @@ class _PlaceholderDataclassBase:
|
|
|
84
85
|
"""Dataclass has no base class - instead we fall back to using this as a placeholder"""
|
|
85
86
|
|
|
86
87
|
|
|
88
|
+
AnyType = TypeVar("AnyType")
|
|
89
|
+
|
|
90
|
+
|
|
87
91
|
def safe_is_subclass(class_to_check: Optional[type], parent_class: type) -> bool:
|
|
88
92
|
if class_to_check is None:
|
|
89
93
|
return False
|
|
@@ -365,13 +369,13 @@ def enumerate_class_properties(t: type) -> Generator[PropertyGenerationDetails,
|
|
|
365
369
|
|
|
366
370
|
|
|
367
371
|
def generate_class_instance( # noqa: C901
|
|
368
|
-
t: type,
|
|
372
|
+
t: type[AnyType],
|
|
369
373
|
seed: int = 1,
|
|
370
374
|
optional_is_none: bool = False,
|
|
371
375
|
generate_relationships: bool = False,
|
|
372
376
|
_visited_type_stack: Optional[list[type]] = None,
|
|
373
377
|
**kwargs: Any,
|
|
374
|
-
) ->
|
|
378
|
+
) -> AnyType:
|
|
375
379
|
"""Given a child class of a key to CLASS_INSTANCE_GENERATORS - generate an instance of that class
|
|
376
380
|
with all properties being assigned unique values based off of seed. The values will match type hints
|
|
377
381
|
|
|
@@ -395,7 +399,7 @@ def generate_class_instance( # noqa: C901
|
|
|
395
399
|
if _visited_type_stack is None:
|
|
396
400
|
_visited_type_stack = []
|
|
397
401
|
if t in _visited_type_stack:
|
|
398
|
-
return None
|
|
402
|
+
return None # type: ignore # This only happens in recursion - the top level object will never be None
|
|
399
403
|
_visited_type_stack.append(t)
|
|
400
404
|
|
|
401
405
|
# We can only generate class instances of classes that inherit from a known base
|
|
@@ -483,7 +487,7 @@ def generate_class_instance( # noqa: C901
|
|
|
483
487
|
return CLASS_INSTANCE_GENERATORS[t_generatable_base](t, values)
|
|
484
488
|
|
|
485
489
|
|
|
486
|
-
def clone_class_instance(obj:
|
|
490
|
+
def clone_class_instance(obj: AnyType, ignored_properties: Optional[set[str]] = None) -> AnyType:
|
|
487
491
|
"""Given an instance of a child class of a key to CLASS_INSTANCE_GENERATORS - generate a new instance of that class
|
|
488
492
|
using references to the values in the current public properties in obj (i.e. a shallow clone).
|
|
489
493
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: assertical
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Assertical - a modular library for helping write (async) integration/unit tests for fastapi/sqlalchemy/postgres projects
|
|
5
5
|
Author: Battery Storage and Grid Integration Program
|
|
6
6
|
Project-URL: Homepage, https://github.com/bsgip/assertical
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|