tigrbl-tests 0.3.3.dev1__py3-none-any.whl → 0.3.4.dev1__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.
- tests/unit/test_initialize_async_task.py +27 -0
- tests/unit/test_initialize_mixed_engines.py +41 -0
- tests/unit/test_initialize_task_schedule.py +27 -0
- tests/unit/test_jsonrpc_openrpc.py +48 -0
- {tigrbl_tests-0.3.3.dev1.dist-info → tigrbl_tests-0.3.4.dev1.dist-info}/METADATA +1 -1
- {tigrbl_tests-0.3.3.dev1.dist-info → tigrbl_tests-0.3.4.dev1.dist-info}/RECORD +8 -4
- {tigrbl_tests-0.3.3.dev1.dist-info → tigrbl_tests-0.3.4.dev1.dist-info}/WHEEL +1 -1
- {tigrbl_tests-0.3.3.dev1.dist-info → tigrbl_tests-0.3.4.dev1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from sqlalchemy import Column, Integer
|
|
5
|
+
|
|
6
|
+
from tigrbl import Base, TigrblApp
|
|
7
|
+
from tigrbl.engine.shortcuts import mem
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Widget(Base):
|
|
11
|
+
__tablename__ = "widgets_async_task"
|
|
12
|
+
|
|
13
|
+
id = Column(Integer, primary_key=True)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_initialize_returns_task_for_async_engine():
|
|
18
|
+
app = TigrblApp(engine=mem())
|
|
19
|
+
app.include_model(Widget, prefix="")
|
|
20
|
+
|
|
21
|
+
result = app.initialize()
|
|
22
|
+
|
|
23
|
+
assert isinstance(result, asyncio.Task)
|
|
24
|
+
|
|
25
|
+
await result
|
|
26
|
+
|
|
27
|
+
assert getattr(app, "_ddl_executed", False) is True
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from sqlalchemy import Column, Integer
|
|
5
|
+
|
|
6
|
+
from tigrbl import Base, TigrblApi, TigrblApp
|
|
7
|
+
from tigrbl.engine.shortcuts import mem
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AsyncWidget(Base):
|
|
11
|
+
__tablename__ = "widgets_async_api"
|
|
12
|
+
|
|
13
|
+
id = Column(Integer, primary_key=True)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class SyncWidget(Base):
|
|
17
|
+
__tablename__ = "widgets_sync_api"
|
|
18
|
+
|
|
19
|
+
id = Column(Integer, primary_key=True)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.mark.asyncio
|
|
23
|
+
async def test_initialize_handles_mixed_sync_async_apis():
|
|
24
|
+
async_api = TigrblApi(engine=mem())
|
|
25
|
+
async_api.include_model(AsyncWidget, prefix="")
|
|
26
|
+
|
|
27
|
+
sync_api = TigrblApi(engine=mem(async_=False))
|
|
28
|
+
sync_api.include_model(SyncWidget, prefix="")
|
|
29
|
+
|
|
30
|
+
app = TigrblApp(engine=mem(async_=False))
|
|
31
|
+
app.include_apis([async_api, sync_api])
|
|
32
|
+
|
|
33
|
+
result = app.initialize()
|
|
34
|
+
|
|
35
|
+
assert isinstance(result, asyncio.Task)
|
|
36
|
+
|
|
37
|
+
await result
|
|
38
|
+
|
|
39
|
+
assert getattr(app, "_ddl_executed", False) is True
|
|
40
|
+
assert getattr(async_api, "_ddl_executed", False) is True
|
|
41
|
+
assert getattr(sync_api, "_ddl_executed", False) is True
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from sqlalchemy import Column, Integer
|
|
5
|
+
|
|
6
|
+
from tigrbl import Base, TigrblApp
|
|
7
|
+
from tigrbl.engine.shortcuts import mem
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Widget(Base):
|
|
11
|
+
__tablename__ = "widgets"
|
|
12
|
+
|
|
13
|
+
id = Column(Integer, primary_key=True)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_initialize_schedules_task_for_sync_engine():
|
|
18
|
+
api = TigrblApp(engine=mem(async_=False))
|
|
19
|
+
api.models["Widget"] = Widget
|
|
20
|
+
|
|
21
|
+
result = api.initialize()
|
|
22
|
+
|
|
23
|
+
assert isinstance(result, asyncio.Task)
|
|
24
|
+
|
|
25
|
+
await result
|
|
26
|
+
|
|
27
|
+
assert getattr(api, "_ddl_executed", False) is True
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from fastapi.testclient import TestClient
|
|
2
|
+
from sqlalchemy import Column, String
|
|
3
|
+
from tigrbl import Base, TigrblApp
|
|
4
|
+
from tigrbl.engine.shortcuts import mem
|
|
5
|
+
from tigrbl.orm.mixins import GUIDPk
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _build_app():
|
|
9
|
+
class Widget(Base, GUIDPk):
|
|
10
|
+
__tablename__ = "widgets_openrpc"
|
|
11
|
+
name = Column(String, nullable=False)
|
|
12
|
+
|
|
13
|
+
app = TigrblApp(engine=mem(async_=False))
|
|
14
|
+
app.include_model(Widget)
|
|
15
|
+
app.initialize()
|
|
16
|
+
app.mount_jsonrpc()
|
|
17
|
+
return app, Widget
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_openrpc_endpoint_exposed():
|
|
21
|
+
app, _ = _build_app()
|
|
22
|
+
client = TestClient(app)
|
|
23
|
+
|
|
24
|
+
response = client.get("/rpc/openrpc.json")
|
|
25
|
+
|
|
26
|
+
assert response.status_code == 200
|
|
27
|
+
payload = response.json()
|
|
28
|
+
assert payload["openrpc"] == "1.2.6"
|
|
29
|
+
assert "methods" in payload
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_openrpc_includes_method_schema():
|
|
33
|
+
app, model = _build_app()
|
|
34
|
+
client = TestClient(app)
|
|
35
|
+
|
|
36
|
+
payload = client.get("/rpc/openrpc.json").json()
|
|
37
|
+
methods = {method["name"]: method for method in payload["methods"]}
|
|
38
|
+
|
|
39
|
+
create_method = methods[f"{model.__name__}.create"]
|
|
40
|
+
assert create_method["paramStructure"] == "by-name"
|
|
41
|
+
|
|
42
|
+
params = create_method["params"][0]["schema"]
|
|
43
|
+
assert params["title"].startswith(model.__name__)
|
|
44
|
+
assert "Create" in params["title"]
|
|
45
|
+
|
|
46
|
+
result = create_method["result"]["schema"]
|
|
47
|
+
assert result["title"].startswith(model.__name__)
|
|
48
|
+
assert "Response" in result["title"]
|
|
@@ -119,11 +119,15 @@ tests/unit/test_hybrid_session_run_sync.py,sha256=6zidxhpUNfE81xtS5kzQYPn36SinMP
|
|
|
119
119
|
tests/unit/test_in_tx.py,sha256=Bzn5iTkJGUpXG8J0Uduj9b8OThgPGXl-jEKfmWyWkPY,549
|
|
120
120
|
tests/unit/test_include_model_columns_namespace.py,sha256=IQhuCZ168NanMHiTlhs_B1seQwYIkaq3WaBqiWkC67c,591
|
|
121
121
|
tests/unit/test_include_models_base_prefix.py,sha256=z8Rvl3bMjf8kMLpqLn7Ia08dR1KQORrHzBIrubyEq8s,813
|
|
122
|
+
tests/unit/test_initialize_async_task.py,sha256=Q2VNj6WR9DAN_niM3g1r-K8bDkRcFB4whrwG1gaviBg,560
|
|
122
123
|
tests/unit/test_initialize_cross_ddl.py,sha256=kaku7ZVX68rDAxNBbZRaVyXSiw4Op6Jb5ex-eNHKmjU,689
|
|
124
|
+
tests/unit/test_initialize_mixed_engines.py,sha256=kQPUAsfOUwcbz3FPMaMuDQpyBIG4q_DvuC9Vye7mIvo,1017
|
|
125
|
+
tests/unit/test_initialize_task_schedule.py,sha256=OLMjubgyOxglRv2vtB6gicEK3_6WuYasZRftIPJ5sMw,555
|
|
123
126
|
tests/unit/test_io_spec_attributes.py,sha256=Da9u7yjw-KVbHF1tpQhUvl7HSfooe9L1k5y-ceRVsaM,5662
|
|
124
127
|
tests/unit/test_iospec_attributes.py,sha256=Xl5jOHBVJH4gmZqznaVrO3trqnwWYtztwRIryAnKsJo,2254
|
|
125
128
|
tests/unit/test_iospec_effects.py,sha256=frPnZNX3_dVqmG_b4rUCrrJRzGQ6JzHKCZm0GsM-csA,5687
|
|
126
129
|
tests/unit/test_jsonrpc_id_example.py,sha256=PYn6uNQEbthPpS5iKKbcNKgcgK1vu-vEPQkSU2DxdRE,338
|
|
130
|
+
tests/unit/test_jsonrpc_openrpc.py,sha256=kURb4JOb8saQJme-Gpp4L4Fgw7J3V_1WJXsFk3Mfn4Q,1392
|
|
127
131
|
tests/unit/test_jsonrpc_router_default_tag.py,sha256=AvL54oUgvuxcR_ffzZ7C-XsgkNvID68A5NHNJNSGXRc,255
|
|
128
132
|
tests/unit/test_kernel_invoke_ctx.py,sha256=w89L-XZzpNsh4A2exxbyBx6x96dLvz7ixqzxXCpNUOs,287
|
|
129
133
|
tests/unit/test_kernel_opview_on_demand.py,sha256=WQeZSzkiV8hR3_RP8OJwQTqu96nFoDz9yZOyGTkS4qU,1170
|
|
@@ -208,7 +212,7 @@ tests/unit/test_v3_op_ctx_attributes.py,sha256=ygRtYSYYtDFCTIRVHX2DFYTliP15NcmVi
|
|
|
208
212
|
tests/unit/test_v3_schemas_and_decorators.py,sha256=1wmg7pmzQNjjbQPRjO8gkCM6BQpMRbeO2jmtDMSYXLU,3818
|
|
209
213
|
tests/unit/test_v3_storage_spec_attributes.py,sha256=iXpjD4GlLddhJ_jC2veND2s6usXdOm-S9sKKfQl9XK0,6540
|
|
210
214
|
tests/unit/test_verbosity.py,sha256=92dIDc-LBIzjR1d90aL077R29rYJztibKYQGTjI6G68,1945
|
|
211
|
-
tigrbl_tests-0.3.
|
|
212
|
-
tigrbl_tests-0.3.
|
|
213
|
-
tigrbl_tests-0.3.
|
|
214
|
-
tigrbl_tests-0.3.
|
|
215
|
+
tigrbl_tests-0.3.4.dev1.dist-info/METADATA,sha256=5OGPBTuiuBGhya4q62jKQvf32VkdtqC5pf7UwSqdEEI,3892
|
|
216
|
+
tigrbl_tests-0.3.4.dev1.dist-info/WHEEL,sha256=kJCRJT_g0adfAJzTx2GUMmS80rTJIVHRCfG0DQgLq3o,88
|
|
217
|
+
tigrbl_tests-0.3.4.dev1.dist-info/licenses/LICENSE,sha256=djUXOlCxLVszShEpZXshZ7v33G-2qIC_j9KXpWKZSzQ,11359
|
|
218
|
+
tigrbl_tests-0.3.4.dev1.dist-info/RECORD,,
|
|
File without changes
|