python-general-be-lib 0.11.0__tar.gz → 0.11.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.
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/PKG-INFO +1 -1
- python_general_be_lib-0.11.1/general/utils/__init__.py +3 -0
- python_general_be_lib-0.11.1/general/utils/consts.py +6 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/pyproject.toml +1 -1
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/python_general_be_lib.egg-info/PKG-INFO +1 -1
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/python_general_be_lib.egg-info/SOURCES.txt +3 -0
- python_general_be_lib-0.11.1/tests/test_engine_defaults.py +103 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_import_pubblici.py +5 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/LICENSE +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/README.md +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/__init__.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/context.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/exception/__init__.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/exception/access_exceptions.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/exception/crud_exceptions.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/exception/exception_interface.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/__init__.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/base/__init__.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/base/base_model.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/base/declarative_base.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/metadata/__init__.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/metadata/crud_metadata.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/metadata/geom_metadata.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/mixin/__init__.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/mixin/audit_mixin.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/mixin/softdelete_mixin.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/mixin/timestamp_mixin.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/__init__.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/crud_repository.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/geometry_repository.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/handler/__init__.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/handler/base_handler.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/handler/handler.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/handler/ilike_handler.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/handler/interval_handler.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/handler/json_handler.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/handler/json_ilike_handler.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/handler/or_handler.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/handler/soft_delete_handler.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/handler/statement_manager.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/many_to_many_repository.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/repository/view_repository.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/logger.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/paginator_dto.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/py.typed +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/python_general_be_lib.egg-info/dependency_links.txt +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/python_general_be_lib.egg-info/requires.txt +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/python_general_be_lib.egg-info/top_level.txt +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/setup.cfg +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_caricamento_parziale.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_compiled_cache.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_entity_has_columns.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_execute_contratto.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_exists.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_find_one.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_get.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_has_columns.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_logger.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_many_to_many.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_metadata_eccezioni.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_metadata_geom.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_metadata_paginazione.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_metadata_pipeline.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_metadata_scorciatoie.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_mixin.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_negazione.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_ordinamento.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_pipeline_handler.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_query_count.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_retrieve_mapper.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_smoke_crud.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_softdelete.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_sql_snapshot.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_to_dict.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_to_pydantic.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_upsert_chiavi.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_valori_falsy.py +0 -0
- {python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_view_repository.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-general-be-lib
|
|
3
|
-
Version: 0.11.
|
|
3
|
+
Version: 0.11.1
|
|
4
4
|
Summary: General purpose backend library — SQLAlchemy CRUD/Geometry repositories, FastAPI exceptions, Pydantic base models, logger utilities.
|
|
5
5
|
Author-email: Andrea Di Placido <a.diplacido@arpes.it>, "Arpes S.r.l." <it.admin@arpes.it>
|
|
6
6
|
License: MIT
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python-general-be-lib"
|
|
7
|
-
version = "0.11.
|
|
7
|
+
version = "0.11.1"
|
|
8
8
|
description = "General purpose backend library — SQLAlchemy CRUD/Geometry repositories, FastAPI exceptions, Pydantic base models, logger utilities."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-general-be-lib
|
|
3
|
-
Version: 0.11.
|
|
3
|
+
Version: 0.11.1
|
|
4
4
|
Summary: General purpose backend library — SQLAlchemy CRUD/Geometry repositories, FastAPI exceptions, Pydantic base models, logger utilities.
|
|
5
5
|
Author-email: Andrea Di Placido <a.diplacido@arpes.it>, "Arpes S.r.l." <it.admin@arpes.it>
|
|
6
6
|
License: MIT
|
|
@@ -36,6 +36,8 @@ general/interface/repository/handler/json_ilike_handler.py
|
|
|
36
36
|
general/interface/repository/handler/or_handler.py
|
|
37
37
|
general/interface/repository/handler/soft_delete_handler.py
|
|
38
38
|
general/interface/repository/handler/statement_manager.py
|
|
39
|
+
general/utils/__init__.py
|
|
40
|
+
general/utils/consts.py
|
|
39
41
|
python_general_be_lib.egg-info/PKG-INFO
|
|
40
42
|
python_general_be_lib.egg-info/SOURCES.txt
|
|
41
43
|
python_general_be_lib.egg-info/dependency_links.txt
|
|
@@ -43,6 +45,7 @@ python_general_be_lib.egg-info/requires.txt
|
|
|
43
45
|
python_general_be_lib.egg-info/top_level.txt
|
|
44
46
|
tests/test_caricamento_parziale.py
|
|
45
47
|
tests/test_compiled_cache.py
|
|
48
|
+
tests/test_engine_defaults.py
|
|
46
49
|
tests/test_entity_has_columns.py
|
|
47
50
|
tests/test_execute_contratto.py
|
|
48
51
|
tests/test_exists.py
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""`ENGINE_DEFAULTS` e `SESSION_DEFAULTS` (3.1 di `.claude/piano-ottimizzazioni.md`).
|
|
2
|
+
|
|
3
|
+
La voce 3.1 proponeva un `build_engine(...)` ed è stata **scartata**: la configurazione
|
|
4
|
+
dell'engine dipende dal profilo di carico del singolo BE, e una libreria di accesso ai dati
|
|
5
|
+
che decide al posto dell'applicazione sposta la responsabilità dove ci sono meno
|
|
6
|
+
informazioni per deciderla.
|
|
7
|
+
|
|
8
|
+
Le costanti chiudono la stessa esigenza senza prendere possesso di niente: sono **dati** che
|
|
9
|
+
l'applicativo espande nella propria `create_engine`/`sessionmaker`, e che può ispezionare o
|
|
10
|
+
scartare. La regola su cosa può entrarci è ciò che questi test difendono: **solo chiavi
|
|
11
|
+
portabili fra le classi di pool**. Le altre stanno in una costante separata.
|
|
12
|
+
|
|
13
|
+
Nessun test qui apre una connessione: `create_engine` non si connette, quindi anche l'URL
|
|
14
|
+
PostgreSQL è verificabile senza database.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import pytest
|
|
20
|
+
from sqlalchemy import create_engine
|
|
21
|
+
from sqlalchemy.orm import sessionmaker
|
|
22
|
+
from sqlalchemy.pool import QueuePool, SingletonThreadPool
|
|
23
|
+
|
|
24
|
+
from general.utils import ENGINE_DEFAULTS, ENGINE_DEFAULTS_QUEUE_POOL, SESSION_DEFAULTS
|
|
25
|
+
|
|
26
|
+
PG_URL = "postgresql+psycopg://utente:password@localhost:1/inesistente"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pytest.fixture
|
|
30
|
+
def url_su_file(tmp_path) -> str:
|
|
31
|
+
return f"sqlite:///{tmp_path / 'prova.sqlite'}"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# ------------------------------------------------------------------ portabilità
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_la_classe_di_pool_dipende_dall_url_non_dal_dialetto(url_su_file: str) -> None:
|
|
38
|
+
"""È la premessa di tutto il resto, e non è ovvia.
|
|
39
|
+
|
|
40
|
+
SQLite **in memoria** usa `SingletonThreadPool`, SQLite **su file** usa `QueuePool`
|
|
41
|
+
come PostgreSQL: lo stesso dialetto accetta o rifiuta le stesse opzioni a seconda
|
|
42
|
+
dell'URL.
|
|
43
|
+
"""
|
|
44
|
+
assert isinstance(create_engine("sqlite://").pool, SingletonThreadPool)
|
|
45
|
+
assert isinstance(create_engine(url_su_file).pool, QueuePool)
|
|
46
|
+
assert isinstance(create_engine(PG_URL).pool, QueuePool)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@pytest.mark.parametrize("url", ["sqlite://", "file", PG_URL], ids=["sqlite memoria", "sqlite file", "postgresql"])
|
|
50
|
+
def test_engine_defaults_si_applica_su_ogni_pool(url: str, url_su_file: str) -> None:
|
|
51
|
+
"""Il contratto della costante portabile: nessuna chiave che un pool rifiuti."""
|
|
52
|
+
engine = create_engine(url_su_file if url == "file" else url, **ENGINE_DEFAULTS)
|
|
53
|
+
|
|
54
|
+
assert engine.pool._pre_ping is True
|
|
55
|
+
engine.dispose()
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_le_opzioni_di_queue_pool_stanno_in_una_costante_separata(url_su_file: str) -> None:
|
|
59
|
+
"""E il motivo per cui è separata: su `SingletonThreadPool` sollevano.
|
|
60
|
+
|
|
61
|
+
È il difetto che la separazione previene — un consumatore che espande tutto sulla
|
|
62
|
+
propria suite di test, che gira su SQLite in memoria come questa, non arriverebbe alla
|
|
63
|
+
prima query.
|
|
64
|
+
"""
|
|
65
|
+
with pytest.raises(TypeError, match="pool_use_lifo"):
|
|
66
|
+
create_engine("sqlite://", **ENGINE_DEFAULTS, **ENGINE_DEFAULTS_QUEUE_POOL)
|
|
67
|
+
|
|
68
|
+
for url in (url_su_file, PG_URL):
|
|
69
|
+
engine = create_engine(url, **ENGINE_DEFAULTS, **ENGINE_DEFAULTS_QUEUE_POOL)
|
|
70
|
+
assert engine.pool._pre_ping is True
|
|
71
|
+
engine.dispose()
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# ------------------------------------------------------------------ i valori
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_i_valori_arrivano_davvero_sul_pool(url_su_file: str) -> None:
|
|
78
|
+
"""Una costante che non ha effetto è peggio di nessuna costante."""
|
|
79
|
+
engine = create_engine(url_su_file, **ENGINE_DEFAULTS, **ENGINE_DEFAULTS_QUEUE_POOL)
|
|
80
|
+
|
|
81
|
+
assert engine.pool._pre_ping is True
|
|
82
|
+
assert engine.pool._recycle == 1800
|
|
83
|
+
assert engine.pool._pool.use_lifo is True, "il flag vive sulla coda del pool, non sul pool"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_session_defaults_arriva_sulla_sessione() -> None:
|
|
88
|
+
"""``expire_on_commit`` è di ``sessionmaker``, non di ``create_engine``: costante a parte."""
|
|
89
|
+
sessione = sessionmaker(bind=create_engine("sqlite://"), **SESSION_DEFAULTS)()
|
|
90
|
+
|
|
91
|
+
assert sessione.expire_on_commit is False
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_le_costanti_non_sono_condivise_per_riferimento() -> None:
|
|
95
|
+
"""Chi le espande con ``**`` ottiene una copia; chi le muta rompe tutti gli altri.
|
|
96
|
+
|
|
97
|
+
Il test non impedisce la mutazione — un ``dict`` è mutabile — ma fissa che l'uso
|
|
98
|
+
documentato (`create_engine(url, **ENGINE_DEFAULTS)`) non la propaga.
|
|
99
|
+
"""
|
|
100
|
+
kwargs = {**ENGINE_DEFAULTS}
|
|
101
|
+
kwargs["pool_pre_ping"] = False
|
|
102
|
+
|
|
103
|
+
assert ENGINE_DEFAULTS["pool_pre_ping"] is True
|
|
@@ -19,6 +19,11 @@ import pytest
|
|
|
19
19
|
|
|
20
20
|
# (package, simboli che devono essere importabili da lì)
|
|
21
21
|
SUPERFICIE = {
|
|
22
|
+
"general.utils": [
|
|
23
|
+
"ENGINE_DEFAULTS",
|
|
24
|
+
"ENGINE_DEFAULTS_QUEUE_POOL",
|
|
25
|
+
"SESSION_DEFAULTS",
|
|
26
|
+
],
|
|
22
27
|
"general.exception": [
|
|
23
28
|
"raise_http_exception",
|
|
24
29
|
"ExceptionInterface",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/exception/access_exceptions.py
RENAMED
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/exception/crud_exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/base/__init__.py
RENAMED
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/base/base_model.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/metadata/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/mixin/__init__.py
RENAMED
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/general/interface/mixin/audit_mixin.py
RENAMED
|
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
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_caricamento_parziale.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_entity_has_columns.py
RENAMED
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_execute_contratto.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_metadata_eccezioni.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_metadata_paginazione.py
RENAMED
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_metadata_pipeline.py
RENAMED
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_metadata_scorciatoie.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_general_be_lib-0.11.0 → python_general_be_lib-0.11.1}/tests/test_pipeline_handler.py
RENAMED
|
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
|