simple-module-test 0.0.28__tar.gz → 0.0.29__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.28 → simple_module_test-0.0.29}/PKG-INFO +4 -4
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/pyproject.toml +4 -4
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/simple_module_test/fixtures.py +38 -2
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/simple_module_test/plugin.py +1 -0
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/.gitignore +0 -0
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/LICENSE +0 -0
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/README.md +0 -0
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/simple_module_test/__init__.py +0 -0
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/simple_module_test/app_factory.py +0 -0
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/simple_module_test/fake_events.py +0 -0
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/simple_module_test/routes.py +0 -0
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/simple_module_test/session_cookie.py +0 -0
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/tests/test_app_factory.py +0 -0
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/tests/test_fake_events.py +0 -0
- {simple_module_test-0.0.28 → simple_module_test-0.0.29}/tests/test_plugin_fixtures.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simple_module_test
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.29
|
|
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,9 +25,9 @@ Requires-Dist: fastapi>=0.115
|
|
|
25
25
|
Requires-Dist: httpx>=0.27
|
|
26
26
|
Requires-Dist: pytest-asyncio>=0.24
|
|
27
27
|
Requires-Dist: pytest>=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.
|
|
28
|
+
Requires-Dist: simple-module-core==0.0.29
|
|
29
|
+
Requires-Dist: simple-module-db==0.0.29
|
|
30
|
+
Requires-Dist: simple-module-hosting==0.0.29
|
|
31
31
|
Requires-Dist: sqlalchemy>=2.0
|
|
32
32
|
Description-Content-Type: text/markdown
|
|
33
33
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_test"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.29"
|
|
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,9 +25,9 @@ dependencies = [
|
|
|
25
25
|
"httpx>=0.27",
|
|
26
26
|
"pytest>=8.0",
|
|
27
27
|
"pytest-asyncio>=0.24",
|
|
28
|
-
"simple_module_core==0.0.
|
|
29
|
-
"simple_module_db==0.0.
|
|
30
|
-
"simple_module_hosting==0.0.
|
|
28
|
+
"simple_module_core==0.0.29",
|
|
29
|
+
"simple_module_db==0.0.29",
|
|
30
|
+
"simple_module_hosting==0.0.29",
|
|
31
31
|
"sqlalchemy>=2.0",
|
|
32
32
|
]
|
|
33
33
|
|
|
@@ -22,12 +22,13 @@ from __future__ import annotations
|
|
|
22
22
|
|
|
23
23
|
import contextlib
|
|
24
24
|
import importlib
|
|
25
|
-
|
|
25
|
+
import os
|
|
26
|
+
from collections.abc import AsyncGenerator, Iterator
|
|
26
27
|
from functools import lru_cache
|
|
27
28
|
|
|
28
29
|
import httpx
|
|
29
30
|
import pytest
|
|
30
|
-
from simple_module_core.discovery import discover_modules
|
|
31
|
+
from simple_module_core.discovery import DEFAULT_AUTH_PROVIDER, discover_modules
|
|
31
32
|
from simple_module_db.base import all_module_bases
|
|
32
33
|
from simple_module_db.session import DatabaseState, init_db
|
|
33
34
|
from simple_module_hosting.settings import Settings
|
|
@@ -35,6 +36,35 @@ from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession
|
|
|
35
36
|
|
|
36
37
|
from simple_module_test.session_cookie import forge_session_cookie
|
|
37
38
|
|
|
39
|
+
_AUTH_PROVIDER_ENV = "SM_AUTH_PROVIDER"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@pytest.fixture(scope="session", autouse=True)
|
|
43
|
+
def pinned_auth_provider() -> Iterator[str]:
|
|
44
|
+
"""Pin ``SM_AUTH_PROVIDER`` to the local-account provider for the suite.
|
|
45
|
+
|
|
46
|
+
``Settings`` reads the repo's ``.env``, and the README tells anyone running
|
|
47
|
+
Keycloak locally to put ``SM_AUTH_PROVIDER=keycloak`` there. Nearly every
|
|
48
|
+
test that boots an app expects the ``users`` provider — ``/users/login``,
|
|
49
|
+
the admin pages, the seeded admin in ``authenticated_client`` — and the
|
|
50
|
+
``Settings(...)`` construction sites are spread across module conftests,
|
|
51
|
+
so pinning it on each one would be a losing game.
|
|
52
|
+
|
|
53
|
+
The real environment outranks ``.env`` in pydantic-settings, so setting it
|
|
54
|
+
here covers every construction site at once. A test that wants a different
|
|
55
|
+
provider can still ``monkeypatch.setenv`` or pass ``auth_provider=`` to
|
|
56
|
+
``Settings`` directly.
|
|
57
|
+
"""
|
|
58
|
+
previous = os.environ.get(_AUTH_PROVIDER_ENV)
|
|
59
|
+
os.environ[_AUTH_PROVIDER_ENV] = DEFAULT_AUTH_PROVIDER
|
|
60
|
+
try:
|
|
61
|
+
yield DEFAULT_AUTH_PROVIDER
|
|
62
|
+
finally:
|
|
63
|
+
if previous is None:
|
|
64
|
+
os.environ.pop(_AUTH_PROVIDER_ENV, None)
|
|
65
|
+
else:
|
|
66
|
+
os.environ[_AUTH_PROVIDER_ENV] = previous
|
|
67
|
+
|
|
38
68
|
|
|
39
69
|
@pytest.fixture
|
|
40
70
|
def settings() -> Settings:
|
|
@@ -44,6 +74,11 @@ def settings() -> Settings:
|
|
|
44
74
|
(and the ``X-Tenant-ID`` header paths they rely on) keep working.
|
|
45
75
|
Individual tests that want the tenant middleware absent construct
|
|
46
76
|
their own ``Settings(multi_tenant=False, ...)`` in the test body.
|
|
77
|
+
|
|
78
|
+
``auth_provider`` is pinned for the same reason as the rest: a developer
|
|
79
|
+
running Keycloak locally has ``SM_AUTH_PROVIDER=keycloak`` in ``.env``,
|
|
80
|
+
which would otherwise swap the auth provider out from under every test
|
|
81
|
+
that expects ``/users/login``.
|
|
47
82
|
"""
|
|
48
83
|
return Settings(
|
|
49
84
|
database_url="sqlite+aiosqlite:///:memory:",
|
|
@@ -51,6 +86,7 @@ def settings() -> Settings:
|
|
|
51
86
|
secret_key="test-secret-key",
|
|
52
87
|
multi_tenant=True,
|
|
53
88
|
tenant_header="X-Tenant-ID",
|
|
89
|
+
auth_provider="users",
|
|
54
90
|
)
|
|
55
91
|
|
|
56
92
|
|
|
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.28 → simple_module_test-0.0.29}/simple_module_test/session_cookie.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|