@@ -431,31 +431,105 @@ def test_node_type_properties1():
431431 f"CALL libschema.node_type_properties() YIELD nodeType, nodeLabels, propertyName, propertyTypes , mandatory RETURN nodeType, nodeLabels, propertyName, propertyTypes , mandatory ORDER BY propertyName, nodeLabels[0];" ,
432432 )[0 ]
433433 )
434- assert (result ) == [":`Activity`" , ["Activity" ], "location" , [ "String" ], True ]
434+ assert (result ) == [":`Activity`" , ["Activity" ], "location" , "String" , False ]
435435
436436 result = list (
437437 execute_and_fetch_all (
438438 cursor ,
439439 f"CALL libschema.node_type_properties() YIELD nodeType, nodeLabels, propertyName, propertyTypes , mandatory RETURN nodeType, nodeLabels, propertyName, propertyTypes , mandatory ORDER BY propertyName, nodeLabels[0];" ,
440440 )[1 ]
441441 )
442- assert (result ) == [":`Activity`" , ["Activity" ], "name" , [ "String" ], True ]
442+ assert (result ) == [":`Activity`" , ["Activity" ], "name" , "String" , False ]
443443
444444 result = list (
445445 execute_and_fetch_all (
446446 cursor ,
447447 f"CALL libschema.node_type_properties() YIELD nodeType, nodeLabels, propertyName, propertyTypes , mandatory RETURN nodeType, nodeLabels, propertyName, propertyTypes , mandatory ORDER BY propertyName, nodeLabels[0];" ,
448448 )[2 ]
449449 )
450- assert (result ) == [":`Dog`" , ["Dog" ], "name" , [ "String" ], True ]
450+ assert (result ) == [":`Dog`" , ["Dog" ], "name" , "String" , False ]
451451
452452 result = list (
453453 execute_and_fetch_all (
454454 cursor ,
455455 f"CALL libschema.node_type_properties() YIELD nodeType, nodeLabels, propertyName, propertyTypes , mandatory RETURN nodeType, nodeLabels, propertyName, propertyTypes , mandatory ORDER BY propertyName, nodeLabels[0];" ,
456456 )[3 ]
457457 )
458- assert (result ) == [":`Dog`" , ["Dog" ], "owner" , ["String" ], True ]
458+ assert (result ) == [":`Dog`" , ["Dog" ], "owner" , "String" , False ]
459+
460+
461+ def test_node_type_properties2 ():
462+ cursor = connect ().cursor ()
463+ execute_and_fetch_all (
464+ cursor ,
465+ """
466+ CREATE (d:MyNode)
467+ CREATE (n:MyNode)
468+ """ ,
469+ )
470+ result = execute_and_fetch_all (
471+ cursor ,
472+ f"CALL libschema.node_type_properties() YIELD nodeType, nodeLabels, propertyName, propertyTypes , mandatory RETURN nodeType, nodeLabels, propertyName, propertyTypes , mandatory ORDER BY propertyName, nodeLabels[0];" ,
473+ )
474+ assert (list (result [0 ])) == [":`MyNode`" , ["MyNode" ], "" , "" , False ]
475+ assert (result .__len__ ()) == 1
476+
477+
478+ def test_node_type_properties3 ():
479+ cursor = connect ().cursor ()
480+ execute_and_fetch_all (
481+ cursor ,
482+ """
483+ CREATE (d:Dog {name: 'Rex', owner: 'Carl'})
484+ CREATE (n:Dog)
485+ """ ,
486+ )
487+ result = execute_and_fetch_all (
488+ cursor ,
489+ f"CALL libschema.node_type_properties() YIELD nodeType, nodeLabels, propertyName, propertyTypes , mandatory RETURN nodeType, nodeLabels, propertyName, propertyTypes , mandatory ORDER BY propertyName, nodeLabels[0];" ,
490+ )
491+
492+ assert (list (result [0 ])) == [":`Dog`" , ["Dog" ], "name" , "String" , False ]
493+ assert (list (result [1 ])) == [":`Dog`" , ["Dog" ], "owner" , "String" , False ]
494+ assert (result .__len__ ()) == 2
495+
496+
497+ def test_node_type_properties4 ():
498+ cursor = connect ().cursor ()
499+ execute_and_fetch_all (
500+ cursor ,
501+ """
502+ CREATE (n:Label1:Label2 {property1: 'value1', property2: 'value2'})
503+ CREATE (m:Label2:Label1 {property3: 'value3'})
504+ """ ,
505+ )
506+ result = list (
507+ execute_and_fetch_all (
508+ cursor ,
509+ f"CALL libschema.node_type_properties() YIELD nodeType, nodeLabels, propertyName, propertyTypes , mandatory RETURN nodeType, nodeLabels, propertyName, propertyTypes , mandatory ORDER BY propertyName, nodeLabels[0];" ,
510+ )
511+ )
512+ assert (list (result [0 ])) == [":`Label1`:`Label2`" , ["Label1" , "Label2" ], "property1" , "String" , False ]
513+ assert (list (result [1 ])) == [":`Label1`:`Label2`" , ["Label1" , "Label2" ], "property2" , "String" , False ]
514+ assert (list (result [2 ])) == [":`Label1`:`Label2`" , ["Label1" , "Label2" ], "property3" , "String" , False ]
515+ assert (result .__len__ ()) == 3
516+
517+
518+ def test_node_type_properties5 ():
519+ cursor = connect ().cursor ()
520+ execute_and_fetch_all (
521+ cursor ,
522+ """
523+ CREATE (d:Dog {name: 'Rex'})
524+ """ ,
525+ )
526+ result = execute_and_fetch_all (
527+ cursor ,
528+ f"CALL libschema.node_type_properties() YIELD nodeType, nodeLabels, propertyName, propertyTypes , mandatory RETURN nodeType, nodeLabels, propertyName, propertyTypes , mandatory ORDER BY propertyName, nodeLabels[0];" ,
529+ )
530+
531+ assert (list (result [0 ])) == [":`Dog`" , ["Dog" ], "name" , "String" , True ]
532+ assert (result .__len__ ()) == 1
459533
460534
461535def test_rel_type_properties1 ():
@@ -473,5 +547,38 @@ def test_rel_type_properties1():
473547 assert (result ) == [":`LOVES`" , "" , "" , False ]
474548
475549
550+ def test_rel_type_properties2 ():
551+ cursor = connect ().cursor ()
552+ execute_and_fetch_all (
553+ cursor ,
554+ """
555+ CREATE (d:Dog {name: 'Rex', owner: 'Carl'})-[l:LOVES]->(a:Activity {name: 'Running', location: 'Zadar'})
556+ CREATE (n:Dog {name: 'Simba', owner: 'Lucy'})-[j:LOVES {duration: 30}]->(b:Activity {name: 'Running', location: 'Zadar'})
557+ """ ,
558+ )
559+ result = execute_and_fetch_all (
560+ cursor ,
561+ f"CALL libschema.rel_type_properties() YIELD relType,propertyName, propertyTypes , mandatory RETURN relType, propertyName, propertyTypes , mandatory;" ,
562+ )
563+ assert (list (result [0 ])) == [":`LOVES`" , "duration" , "Int" , False ]
564+ assert (result .__len__ ()) == 1
565+
566+
567+ def test_rel_type_properties3 ():
568+ cursor = connect ().cursor ()
569+ execute_and_fetch_all (
570+ cursor ,
571+ """
572+ CREATE (n:Dog {name: 'Simba', owner: 'Lucy'})-[j:LOVES {duration: 30}]->(b:Activity {name: 'Running', location: 'Zadar'})
573+ """ ,
574+ )
575+ result = execute_and_fetch_all (
576+ cursor ,
577+ f"CALL libschema.rel_type_properties() YIELD relType,propertyName, propertyTypes , mandatory RETURN relType, propertyName, propertyTypes , mandatory;" ,
578+ )
579+ assert (list (result [0 ])) == [":`LOVES`" , "duration" , "Int" , True ]
580+ assert (result .__len__ ()) == 1
581+
582+
476583if __name__ == "__main__" :
477584 sys .exit (pytest .main ([__file__ , "-rA" ]))
0 commit comments