@@ -35,12 +35,15 @@ class TestModel(base): # type: ignore[misc,valid-type]
35
35
assert r .name == "dummy"
36
36
assert r .primary_key == "id"
37
37
assert r .fields == {"id" : comp ("NumberField" , {"source" : "id" }),
38
- "num" : comp ("TextField" , {"source" : "num" })}
38
+ "num" : comp ("TextField" , {"source" : "num" , "fullWidth" : True ,
39
+ "multiline" : True })}
39
40
# Autoincremented PK should not be in create form
40
41
assert r .inputs == {
41
42
"id" : comp ("NumberInput" , {"source" : "id" , "validate" : [func ("required" , ())]})
42
43
| {"show_create" : False },
43
- "num" : comp ("TextInput" , {"source" : "num" , "validate" : [func ("required" , ())]})
44
+ "num" : comp ("TextInput" , {
45
+ "source" : "num" , "fullWidth" : True , "multiline" : True ,
46
+ "validate" : [func ("required" , ())]})
44
47
| {"show_create" : True }
45
48
}
46
49
@@ -66,6 +69,21 @@ def test_table(mock_engine: AsyncEngine) -> None:
66
69
}
67
70
68
71
72
+ def test_extra_props (base : type [DeclarativeBase ], mock_engine : AsyncEngine ) -> None :
73
+ class TestModel (base ): # type: ignore[misc,valid-type]
74
+ __tablename__ = "dummy"
75
+ id : Mapped [int ] = mapped_column (primary_key = True )
76
+ num : Mapped [str ] = mapped_column (sa .String (128 ), comment = "Foo" , default = "Bar" )
77
+
78
+ r = SAResource (mock_engine , TestModel )
79
+ assert r .fields ["num" ]["props" ] == {
80
+ "source" : "num" , "fullWidth" : True , "multiline" : True , "placeholder" : "Bar" ,
81
+ "helperText" : "Foo" }
82
+ assert r .inputs ["num" ]["props" ] == {
83
+ "source" : "num" , "fullWidth" : True , "multiline" : True , "placeholder" : "Bar" ,
84
+ "helperText" : "Foo" , "validate" : [func ("maxLength" , (128 ,))]}
85
+
86
+
69
87
async def test_binary (
70
88
base : DeclarativeBase , aiohttp_client : Callable [[web .Application ], Awaitable [TestClient ]],
71
89
login : _Login
@@ -243,19 +261,21 @@ async def test_nonid_pk(base: type[DeclarativeBase], mock_engine: AsyncEngine) -
243
261
class TestModel (base ): # type: ignore[misc,valid-type]
244
262
__tablename__ = "test"
245
263
num : Mapped [int ] = mapped_column (primary_key = True )
246
- other : Mapped [str ]
264
+ other : Mapped [str ] = mapped_column ( sa . String ( 64 ))
247
265
248
266
r = SAResource (mock_engine , TestModel )
249
267
assert r .name == "test"
250
268
assert r .primary_key == "num"
251
269
assert r .fields == {
252
270
"num" : comp ("NumberField" , {"source" : "num" }),
253
- "other" : comp ("TextField" , {"source" : "other" })
271
+ "other" : comp ("TextField" , {"source" : "other" , "fullWidth" : True })
254
272
}
255
273
assert r .inputs == {
256
274
"num" : comp ("NumberInput" , {"source" : "num" , "validate" : [func ("required" , ())]})
257
275
| {"show_create" : False },
258
- "other" : comp ("TextInput" , {"source" : "other" , "validate" : [func ("required" , ())]})
276
+ "other" : comp ("TextInput" , {
277
+ "fullWidth" : True , "source" : "other" ,
278
+ "validate" : [func ("required" , ()), func ("maxLength" , (64 ,))]})
259
279
| {"show_create" : True }
260
280
}
261
281
0 commit comments