@@ -277,6 +277,11 @@ def read_test(file):
277277 return result , solution
278278
279279
280+ @pytest .mark .skip
281+ def sort_constraints_by_path (list_ ):
282+ return sorted (list_ , key = lambda c : c .path if c .path is not None else '' )
283+
284+
280285@pytest .mark .parametrize ('params' , [PARAMS_TC6 .copy ()])
281286def test_tc6_remove_one (params ):
282287 query = "PREFIX test6: <http://example.org/testGraph6#>\n SELECT DISTINCT ?x WHERE {\n ?x test6:property0 ?p0 .\n ?x ^test6:property2 ?p2 .\n ?x test6:property3 ?p3 .\n ?x test6:belongsTo ?y.\n }"
@@ -292,26 +297,15 @@ def test_tc6_remove_one(params):
292297
293298 shape_schema = prepare_validation (Config .from_request_form (params ), Query (query ), None )
294299 assert len (shape_schema .shapes ) == 2
295- constraints = shape_schema .shapes [ 0 ].constraints
300+ constraints = sort_constraints_by_path ( shape_schema .shapesDict [ '<http://example.org/ShapeA>' ].constraints )
296301 assert len (constraints ) == 3
297302 for i , c in enumerate (constraints ):
298303 if i == 0 :
299- assert isinstance (c , MinOnlyConstraint )
300- assert c .path == '<http://example.org/testGraph6#property3>'
301- assert c .options is None
302- assert c .min == 1
303- elif i == 1 :
304- assert isinstance (c , MinOnlyConstraint )
305- assert c .path == '<http://example.org/testGraph6#belongsTo>'
306- assert c .options is None
307- assert c .min == 1
308- assert c .shapeRef == '<http://example.org/ShapeB>'
309- else :
310304 assert isinstance (c , MinOnlyConstraint )
311305 assert c .path is None
312306 assert isinstance (c .options , list )
313307 assert len (c .options ) == 2
314- for j , orc in enumerate (c .options ):
308+ for j , orc in enumerate (sort_constraints_by_path ( c .options ) ):
315309 if j == 0 :
316310 assert isinstance (orc , MinOnlyConstraint )
317311 assert orc .path == '<http://example.org/testGraph6#property0>'
@@ -320,6 +314,17 @@ def test_tc6_remove_one(params):
320314 assert isinstance (orc , MaxOnlyConstraint )
321315 assert orc .path == '^<http://example.org/testGraph6#property2>'
322316 assert orc .max == 0
317+ elif i == 1 :
318+ assert isinstance (c , MinOnlyConstraint )
319+ assert c .path == '<http://example.org/testGraph6#belongsTo>'
320+ assert c .options is None
321+ assert c .min == 1
322+ assert c .shapeRef == '<http://example.org/ShapeB>'
323+ else :
324+ assert isinstance (c , MinOnlyConstraint )
325+ assert c .path == '<http://example.org/testGraph6#property3>'
326+ assert c .options is None
327+ assert c .min == 1
323328
324329
325330@pytest .mark .parametrize ('params' , [PARAMS_TC6 .copy ()])
@@ -336,19 +341,19 @@ def test_remove_down_to_one(params):
336341
337342 shape_schema = prepare_validation (Config .from_request_form (params ), Query (query ), None )
338343 assert len (shape_schema .shapes ) == 1
339- constraints = shape_schema .shapes [0 ].constraints
344+ constraints = sort_constraints_by_path ( shape_schema .shapes [0 ].constraints )
340345 assert len (constraints ) == 2
341346 for i , c in enumerate (constraints ):
342347 if i == 0 :
343348 assert isinstance (c , MinOnlyConstraint )
344- assert c .path == '<http://example.org/testGraph6#property3 >'
349+ assert c .path == '<http://example.org/testGraph6#property1 >'
345350 assert c .options is None
346- assert c .min == 1
351+ assert c .min == 3
347352 else :
348353 assert isinstance (c , MinOnlyConstraint )
349- assert c .path == '<http://example.org/testGraph6#property1 >'
354+ assert c .path == '<http://example.org/testGraph6#property3 >'
350355 assert c .options is None
351- assert c .min == 3
356+ assert c .min == 1
352357
353358
354359@pytest .mark .parametrize ('params' , [PARAMS_TC6 .copy ()])
0 commit comments