@@ -190,7 +190,7 @@ def test_single_property(generate_classes):
190190 ql .Class (name = "MyObject" , final = True ,
191191 properties = [
192192 ql .Property (singular = "Foo" , type = "bar" , tablename = "my_objects" ,
193- tableparams = ["this" , "result" ]),
193+ tableparams = ["this" , "result" ], doc_name = "foo" ),
194194 ])),
195195 }
196196
@@ -200,13 +200,13 @@ def test_children(generate_classes):
200200 schema .Class ("FakeRoot" ),
201201 schema .Class ("MyObject" , properties = [
202202 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 ),
206206 schema .OptionalProperty ("c" , "int" ),
207- schema .OptionalProperty ("child3 " , "int" , is_child = True ),
207+ schema .OptionalProperty ("child_3 " , "int" , is_child = True ),
208208 schema .RepeatedOptionalProperty ("d" , "int" ),
209- schema .RepeatedOptionalProperty ("child4 " , "int" , is_child = True ),
209+ schema .RepeatedOptionalProperty ("child_4 " , "int" , is_child = True ),
210210 ]),
211211 ]) == {
212212 "FakeRoot.qll" : (ql .Stub (name = "FakeRoot" , base_import = gen_import_prefix + "FakeRoot" ),
@@ -215,27 +215,31 @@ def test_children(generate_classes):
215215 ql .Class (name = "MyObject" , final = True ,
216216 properties = [
217217 ql .Property (singular = "A" , type = "int" , tablename = "my_objects" ,
218- tableparams = ["this" , "result" , "_" ]),
218+ tableparams = ["this" , "result" , "_" ], doc_name = "a" ),
219219 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" ),
221222 ql .Property (singular = "B" , plural = "Bs" , type = "int" ,
222223 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" ),
227230 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 " ,
230233 tableparams = ["this" , "result" ], is_optional = True ,
231- prev_child = "Child2 " ),
234+ prev_child = "Child" , doc_name = "child 3 " ),
232235 ql .Property (singular = "D" , plural = "Ds" , type = "int" ,
233236 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" ),
235239 ql .Property (singular = "Child4" , plural = "Child4s" , type = "int" ,
236- tablename = "my_object_child4s " ,
240+ tablename = "my_object_child_4s " ,
237241 tableparams = ["this" , "index" , "result" ], is_optional = True ,
238- prev_child = "Child3" ),
242+ prev_child = "Child3" , doc_name = "child 4" , doc_name_plural = "child 4s" ),
239243 ])),
240244 }
241245
@@ -252,11 +256,11 @@ def test_single_properties(generate_classes):
252256 ql .Class (name = "MyObject" , final = True ,
253257 properties = [
254258 ql .Property (singular = "One" , type = "x" , tablename = "my_objects" ,
255- tableparams = ["this" , "result" , "_" , "_" ]),
259+ tableparams = ["this" , "result" , "_" , "_" ], doc_name = "one" ),
256260 ql .Property (singular = "Two" , type = "y" , tablename = "my_objects" ,
257- tableparams = ["this" , "_" , "result" , "_" ]),
261+ tableparams = ["this" , "_" , "result" , "_" ], doc_name = "two" ),
258262 ql .Property (singular = "Three" , type = "z" , tablename = "my_objects" ,
259- tableparams = ["this" , "_" , "_" , "result" ]),
263+ tableparams = ["this" , "_" , "_" , "result" ], doc_name = "three" ),
260264 ])),
261265 }
262266
@@ -274,7 +278,7 @@ def test_optional_property(generate_classes, is_child, prev_child):
274278 ql .Class (name = "MyObject" , final = True , properties = [
275279 ql .Property (singular = "Foo" , type = "bar" , tablename = "my_object_foos" ,
276280 tableparams = ["this" , "result" ],
277- is_optional = True , prev_child = prev_child ),
281+ is_optional = True , prev_child = prev_child , doc_name = "foo" ),
278282 ])),
279283 }
280284
@@ -291,7 +295,8 @@ def test_repeated_property(generate_classes, is_child, prev_child):
291295 "MyObject.qll" : (ql .Stub (name = "MyObject" , base_import = gen_import_prefix + "MyObject" ),
292296 ql .Class (name = "MyObject" , final = True , properties = [
293297 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" ),
295300 ])),
296301 }
297302
@@ -310,7 +315,7 @@ def test_repeated_optional_property(generate_classes, is_child, prev_child):
310315 ql .Class (name = "MyObject" , final = True , properties = [
311316 ql .Property (singular = "Foo" , plural = "Foos" , type = "bar" , tablename = "my_object_foos" ,
312317 tableparams = ["this" , "index" , "result" ], is_optional = True ,
313- prev_child = prev_child ),
318+ prev_child = prev_child , doc_name = "foo" , doc_name_plural = "foos" ),
314319 ])),
315320 }
316321
@@ -323,8 +328,7 @@ def test_predicate_property(generate_classes):
323328 "MyObject.qll" : (ql .Stub (name = "MyObject" , base_import = gen_import_prefix + "MyObject" ),
324329 ql .Class (name = "MyObject" , final = True , properties = [
325330 ql .Property (singular = "isFoo" , type = "predicate" , tablename = "my_object_is_foo" ,
326- tableparams = ["this" ],
327- is_predicate = True ),
331+ tableparams = ["this" ], is_predicate = True ),
328332 ])),
329333 }
330334
@@ -342,7 +346,7 @@ def test_single_class_property(generate_classes, is_child, prev_child):
342346 ql .Property (singular = "Foo" , type = "Bar" , tablename = "my_objects" ,
343347 tableparams = [
344348 "this" , "result" ],
345- prev_child = prev_child ),
349+ prev_child = prev_child , doc_name = "foo" ),
346350 ],
347351 )),
348352 "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):
629633 }
630634
631635
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+
632652if __name__ == '__main__' :
633653 sys .exit (pytest .main ([__file__ ] + sys .argv [1 :]))
0 commit comments