Skip to content

Commit d06f8fb

Browse files
committed
add entity test
1 parent d18de76 commit d06f8fb

File tree

13 files changed

+4011
-0
lines changed

13 files changed

+4011
-0
lines changed

tests/entities/__init__.py

Whitespace-only changes.

tests/entities/models/__init__.py

Whitespace-only changes.

tests/entities/models/types/__init__.py

Whitespace-only changes.

tests/entities/models/types/app.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from teo import App, Request, Response, HandlerGroup
2+
from tests.helpers.schema_path_args import schema_path_args
3+
from .entities import SupportCreateInput, SupportFindManyArgs, Teo
4+
5+
6+
def load_app():
7+
app = App(schema_path_args(__file__, "schema.teo"))
8+
def support_handler_group(group: HandlerGroup):
9+
async def my_create_object(req: Request):
10+
teo: Teo = req.teo()
11+
input: SupportCreateInput = req.body_object()
12+
object = await teo.support.create_object(input)
13+
await object.save()
14+
return Response.data(await object.to_teon())
15+
group.define_handler("myCreateObject", my_create_object)
16+
async def my_find_many_objects(req: Request):
17+
teo: Teo = req.teo()
18+
input: SupportFindManyArgs = req.body_object()
19+
objects = await teo.support.find_many_objects(input)
20+
values = [await object.to_teon() for object in objects]
21+
return Response.data(values)
22+
group.define_handler("myFindManyObjects", my_find_many_objects)
23+
app.main_namespace().define_model_handler_group("Support", support_handler_group)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import "./schema"
2+
3+
dataset default {
4+
group Support {
5+
record default {
6+
int32: 0,
7+
int64: 0,
8+
float32: 0.0,
9+
float64: 0,
10+
bool: false,
11+
string: "",
12+
date: Date("1970-01-01"),
13+
dateTime: DateTime("1970-01-01T00:00:00.000Z"),
14+
decimal: Decimal("0"),
15+
sex: .male,
16+
int32Array: [1],
17+
int64Array: [1],
18+
float32Array: [1],
19+
float64Array: [1.0],
20+
boolArray: [false],
21+
stringArray: ["a"],
22+
dateArray: [Date("2024-11-07")],
23+
dateTimeArray: [DateTime("2024-11-07T00:00:00.000Z")],
24+
decimalArray: [Decimal("1")],
25+
sexesArray: [.male, .female]
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)