@@ -190,7 +190,7 @@ def test_single_property(generate_classes):
190
190
ql .Class (name = "MyObject" , final = True ,
191
191
properties = [
192
192
ql .Property (singular = "Foo" , type = "bar" , tablename = "my_objects" ,
193
- tableparams = ["this" , "result" ]),
193
+ tableparams = ["this" , "result" ], doc_name = "foo" ),
194
194
])),
195
195
}
196
196
@@ -200,13 +200,13 @@ def test_children(generate_classes):
200
200
schema .Class ("FakeRoot" ),
201
201
schema .Class ("MyObject" , properties = [
202
202
schema .SingleProperty ("a" , "int" ),
203
- schema .SingleProperty ("child1 " , "int" , is_child = True ),
204
- schema .RepeatedProperty ("b " , "int" ),
205
- schema .RepeatedProperty ("child2 " , "int" , is_child = True ),
203
+ schema .SingleProperty ("child_1 " , "int" , is_child = True ),
204
+ schema .RepeatedProperty ("bs " , "int" ),
205
+ schema .RepeatedProperty ("children " , "int" , is_child = True ),
206
206
schema .OptionalProperty ("c" , "int" ),
207
- schema .OptionalProperty ("child3 " , "int" , is_child = True ),
207
+ schema .OptionalProperty ("child_3 " , "int" , is_child = True ),
208
208
schema .RepeatedOptionalProperty ("d" , "int" ),
209
- schema .RepeatedOptionalProperty ("child4 " , "int" , is_child = True ),
209
+ schema .RepeatedOptionalProperty ("child_4 " , "int" , is_child = True ),
210
210
]),
211
211
]) == {
212
212
"FakeRoot.qll" : (ql .Stub (name = "FakeRoot" , base_import = gen_import_prefix + "FakeRoot" ),
@@ -215,27 +215,31 @@ def test_children(generate_classes):
215
215
ql .Class (name = "MyObject" , final = True ,
216
216
properties = [
217
217
ql .Property (singular = "A" , type = "int" , tablename = "my_objects" ,
218
- tableparams = ["this" , "result" , "_" ]),
218
+ tableparams = ["this" , "result" , "_" ], doc_name = "a" ),
219
219
ql .Property (singular = "Child1" , type = "int" , tablename = "my_objects" ,
220
- tableparams = ["this" , "_" , "result" ], prev_child = "" ),
220
+ tableparams = ["this" , "_" , "result" ], prev_child = "" ,
221
+ doc_name = "child 1" ),
221
222
ql .Property (singular = "B" , plural = "Bs" , type = "int" ,
222
223
tablename = "my_object_bs" ,
223
- tableparams = ["this" , "index" , "result" ]),
224
- ql .Property (singular = "Child2" , plural = "Child2s" , type = "int" ,
225
- tablename = "my_object_child2s" ,
226
- tableparams = ["this" , "index" , "result" ], prev_child = "Child1" ),
224
+ tableparams = ["this" , "index" , "result" ],
225
+ doc_name = "b" , doc_name_plural = "bs" ),
226
+ ql .Property (singular = "Child" , plural = "Children" , type = "int" ,
227
+ tablename = "my_object_children" ,
228
+ tableparams = ["this" , "index" , "result" ], prev_child = "Child1" ,
229
+ doc_name = "child" , doc_name_plural = "children" ),
227
230
ql .Property (singular = "C" , type = "int" , tablename = "my_object_cs" ,
228
- tableparams = ["this" , "result" ], is_optional = True ),
229
- ql .Property (singular = "Child3" , type = "int" , tablename = "my_object_child3s " ,
231
+ tableparams = ["this" , "result" ], is_optional = True , doc_name = "c" ),
232
+ ql .Property (singular = "Child3" , type = "int" , tablename = "my_object_child_3s " ,
230
233
tableparams = ["this" , "result" ], is_optional = True ,
231
- prev_child = "Child2 " ),
234
+ prev_child = "Child" , doc_name = "child 3 " ),
232
235
ql .Property (singular = "D" , plural = "Ds" , type = "int" ,
233
236
tablename = "my_object_ds" ,
234
- tableparams = ["this" , "index" , "result" ], is_optional = True ),
237
+ tableparams = ["this" , "index" , "result" ], is_optional = True ,
238
+ doc_name = "d" , doc_name_plural = "ds" ),
235
239
ql .Property (singular = "Child4" , plural = "Child4s" , type = "int" ,
236
- tablename = "my_object_child4s " ,
240
+ tablename = "my_object_child_4s " ,
237
241
tableparams = ["this" , "index" , "result" ], is_optional = True ,
238
- prev_child = "Child3" ),
242
+ prev_child = "Child3" , doc_name = "child 4" , doc_name_plural = "child 4s" ),
239
243
])),
240
244
}
241
245
@@ -252,11 +256,11 @@ def test_single_properties(generate_classes):
252
256
ql .Class (name = "MyObject" , final = True ,
253
257
properties = [
254
258
ql .Property (singular = "One" , type = "x" , tablename = "my_objects" ,
255
- tableparams = ["this" , "result" , "_" , "_" ]),
259
+ tableparams = ["this" , "result" , "_" , "_" ], doc_name = "one" ),
256
260
ql .Property (singular = "Two" , type = "y" , tablename = "my_objects" ,
257
- tableparams = ["this" , "_" , "result" , "_" ]),
261
+ tableparams = ["this" , "_" , "result" , "_" ], doc_name = "two" ),
258
262
ql .Property (singular = "Three" , type = "z" , tablename = "my_objects" ,
259
- tableparams = ["this" , "_" , "_" , "result" ]),
263
+ tableparams = ["this" , "_" , "_" , "result" ], doc_name = "three" ),
260
264
])),
261
265
}
262
266
@@ -274,7 +278,7 @@ def test_optional_property(generate_classes, is_child, prev_child):
274
278
ql .Class (name = "MyObject" , final = True , properties = [
275
279
ql .Property (singular = "Foo" , type = "bar" , tablename = "my_object_foos" ,
276
280
tableparams = ["this" , "result" ],
277
- is_optional = True , prev_child = prev_child ),
281
+ is_optional = True , prev_child = prev_child , doc_name = "foo" ),
278
282
])),
279
283
}
280
284
@@ -291,7 +295,8 @@ def test_repeated_property(generate_classes, is_child, prev_child):
291
295
"MyObject.qll" : (ql .Stub (name = "MyObject" , base_import = gen_import_prefix + "MyObject" ),
292
296
ql .Class (name = "MyObject" , final = True , properties = [
293
297
ql .Property (singular = "Foo" , plural = "Foos" , type = "bar" , tablename = "my_object_foos" ,
294
- tableparams = ["this" , "index" , "result" ], prev_child = prev_child ),
298
+ tableparams = ["this" , "index" , "result" ], prev_child = prev_child ,
299
+ doc_name = "foo" , doc_name_plural = "foos" ),
295
300
])),
296
301
}
297
302
@@ -310,7 +315,7 @@ def test_repeated_optional_property(generate_classes, is_child, prev_child):
310
315
ql .Class (name = "MyObject" , final = True , properties = [
311
316
ql .Property (singular = "Foo" , plural = "Foos" , type = "bar" , tablename = "my_object_foos" ,
312
317
tableparams = ["this" , "index" , "result" ], is_optional = True ,
313
- prev_child = prev_child ),
318
+ prev_child = prev_child , doc_name = "foo" , doc_name_plural = "foos" ),
314
319
])),
315
320
}
316
321
@@ -323,8 +328,7 @@ def test_predicate_property(generate_classes):
323
328
"MyObject.qll" : (ql .Stub (name = "MyObject" , base_import = gen_import_prefix + "MyObject" ),
324
329
ql .Class (name = "MyObject" , final = True , properties = [
325
330
ql .Property (singular = "isFoo" , type = "predicate" , tablename = "my_object_is_foo" ,
326
- tableparams = ["this" ],
327
- is_predicate = True ),
331
+ tableparams = ["this" ], is_predicate = True ),
328
332
])),
329
333
}
330
334
@@ -342,7 +346,7 @@ def test_single_class_property(generate_classes, is_child, prev_child):
342
346
ql .Property (singular = "Foo" , type = "Bar" , tablename = "my_objects" ,
343
347
tableparams = [
344
348
"this" , "result" ],
345
- prev_child = prev_child ),
349
+ prev_child = prev_child , doc_name = "foo" ),
346
350
],
347
351
)),
348
352
"Bar.qll" : (ql .Stub (name = "Bar" , base_import = gen_import_prefix + "Bar" ),
@@ -629,5 +633,21 @@ def test_test_class_hierarchy_uncollapse_at_final(opts, generate_tests):
629
633
}
630
634
631
635
636
+ def test_property_doc (generate_classes ):
637
+ doc = ["Lorem" , "Ipsum" ]
638
+ assert generate_classes ([
639
+ schema .Class ("MyObject" , properties = [
640
+ schema .SingleProperty ("foo" , "bar" , doc = doc ),
641
+ ]),
642
+ ]) == {
643
+ "MyObject.qll" : (ql .Stub (name = "MyObject" , base_import = gen_import_prefix + "MyObject" ),
644
+ ql .Class (name = "MyObject" , final = True ,
645
+ properties = [
646
+ ql .Property (singular = "Foo" , type = "bar" , tablename = "my_objects" ,
647
+ tableparams = ["this" , "result" ], doc_name = "foo" , doc = doc ),
648
+ ])),
649
+ }
650
+
651
+
632
652
if __name__ == '__main__' :
633
653
sys .exit (pytest .main ([__file__ ] + sys .argv [1 :]))
0 commit comments