zrb 0.23.0__py3-none-any.whl → 0.24.0__py3-none-any.whl
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.
- zrb/__init__.py +2 -0
- zrb/builtin/devtool/install/_input.py +2 -2
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/start.py +5 -6
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/start.py +5 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_helper.py +1 -52
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/start.py +5 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/start.py +5 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/start.py +4 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/README.md +84 -8
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/loadtest/locustfile.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/loadtest/template.env +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/config.py +59 -61
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/frontend/src/routes/+layout.svelte +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/frontend/vite.config.ts +7 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/app/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/{app.py → app/app.py} +30 -29
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/{app_lifespan.py → app/app_lifespan.py} +16 -16
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/{app_state.py → app/app_state.py} +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/db_connection.py +14 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/frontend_index.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/log.py +6 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/messagebus.py +33 -33
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/rpc.py +9 -9
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/main.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/access_token_scheme.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/access_token_util.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/model/user_model.py +6 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/refresh_token_util.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/user.py +18 -18
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/register_module.py +9 -9
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/register_module.py +9 -9
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/template.env +5 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_permission_crud.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_login.py +14 -14
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/test_liveness_and_readiness.py +3 -3
- zrb/builtin/project/add/fastapp/crud/_helper/__init__.py +7 -0
- zrb/builtin/project/add/fastapp/crud/_helper/_common.py +8 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_api.py +45 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_permission.py +40 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_rpc.py +45 -0
- zrb/builtin/project/add/fastapp/crud/crud.py +3 -12
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/repo.py +12 -1
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/schema/snake_zrb_entity_name.py +1 -0
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/test/snake_zrb_module_name/test_snake_zrb_entity_name.py +8 -7
- zrb/builtin/project/add/fastapp/field/_helper/__init__.py +17 -0
- zrb/builtin/project/add/fastapp/field/_helper/_common.py +102 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_delete_page.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_detail_page.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_insert_page.py +62 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_list_page.py +47 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_repo.py +47 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_schema.py +45 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_test.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_update_page.py +50 -0
- zrb/builtin/project/add/fastapp/field/_input.py +14 -2
- zrb/builtin/project/add/fastapp/field/field.py +70 -90
- zrb/builtin/project/add/fastapp/module/_helper/__init__.py +17 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_all_disabled_env.py +22 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_all_enabled_env.py +22 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_deployment_template_env.py +25 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_src_template_env.py +25 -0
- zrb/builtin/project/add/fastapp/module/_helper/create_app_config.py +29 -0
- zrb/builtin/project/add/fastapp/module/_helper/create_microservice_config.py +158 -0
- zrb/builtin/project/add/fastapp/module/_helper/register_migration.py +35 -0
- zrb/builtin/project/add/fastapp/module/_helper/register_module.py +33 -0
- zrb/builtin/project/add/fastapp/module/module.py +8 -37
- zrb/builtin/project/add/fastapp/module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/register_module.py +9 -9
- zrb/builtin/project/add/plugin/plugin.py +2 -2
- zrb/builtin/project/create/create.py +2 -2
- zrb/builtin/version.py +3 -3
- zrb/config/config.py +14 -14
- zrb/helper/callable.py +3 -1
- zrb/helper/cli.py +4 -4
- zrb/helper/file/copy_tree.py +26 -10
- zrb/helper/log.py +3 -3
- zrb/helper/string/parse_replacement.py +1 -1
- zrb/helper/typecheck.py +2 -2
- zrb/helper/typing.py +2 -2
- zrb/helper/util.py +12 -0
- zrb/runner.py +2 -2
- zrb/task/base_remote_cmd_task.py +5 -1
- zrb/task/base_task/base_task.py +3 -3
- zrb/task/base_task/component/base_task_model.py +9 -9
- zrb/task/cmd_task.py +15 -7
- zrb/task/docker_compose_start_task.py +151 -0
- zrb/task/docker_compose_task.py +35 -16
- zrb/task_input/base_input.py +2 -2
- zrb/task_input/multiline_input.py +2 -2
- {zrb-0.23.0.dist-info → zrb-0.24.0.dist-info}/METADATA +3 -3
- {zrb-0.23.0.dist-info → zrb-0.24.0.dist-info}/RECORD +98 -80
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/init.py +0 -34
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/init.py +0 -34
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/init.py +0 -36
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/init.py +0 -36
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/init.py +0 -26
- zrb/builtin/project/add/fastapp/crud/_helper.py +0 -118
- zrb/builtin/project/add/fastapp/field/_helper.py +0 -342
- zrb/builtin/project/add/fastapp/module/_helper.py +0 -313
- {zrb-0.23.0.dist-info → zrb-0.24.0.dist-info}/LICENSE +0 -0
- {zrb-0.23.0.dist-info → zrb-0.24.0.dist-info}/WHEEL +0 -0
- {zrb-0.23.0.dist-info → zrb-0.24.0.dist-info}/entry_points.txt +0 -0
@@ -1,10 +1,10 @@
|
|
1
1
|
from config import (
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
APP_ENABLE_API,
|
3
|
+
APP_ENABLE_EVENT_HANDLER,
|
4
|
+
APP_ENABLE_LOG_MODULE,
|
5
|
+
APP_ENABLE_RPC_SERVER,
|
6
6
|
)
|
7
|
-
from integration.app import app
|
7
|
+
from integration.app.app import app
|
8
8
|
from integration.log import logger
|
9
9
|
from integration.messagebus import consumer, publisher
|
10
10
|
from integration.rpc import rpc_caller, rpc_server
|
@@ -15,10 +15,10 @@ from module.log.rpc import register_rpc
|
|
15
15
|
|
16
16
|
|
17
17
|
def register_log():
|
18
|
-
if not
|
18
|
+
if not APP_ENABLE_LOG_MODULE:
|
19
19
|
logger.info('🥪 Skip registering "log"')
|
20
20
|
return
|
21
|
-
if
|
21
|
+
if APP_ENABLE_API:
|
22
22
|
register_api(
|
23
23
|
logger=logger,
|
24
24
|
app=app,
|
@@ -26,11 +26,11 @@ def register_log():
|
|
26
26
|
rpc_caller=rpc_caller,
|
27
27
|
publisher=publisher,
|
28
28
|
)
|
29
|
-
if
|
29
|
+
if APP_ENABLE_EVENT_HANDLER:
|
30
30
|
register_event(
|
31
31
|
logger=logger, consumer=consumer, rpc_caller=rpc_caller, publisher=publisher
|
32
32
|
)
|
33
|
-
if
|
33
|
+
if APP_ENABLE_RPC_SERVER:
|
34
34
|
register_rpc(
|
35
35
|
logger=logger,
|
36
36
|
rpc_server=rpc_server,
|
@@ -10,8 +10,8 @@ APP_OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
|
|
10
10
|
|
11
11
|
PUBLIC_BRAND=PascalZrbAppName
|
12
12
|
PUBLIC_TITLE=PascalZrbAppName
|
13
|
-
|
14
|
-
|
13
|
+
APP_AUTH_ACCESS_TOKEN_COOKIE_KEY=access_token
|
14
|
+
APP_AUTH_REFRESH_TOKEN_COOKIE_KEY=refresh_token
|
15
15
|
|
16
16
|
APP_AUTH_ACCESS_TOKEN_EXPIRE_SECONDS=300
|
17
17
|
APP_AUTH_ACCESS_TOKEN_TYPE=jwt
|
@@ -36,6 +36,9 @@ APP_AUTH_GUEST_PHONE=
|
|
36
36
|
APP_DB_CONNECTION=postgresql+psycopg2://postgres:admin@localhost:5432/snake_zrb_app_name
|
37
37
|
APP_DB_ENGINE_SHOW_LOG=false
|
38
38
|
APP_DB_AUTO_MIGRATE=true
|
39
|
+
APP_DB_POOL_PRE_PING=true
|
40
|
+
APP_DB_POOL_SIZE=20
|
41
|
+
APP_DB_POOL_MAX_OVERFLOW=0
|
39
42
|
|
40
43
|
APP_BROKER_TYPE=rabbitmq
|
41
44
|
|
zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py
CHANGED
@@ -2,7 +2,7 @@ from typing import AsyncIterator
|
|
2
2
|
|
3
3
|
import pytest
|
4
4
|
from httpx import AsyncClient
|
5
|
-
from src.config import
|
5
|
+
from src.config import APP_AUTH_ADMIN_PASSWORD, APP_AUTH_ADMIN_USERNAME
|
6
6
|
|
7
7
|
inserted_success_data = {
|
8
8
|
"name": "test-create-group-success",
|
@@ -35,8 +35,8 @@ async def test_insert_group_and_get_success(
|
|
35
35
|
login_admin_response = await client.post(
|
36
36
|
"/api/v1/auth/login",
|
37
37
|
json={
|
38
|
-
"identity":
|
39
|
-
"password":
|
38
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
39
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
40
40
|
},
|
41
41
|
)
|
42
42
|
assert login_admin_response.status_code == 200
|
@@ -88,8 +88,8 @@ async def test_update_group_and_get_success(
|
|
88
88
|
login_admin_response = await client.post(
|
89
89
|
"/api/v1/auth/login",
|
90
90
|
json={
|
91
|
-
"identity":
|
92
|
-
"password":
|
91
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
92
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
93
93
|
},
|
94
94
|
)
|
95
95
|
assert login_admin_response.status_code == 200
|
@@ -155,8 +155,8 @@ async def test_delete_group_and_get_success(
|
|
155
155
|
login_admin_response = await client.post(
|
156
156
|
"/api/v1/auth/login",
|
157
157
|
json={
|
158
|
-
"identity":
|
159
|
-
"password":
|
158
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
159
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
160
160
|
},
|
161
161
|
)
|
162
162
|
assert login_admin_response.status_code == 200
|
@@ -2,7 +2,7 @@ from typing import AsyncIterator
|
|
2
2
|
|
3
3
|
import pytest
|
4
4
|
from httpx import AsyncClient
|
5
|
-
from src.config import
|
5
|
+
from src.config import APP_AUTH_ADMIN_PASSWORD, APP_AUTH_ADMIN_USERNAME
|
6
6
|
|
7
7
|
inserted_success_data = {
|
8
8
|
"name": "test-create-permission-success",
|
@@ -31,8 +31,8 @@ async def test_insert_permission_and_get_success(
|
|
31
31
|
login_admin_response = await client.post(
|
32
32
|
"/api/v1/auth/login",
|
33
33
|
json={
|
34
|
-
"identity":
|
35
|
-
"password":
|
34
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
35
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
36
36
|
},
|
37
37
|
)
|
38
38
|
assert login_admin_response.status_code == 200
|
@@ -84,8 +84,8 @@ async def test_update_permission_and_get_success(
|
|
84
84
|
login_admin_response = await client.post(
|
85
85
|
"/api/v1/auth/login",
|
86
86
|
json={
|
87
|
-
"identity":
|
88
|
-
"password":
|
87
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
88
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
89
89
|
"permissions": [],
|
90
90
|
},
|
91
91
|
)
|
@@ -152,8 +152,8 @@ async def test_delete_permission_and_get_success(
|
|
152
152
|
login_admin_response = await client.post(
|
153
153
|
"/api/v1/auth/login",
|
154
154
|
json={
|
155
|
-
"identity":
|
156
|
-
"password":
|
155
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
156
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
157
157
|
},
|
158
158
|
)
|
159
159
|
assert login_admin_response.status_code == 200
|
zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py
CHANGED
@@ -2,7 +2,7 @@ from typing import AsyncIterator
|
|
2
2
|
|
3
3
|
import pytest
|
4
4
|
from httpx import AsyncClient
|
5
|
-
from src.config import
|
5
|
+
from src.config import APP_AUTH_ADMIN_PASSWORD, APP_AUTH_ADMIN_USERNAME
|
6
6
|
|
7
7
|
inserted_success_data = {
|
8
8
|
"username": "test-create-user-success",
|
@@ -51,8 +51,8 @@ async def test_insert_user_and_get_success(
|
|
51
51
|
login_admin_response = await client.post(
|
52
52
|
"/api/v1/auth/login",
|
53
53
|
json={
|
54
|
-
"identity":
|
55
|
-
"password":
|
54
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
55
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
56
56
|
},
|
57
57
|
)
|
58
58
|
assert login_admin_response.status_code == 200
|
@@ -104,8 +104,8 @@ async def test_update_user_and_get_success(
|
|
104
104
|
login_admin_response = await client.post(
|
105
105
|
"/api/v1/auth/login",
|
106
106
|
json={
|
107
|
-
"identity":
|
108
|
-
"password":
|
107
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
108
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
109
109
|
},
|
110
110
|
)
|
111
111
|
assert login_admin_response.status_code == 200
|
@@ -171,8 +171,8 @@ async def test_delete_user_and_get_success(
|
|
171
171
|
login_admin_response = await client.post(
|
172
172
|
"/api/v1/auth/login",
|
173
173
|
json={
|
174
|
-
"identity":
|
175
|
-
"password":
|
174
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
175
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
176
176
|
},
|
177
177
|
)
|
178
178
|
assert login_admin_response.status_code == 200
|
zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_login.py
CHANGED
@@ -2,7 +2,7 @@ from typing import AsyncIterator
|
|
2
2
|
|
3
3
|
import pytest
|
4
4
|
from httpx import AsyncClient
|
5
|
-
from src.config import
|
5
|
+
from src.config import APP_AUTH_ADMIN_PASSWORD, APP_AUTH_ADMIN_USERNAME
|
6
6
|
|
7
7
|
|
8
8
|
@pytest.mark.asyncio
|
@@ -13,8 +13,8 @@ async def test_admin_user_login_success(
|
|
13
13
|
login_response = await client.post(
|
14
14
|
"/api/v1/auth/login",
|
15
15
|
json={
|
16
|
-
"identity":
|
17
|
-
"password":
|
16
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
17
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
18
18
|
},
|
19
19
|
)
|
20
20
|
assert login_response.status_code == 200
|
@@ -30,7 +30,7 @@ async def test_admin_user_login_empty_identity_failed(
|
|
30
30
|
async for client in test_client_generator:
|
31
31
|
login_response = await client.post(
|
32
32
|
"/api/v1/auth/login",
|
33
|
-
json={"identity": "", "password":
|
33
|
+
json={"identity": "", "password": APP_AUTH_ADMIN_PASSWORD},
|
34
34
|
)
|
35
35
|
assert login_response.status_code == 422
|
36
36
|
|
@@ -42,7 +42,7 @@ async def test_admin_user_login_invalid_identity_failed(
|
|
42
42
|
async for client in test_client_generator:
|
43
43
|
login_response = await client.post(
|
44
44
|
"/api/v1/auth/login",
|
45
|
-
json={"identity": "invalid-identity", "password":
|
45
|
+
json={"identity": "invalid-identity", "password": APP_AUTH_ADMIN_PASSWORD},
|
46
46
|
)
|
47
47
|
assert login_response.status_code == 404
|
48
48
|
|
@@ -54,7 +54,7 @@ async def test_admin_user_failed_invalid_password(
|
|
54
54
|
async for client in test_client_generator:
|
55
55
|
login_response = await client.post(
|
56
56
|
"/api/v1/auth/login",
|
57
|
-
json={"identity":
|
57
|
+
json={"identity": APP_AUTH_ADMIN_USERNAME, "password": "invalid-password"},
|
58
58
|
)
|
59
59
|
assert login_response.status_code == 404
|
60
60
|
|
@@ -68,8 +68,8 @@ async def test_create_normal_user_and_login_with_username_success(
|
|
68
68
|
login_admin_response = await client.post(
|
69
69
|
"/api/v1/auth/login",
|
70
70
|
json={
|
71
|
-
"identity":
|
72
|
-
"password":
|
71
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
72
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
73
73
|
},
|
74
74
|
)
|
75
75
|
assert login_admin_response.status_code == 200
|
@@ -113,8 +113,8 @@ async def test_create_normal_user_and_login_with_phone_success(
|
|
113
113
|
login_admin_response = await client.post(
|
114
114
|
"/api/v1/auth/login",
|
115
115
|
json={
|
116
|
-
"identity":
|
117
|
-
"password":
|
116
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
117
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
118
118
|
},
|
119
119
|
)
|
120
120
|
assert login_admin_response.status_code == 200
|
@@ -155,8 +155,8 @@ async def test_create_normal_user_and_login_with_email_success(
|
|
155
155
|
login_admin_response = await client.post(
|
156
156
|
"/api/v1/auth/login",
|
157
157
|
json={
|
158
|
-
"identity":
|
159
|
-
"password":
|
158
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
159
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
160
160
|
},
|
161
161
|
)
|
162
162
|
assert login_admin_response.status_code == 200
|
@@ -200,8 +200,8 @@ async def test_create_normal_user_and_login_failed(
|
|
200
200
|
login_admin_response = await client.post(
|
201
201
|
"/api/v1/auth/login",
|
202
202
|
json={
|
203
|
-
"identity":
|
204
|
-
"password":
|
203
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
204
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
205
205
|
},
|
206
206
|
)
|
207
207
|
assert login_admin_response.status_code == 200
|
@@ -2,7 +2,7 @@ from typing import AsyncIterator
|
|
2
2
|
|
3
3
|
import pytest
|
4
4
|
from httpx import AsyncClient
|
5
|
-
from src.config import
|
5
|
+
from src.config import APP_NAME
|
6
6
|
|
7
7
|
|
8
8
|
@pytest.mark.asyncio
|
@@ -10,7 +10,7 @@ async def test_get_liveness(test_client_generator: AsyncIterator[AsyncClient]):
|
|
10
10
|
async for client in test_client_generator:
|
11
11
|
response = await client.get("/liveness")
|
12
12
|
assert response.status_code == 200
|
13
|
-
assert response.json() == {"app":
|
13
|
+
assert response.json() == {"app": APP_NAME, "alive": True}
|
14
14
|
|
15
15
|
|
16
16
|
@pytest.mark.asyncio
|
@@ -25,7 +25,7 @@ async def test_get_readiness(test_client_generator: AsyncIterator[AsyncClient]):
|
|
25
25
|
async for client in test_client_generator:
|
26
26
|
response = await client.get("/readiness")
|
27
27
|
assert response.status_code == 200
|
28
|
-
assert response.json() == {"app":
|
28
|
+
assert response.json() == {"app": APP_NAME, "ready": True}
|
29
29
|
|
30
30
|
|
31
31
|
@pytest.mark.asyncio
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from zrb.helper.codemod.add_import_module import add_import_module
|
4
|
+
from zrb.helper.codemod.append_code_to_function import append_code_to_function
|
5
|
+
from zrb.helper.file.text import read_text_file_async, write_text_file_async
|
6
|
+
from zrb.helper.typecheck import typechecked
|
7
|
+
from zrb.helper.util import to_snake_case
|
8
|
+
from zrb.task.task import Task
|
9
|
+
|
10
|
+
from ._common import get_app_module_dir
|
11
|
+
|
12
|
+
|
13
|
+
@typechecked
|
14
|
+
async def register_api(
|
15
|
+
task: Task, project_dir: str, app_name: str, module_name: str, entity_name: str
|
16
|
+
):
|
17
|
+
snake_module_name = to_snake_case(module_name)
|
18
|
+
snake_entity_name = to_snake_case(entity_name)
|
19
|
+
module_api_file_path = os.path.join(
|
20
|
+
get_app_module_dir(project_dir, app_name), snake_module_name, "api.py"
|
21
|
+
)
|
22
|
+
register_function_path = ".".join(
|
23
|
+
["module", snake_module_name, "entity", snake_entity_name, "api"]
|
24
|
+
)
|
25
|
+
register_function = f"register_{snake_entity_name}_api"
|
26
|
+
task.print_out(f"Read code from: {module_api_file_path}")
|
27
|
+
code = await read_text_file_async(module_api_file_path)
|
28
|
+
task.print_out(
|
29
|
+
f'Add import "register_api" as "{register_function}" '
|
30
|
+
+ f'from "{register_function_path}" to the code'
|
31
|
+
)
|
32
|
+
code = add_import_module(
|
33
|
+
code=code,
|
34
|
+
module_path=register_function_path,
|
35
|
+
resource="register_api",
|
36
|
+
alias=register_function,
|
37
|
+
)
|
38
|
+
task.print_out(f'Add "{register_function}" call to the code')
|
39
|
+
code = append_code_to_function(
|
40
|
+
code=code,
|
41
|
+
function_name="register_api",
|
42
|
+
new_code=f"{register_function}(logger, app, authorizer, rpc_caller, publisher)", # noqa
|
43
|
+
)
|
44
|
+
task.print_out(f"Write modified code to: {module_api_file_path}")
|
45
|
+
await write_text_file_async(module_api_file_path, code)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from zrb.helper.codemod.append_code_to_function import append_code_to_function
|
4
|
+
from zrb.helper.file.text import read_text_file_async, write_text_file_async
|
5
|
+
from zrb.helper.typecheck import typechecked
|
6
|
+
from zrb.helper.util import to_snake_case
|
7
|
+
from zrb.task.task import Task
|
8
|
+
|
9
|
+
from ._common import get_app_module_dir
|
10
|
+
|
11
|
+
|
12
|
+
@typechecked
|
13
|
+
async def register_permission(
|
14
|
+
task: Task, project_dir: str, app_name: str, module_name: str, entity_name: str
|
15
|
+
):
|
16
|
+
snake_module_name = to_snake_case(module_name)
|
17
|
+
snake_entity_name = to_snake_case(entity_name)
|
18
|
+
module_register_permission_file_path = os.path.join(
|
19
|
+
get_app_module_dir(project_dir, app_name),
|
20
|
+
"auth",
|
21
|
+
"register_permission.py",
|
22
|
+
)
|
23
|
+
task.print_out(f"Read code from: {module_register_permission_file_path}")
|
24
|
+
code = await read_text_file_async(module_register_permission_file_path)
|
25
|
+
code = append_code_to_function(
|
26
|
+
code=code,
|
27
|
+
function_name="register_permission",
|
28
|
+
new_code="\n".join(
|
29
|
+
[
|
30
|
+
"await ensure_entity_permission(",
|
31
|
+
f" module_name='{snake_module_name}', entity_name='{snake_entity_name}'", # noqa
|
32
|
+
")",
|
33
|
+
]
|
34
|
+
),
|
35
|
+
)
|
36
|
+
task.print_out(
|
37
|
+
f'Add "ensure_entity_permission" call for {snake_entity_name} ' + "to the code"
|
38
|
+
)
|
39
|
+
task.print_out(f"Write modified code to: {module_register_permission_file_path}")
|
40
|
+
await write_text_file_async(module_register_permission_file_path, code)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from zrb.helper.codemod.add_import_module import add_import_module
|
4
|
+
from zrb.helper.codemod.append_code_to_function import append_code_to_function
|
5
|
+
from zrb.helper.file.text import read_text_file_async, write_text_file_async
|
6
|
+
from zrb.helper.typecheck import typechecked
|
7
|
+
from zrb.helper.util import to_snake_case
|
8
|
+
from zrb.task.task import Task
|
9
|
+
|
10
|
+
from ._common import get_app_module_dir
|
11
|
+
|
12
|
+
|
13
|
+
@typechecked
|
14
|
+
async def register_rpc(
|
15
|
+
task: Task, project_dir: str, app_name: str, module_name: str, entity_name: str
|
16
|
+
):
|
17
|
+
snake_module_name = to_snake_case(module_name)
|
18
|
+
snake_entity_name = to_snake_case(entity_name)
|
19
|
+
module_rpc_file_path = os.path.join(
|
20
|
+
get_app_module_dir(project_dir, app_name), snake_module_name, "rpc.py"
|
21
|
+
)
|
22
|
+
register_function_path = ".".join(
|
23
|
+
["module", snake_module_name, "entity", snake_entity_name, "rpc"]
|
24
|
+
)
|
25
|
+
register_function = f"register_{snake_entity_name}_rpc"
|
26
|
+
task.print_out(f"Read code from: {module_rpc_file_path}")
|
27
|
+
code = await read_text_file_async(module_rpc_file_path)
|
28
|
+
task.print_out(
|
29
|
+
f'Add import "register_rpc" as "{register_function}" '
|
30
|
+
+ f'from "{register_function_path}" to the code'
|
31
|
+
)
|
32
|
+
code = add_import_module(
|
33
|
+
code=code,
|
34
|
+
module_path=register_function_path,
|
35
|
+
resource="register_rpc",
|
36
|
+
alias=register_function,
|
37
|
+
)
|
38
|
+
task.print_out(f'Add "{register_function}" call to the code')
|
39
|
+
code = append_code_to_function(
|
40
|
+
code=code,
|
41
|
+
function_name="register_rpc",
|
42
|
+
new_code=f"{register_function}(logger, rpc_server, rpc_caller, publisher)", # noqa
|
43
|
+
)
|
44
|
+
task.print_out(f"Write modified code to: {module_rpc_file_path}")
|
45
|
+
await write_text_file_async(module_rpc_file_path, code)
|
@@ -107,24 +107,15 @@ async def register_crud(*args: Any, **kwargs: Any):
|
|
107
107
|
app_name = kwargs.get("app_name")
|
108
108
|
module_name = kwargs.get("module_name")
|
109
109
|
entity_name = kwargs.get("entity_name")
|
110
|
-
kebab_app_name = util.to_kebab_case(app_name)
|
111
|
-
snake_module_name = util.to_snake_case(module_name)
|
112
|
-
snake_entity_name = util.to_snake_case(entity_name)
|
113
110
|
await asyncio.gather(
|
114
111
|
asyncio.create_task(
|
115
|
-
register_api(
|
116
|
-
task, project_dir, kebab_app_name, snake_module_name, snake_entity_name
|
117
|
-
)
|
112
|
+
register_api(task, project_dir, app_name, module_name, entity_name)
|
118
113
|
),
|
119
114
|
asyncio.create_task(
|
120
|
-
register_rpc(
|
121
|
-
task, project_dir, kebab_app_name, snake_module_name, snake_entity_name
|
122
|
-
)
|
115
|
+
register_rpc(task, project_dir, app_name, module_name, entity_name)
|
123
116
|
),
|
124
117
|
asyncio.create_task(
|
125
|
-
register_permission(
|
126
|
-
task, project_dir, kebab_app_name, snake_module_name, snake_entity_name
|
127
|
-
)
|
118
|
+
register_permission(task, project_dir, app_name, module_name, entity_name)
|
128
119
|
),
|
129
120
|
)
|
130
121
|
|
@@ -4,7 +4,18 @@ from module.snake_zrb_module_name.schema.snake_zrb_entity_name import (
|
|
4
4
|
PascalZrbEntityName,
|
5
5
|
PascalZrbEntityNameData,
|
6
6
|
)
|
7
|
-
from sqlalchemy import
|
7
|
+
from sqlalchemy import (
|
8
|
+
Boolean,
|
9
|
+
Column,
|
10
|
+
Date,
|
11
|
+
DateTime,
|
12
|
+
Double,
|
13
|
+
Float,
|
14
|
+
Integer,
|
15
|
+
String,
|
16
|
+
Text,
|
17
|
+
Time,
|
18
|
+
)
|
8
19
|
|
9
20
|
|
10
21
|
class DBEntityPascalZrbEntityName(Base, DBEntityMixin):
|
@@ -1,8 +1,9 @@
|
|
1
|
+
from datetime import date, datetime, time
|
1
2
|
from typing import AsyncIterator
|
2
3
|
|
3
4
|
import pytest
|
5
|
+
from config import APP_AUTH_ADMIN_PASSWORD, APP_AUTH_ADMIN_USERNAME
|
4
6
|
from httpx import AsyncClient
|
5
|
-
from src.config import app_auth_admin_password, app_auth_admin_username
|
6
7
|
|
7
8
|
inserted_success_data = {
|
8
9
|
"snake_zrb_column_name": "test-kebab-create-entity-name-success"
|
@@ -27,8 +28,8 @@ async def test_insert_snake_zrb_entity_name_and_get_success(
|
|
27
28
|
login_admin_response = await client.post(
|
28
29
|
"/api/v1/auth/login",
|
29
30
|
json={
|
30
|
-
"identity":
|
31
|
-
"password":
|
31
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
32
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
32
33
|
},
|
33
34
|
)
|
34
35
|
assert login_admin_response.status_code == 200
|
@@ -80,8 +81,8 @@ async def test_update_snake_zrb_entity_name_and_get_success(
|
|
80
81
|
login_admin_response = await client.post(
|
81
82
|
"/api/v1/auth/login",
|
82
83
|
json={
|
83
|
-
"identity":
|
84
|
-
"password":
|
84
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
85
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
85
86
|
},
|
86
87
|
)
|
87
88
|
assert login_admin_response.status_code == 200
|
@@ -147,8 +148,8 @@ async def test_delete_snake_zrb_entity_name_and_get_success(
|
|
147
148
|
login_admin_response = await client.post(
|
148
149
|
"/api/v1/auth/login",
|
149
150
|
json={
|
150
|
-
"identity":
|
151
|
-
"password":
|
151
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
152
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
152
153
|
},
|
153
154
|
)
|
154
155
|
assert login_admin_response.status_code == 200
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from .inject_delete_page import inject_delete_page
|
2
|
+
from .inject_detail_page import inject_detail_page
|
3
|
+
from .inject_insert_page import inject_insert_page
|
4
|
+
from .inject_list_page import inject_list_page
|
5
|
+
from .inject_repo import inject_repo
|
6
|
+
from .inject_schema import inject_schema
|
7
|
+
from .inject_test import inject_test
|
8
|
+
from .inject_update_page import inject_update_page
|
9
|
+
|
10
|
+
assert inject_list_page
|
11
|
+
assert inject_detail_page
|
12
|
+
assert inject_insert_page
|
13
|
+
assert inject_update_page
|
14
|
+
assert inject_delete_page
|
15
|
+
assert inject_repo
|
16
|
+
assert inject_schema
|
17
|
+
assert inject_test
|