simple-module-test 0.0.43__tar.gz → 0.0.44__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.
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/PKG-INFO +6 -6
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/README.md +1 -1
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/pyproject.toml +5 -5
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/__init__.py +1 -1
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/fixtures.py +5 -5
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/plugin.py +2 -2
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/process_state.py +4 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/tenant_client.py +3 -3
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/.gitignore +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/LICENSE +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/_schema.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/app_factory.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/database.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/fake_events.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/inertia.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/inertia_page.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/mail.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/redis_server.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/routes.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/session_cookie.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/setup_wizard.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/waiting.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/tests/test_app_factory.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/tests/test_fake_events.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/tests/test_plugin_fixtures.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/tests/test_schema_reuse_pg.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/tests/test_testing_inertia_headers.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/tests/test_testing_inertia_page.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/tests/test_testing_process_state.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/tests/test_waiting_helpers.py +0 -0
- {simple_module_test-0.0.43 → simple_module_test-0.0.44}/tests/test_worker_database.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_test
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.44
|
|
4
4
|
Summary: Shared pytest fixtures (app, client, db_session, authenticated_client) for writing simple_module module tests
|
|
5
5
|
Project-URL: Homepage, https://github.com/antosubash/simple_module_python
|
|
6
6
|
Project-URL: Repository, https://github.com/antosubash/simple_module_python
|
|
@@ -25,10 +25,10 @@ Requires-Dist: fastapi<0.163,>=0.140
|
|
|
25
25
|
Requires-Dist: httpx<0.29,>=0.27
|
|
26
26
|
Requires-Dist: pytest-asyncio<2,>=0.24
|
|
27
27
|
Requires-Dist: pytest<10,>=8.0
|
|
28
|
-
Requires-Dist: simple-module-core==0.0.
|
|
29
|
-
Requires-Dist: simple-module-db==0.0.
|
|
30
|
-
Requires-Dist: simple-module-hosting==0.0.
|
|
31
|
-
Requires-Dist: simple-module-inertia==0.0.
|
|
28
|
+
Requires-Dist: simple-module-core==0.0.44
|
|
29
|
+
Requires-Dist: simple-module-db==0.0.44
|
|
30
|
+
Requires-Dist: simple-module-hosting==0.0.44
|
|
31
|
+
Requires-Dist: simple-module-inertia==0.0.44
|
|
32
32
|
Requires-Dist: sqlalchemy<3,>=2.0
|
|
33
33
|
Description-Content-Type: text/markdown
|
|
34
34
|
|
|
@@ -56,7 +56,7 @@ All fixtures below are auto-registered via the `pytest11` entry point — instal
|
|
|
56
56
|
- `db_state`, `engine`, `db_session` — fresh `DatabaseState` per test; `db_session` also creates all module tables and stamps `alembic_version` at head so the boot-time migration check passes.
|
|
57
57
|
- `app` — a `create_app(settings)` instance with `lifespan` started and stopped.
|
|
58
58
|
- `client` — an `httpx.AsyncClient` bound to the test app.
|
|
59
|
-
- `authenticated_client` — same but with an admin user seeded and a forged session cookie attached. **Requires the `users` module** to be installed (it seeds the admin via `users.bootstrap`); apps scaffolded by `smpy` include it.
|
|
59
|
+
- `authenticated_client` — same but with an admin user seeded and a forged session cookie attached. **Requires the `users` module** to be installed (it seeds the admin via `users.core.bootstrap`); apps scaffolded by `smpy` include it.
|
|
60
60
|
- `tenant_client` — factory: `async with tenant_client("member") as (client, tenant_id, user_id)` signs in a fresh user who is an `owner` / `admin` / `member` (default `owner`) of a new tenant — or of `tenant_id=` when given — with that tenant active. **Requires the `users` and `tenants` modules.**
|
|
61
61
|
|
|
62
62
|
## Usage
|
|
@@ -22,7 +22,7 @@ All fixtures below are auto-registered via the `pytest11` entry point — instal
|
|
|
22
22
|
- `db_state`, `engine`, `db_session` — fresh `DatabaseState` per test; `db_session` also creates all module tables and stamps `alembic_version` at head so the boot-time migration check passes.
|
|
23
23
|
- `app` — a `create_app(settings)` instance with `lifespan` started and stopped.
|
|
24
24
|
- `client` — an `httpx.AsyncClient` bound to the test app.
|
|
25
|
-
- `authenticated_client` — same but with an admin user seeded and a forged session cookie attached. **Requires the `users` module** to be installed (it seeds the admin via `users.bootstrap`); apps scaffolded by `smpy` include it.
|
|
25
|
+
- `authenticated_client` — same but with an admin user seeded and a forged session cookie attached. **Requires the `users` module** to be installed (it seeds the admin via `users.core.bootstrap`); apps scaffolded by `smpy` include it.
|
|
26
26
|
- `tenant_client` — factory: `async with tenant_client("member") as (client, tenant_id, user_id)` signs in a fresh user who is an `owner` / `admin` / `member` (default `owner`) of a new tenant — or of `tenant_id=` when given — with that tenant active. **Requires the `users` and `tenants` modules.**
|
|
27
27
|
|
|
28
28
|
## Usage
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_test"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.44"
|
|
4
4
|
description = "Shared pytest fixtures (app, client, db_session, authenticated_client) for writing simple_module module tests"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -25,10 +25,10 @@ dependencies = [
|
|
|
25
25
|
"httpx>=0.27,<0.29",
|
|
26
26
|
"pytest>=8.0,<10",
|
|
27
27
|
"pytest-asyncio>=0.24,<2",
|
|
28
|
-
"simple_module_core==0.0.
|
|
29
|
-
"simple_module_db==0.0.
|
|
30
|
-
"simple_module_hosting==0.0.
|
|
31
|
-
"simple_module_inertia==0.0.
|
|
28
|
+
"simple_module_core==0.0.44",
|
|
29
|
+
"simple_module_db==0.0.44",
|
|
30
|
+
"simple_module_hosting==0.0.44",
|
|
31
|
+
"simple_module_inertia==0.0.44",
|
|
32
32
|
"sqlalchemy>=2.0,<3",
|
|
33
33
|
]
|
|
34
34
|
|
|
@@ -22,7 +22,7 @@ The pytest plugin auto-registers these fixtures (no imports needed):
|
|
|
22
22
|
real broker (cross-worker cache invalidation) and skips when the binary is absent.
|
|
23
23
|
See ``simple_module_test.plugin`` (and ``simple_module_test.fixtures``) for
|
|
24
24
|
their definitions. ``authenticated_client`` additionally requires the ``users``
|
|
25
|
-
module to be installed — it seeds an admin via ``users.bootstrap``.
|
|
25
|
+
module to be installed — it seeds an admin via ``users.core.bootstrap``.
|
|
26
26
|
``tenant_client`` (``users`` + ``tenants``) is a factory yielding a client signed
|
|
27
27
|
in as an ``owner``/``admin``/``member`` of a real tenant — see
|
|
28
28
|
``simple_module_test.tenant_client``.
|
|
@@ -12,7 +12,7 @@ passes.
|
|
|
12
12
|
Module-scope imports here reference only framework packages
|
|
13
13
|
(``simple_module_core`` / ``simple_module_db`` / ``simple_module_hosting``),
|
|
14
14
|
which are this package's declared dependencies. The one plugin-module coupling
|
|
15
|
-
— ``authenticated_client`` seeding an admin via ``users.bootstrap`` — is a lazy
|
|
15
|
+
— ``authenticated_client`` seeding an admin via ``users.core.bootstrap`` — is a lazy
|
|
16
16
|
import inside the fixture body, so importing this module never requires the
|
|
17
17
|
``users`` module to be installed (mirroring ``plugin._bootstrap_eager_celery``,
|
|
18
18
|
which soft-imports ``background_tasks``).
|
|
@@ -146,7 +146,7 @@ async def _seed_setup_admin(application) -> None:
|
|
|
146
146
|
there is nothing to satisfy. Use ``setup_pending_app`` to exercise the gate.
|
|
147
147
|
"""
|
|
148
148
|
try:
|
|
149
|
-
from users.bootstrap import create_admin
|
|
149
|
+
from users.core.bootstrap import create_admin
|
|
150
150
|
except ImportError:
|
|
151
151
|
return
|
|
152
152
|
|
|
@@ -207,7 +207,7 @@ def _disable_env_bootstrap(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
|
207
207
|
if key.startswith("SM_USERS_BOOTSTRAP_"):
|
|
208
208
|
monkeypatch.delenv(key, raising=False)
|
|
209
209
|
try:
|
|
210
|
-
from users import bootstrap as bootstrap_module
|
|
210
|
+
from users.core import bootstrap as bootstrap_module
|
|
211
211
|
except ImportError:
|
|
212
212
|
return # No local-accounts provider installed; nothing bootstraps.
|
|
213
213
|
monkeypatch.setattr(bootstrap_module, "_read_dotenv_bootstrap_vars", dict)
|
|
@@ -241,11 +241,11 @@ async def authenticated_client(app) -> AsyncGenerator[httpx.AsyncClient, None]:
|
|
|
241
241
|
"""HTTPX client with a signed session cookie carrying a seeded admin user's id.
|
|
242
242
|
|
|
243
243
|
Requires the ``users`` module to be installed — it seeds the admin via
|
|
244
|
-
``users.bootstrap.create_admin``. The import is deferred to here (not module
|
|
244
|
+
``users.core.bootstrap.create_admin``. The import is deferred to here (not module
|
|
245
245
|
scope) so this plugin imports cleanly without ``users``; a consumer app that
|
|
246
246
|
uses this fixture without ``users`` gets a clear ImportError naming it.
|
|
247
247
|
"""
|
|
248
|
-
from users.bootstrap import create_admin
|
|
248
|
+
from users.core.bootstrap import create_admin
|
|
249
249
|
|
|
250
250
|
async with app.state.sm.db.session_factory() as session:
|
|
251
251
|
# Idempotent: the `app` fixture already seeded this same admin so the
|
|
@@ -92,8 +92,8 @@ def _bootstrap_eager_celery() -> None:
|
|
|
92
92
|
"""
|
|
93
93
|
os.environ.setdefault("SM_BG_TASKS_BROADCAST_INVALIDATIONS", "false")
|
|
94
94
|
with contextlib.suppress(ImportError):
|
|
95
|
-
from background_tasks.
|
|
96
|
-
from background_tasks.
|
|
95
|
+
from background_tasks.core.settings import BackgroundTasksSettings
|
|
96
|
+
from background_tasks.worker.celery_app import build_celery
|
|
97
97
|
|
|
98
98
|
build_celery(BackgroundTasksSettings(task_always_eager=True, task_eager_propagates=True))
|
|
99
99
|
|
|
@@ -5,6 +5,8 @@ from collections.abc import Iterator
|
|
|
5
5
|
import pytest
|
|
6
6
|
from simple_module_core.leases import reset_lease_backend
|
|
7
7
|
from simple_module_core.mail import reset_mail_sender
|
|
8
|
+
from simple_module_core.settings_hydrate import env_supplied_fields
|
|
9
|
+
from simple_module_hosting._api_version import default_api_version
|
|
8
10
|
from simple_module_hosting.sentry import reset_sentry
|
|
9
11
|
|
|
10
12
|
|
|
@@ -13,6 +15,8 @@ def reset_process_state() -> None:
|
|
|
13
15
|
reset_mail_sender()
|
|
14
16
|
reset_lease_backend()
|
|
15
17
|
reset_sentry()
|
|
18
|
+
env_supplied_fields.cache_clear()
|
|
19
|
+
default_api_version.cache_clear()
|
|
16
20
|
|
|
17
21
|
|
|
18
22
|
@pytest.fixture(autouse=True)
|
|
@@ -45,7 +45,7 @@ class TenantClient(NamedTuple):
|
|
|
45
45
|
|
|
46
46
|
async def create_user(app: Any, email: str) -> str:
|
|
47
47
|
"""A real, active, non-superuser ``users`` row with the ``user`` role; its id."""
|
|
48
|
-
from users.bootstrap import ensure_user_role
|
|
48
|
+
from users.core.bootstrap import ensure_user_role
|
|
49
49
|
from users.models import User, UserRole
|
|
50
50
|
|
|
51
51
|
async with app.state.sm.db.session_factory() as session:
|
|
@@ -69,7 +69,7 @@ async def create_user(app: Any, email: str) -> str:
|
|
|
69
69
|
|
|
70
70
|
async def _join(app: Any, user_id: str, email: str, role: TenantRole, tenant_id: str | None) -> str:
|
|
71
71
|
from tenants.models import Membership, Tenant
|
|
72
|
-
from tenants.resolver import forget
|
|
72
|
+
from tenants.resolution.resolver import forget
|
|
73
73
|
|
|
74
74
|
async with app.state.sm.db.session_factory() as session:
|
|
75
75
|
if tenant_id is None:
|
|
@@ -104,7 +104,7 @@ def tenant_client(app: Any) -> Callable[..., AbstractAsyncContextManager[TenantC
|
|
|
104
104
|
``tenant_id`` when given — and yields a :class:`TenantClient` whose session
|
|
105
105
|
has that tenant active.
|
|
106
106
|
"""
|
|
107
|
-
from tenants.constants import SESSION_ACTIVE_TENANT
|
|
107
|
+
from tenants.core.constants import SESSION_ACTIVE_TENANT
|
|
108
108
|
|
|
109
109
|
@asynccontextmanager
|
|
110
110
|
async def factory(
|
|
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
|
{simple_module_test-0.0.43 → simple_module_test-0.0.44}/simple_module_test/session_cookie.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_test-0.0.43 → simple_module_test-0.0.44}/tests/test_testing_inertia_headers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|