@@ -526,3 +526,65 @@ def test_migrate_query():
526526 expected = json .load (fp )
527527
528528 assert migrated_query == expected
529+
530+
531+ def test_generate_query_type_filter_flattened ():
532+ query = Query (
533+ node_type = "https://openminds.ebrains.eu/publications/LivePaperVersion" ,
534+ label = "fg-testing-livepaperversion" ,
535+ space = "livepapers" ,
536+ properties = [
537+ QueryProperty ("https://openminds.ebrains.eu/vocab/shortName" , name = "short_name" ),
538+ QueryProperty (
539+ [
540+ "https://openminds.ebrains.eu/vocab/relatedPublication" ,
541+ "https://openminds.ebrains.eu/vocab/identifier" ,
542+ ],
543+ type_filter = "https://openminds.ebrains.eu/core/DOI" ,
544+ name = "related_publications" ,
545+ ),
546+ ],
547+ )
548+ expected = {
549+ "@context" : {
550+ "@vocab" : "https://core.kg.ebrains.eu/vocab/query/" ,
551+ "merge" : {"@id" : "merge" , "@type" : "@id" },
552+ "query" : "https://schema.hbp.eu/myQuery/" ,
553+ "propertyName" : {"@id" : "propertyName" , "@type" : "@id" },
554+ "path" : {"@id" : "path" , "@type" : "@id" }
555+ },
556+ "meta" : {
557+ "type" : "https://openminds.ebrains.eu/publications/LivePaperVersion" ,
558+ "description" : "Automatically generated by fairgraph" ,
559+ "name" : "fg-testing-livepaperversion"
560+ },
561+ "structure" : [
562+ {
563+ "path" : "@id" ,
564+ "filter" : {
565+ "op" : "EQUALS" ,
566+ "parameter" : "id"
567+ }
568+ },
569+ {
570+ "propertyName" : "query:space" ,
571+ "path" : "https://core.kg.ebrains.eu/vocab/meta/space" ,
572+ "filter" : {
573+ "op" : "EQUALS" ,
574+ "value" : "livepapers"
575+ }
576+ },
577+ {"propertyName" : "short_name" , "path" : "https://openminds.ebrains.eu/vocab/shortName" },
578+ {
579+ "propertyName" : "related_publications" ,
580+ "path" : [
581+ {
582+ "@id" : "https://openminds.ebrains.eu/vocab/relatedPublication" ,
583+ "typeFilter" : {"@id" : "https://openminds.ebrains.eu/core/DOI" }
584+ },
585+ "https://openminds.ebrains.eu/vocab/identifier"
586+ ]
587+ }
588+ ]
589+ }
590+ assert query .serialize () == expected
0 commit comments