@@ -41,6 +41,8 @@ def load_normalized_nodes_module():
4141normalized_nodes = load_normalized_nodes_module ()
4242_lookup_curie_metadata = normalized_nodes ._lookup_curie_metadata
4343_lookup_equivalent_identifiers = normalized_nodes ._lookup_equivalent_identifiers
44+ create_normalized_node = normalized_nodes .create_normalized_node
45+ NormalizedNode = normalized_nodes .NormalizedNode
4446
4547
4648class FakeAsyncElasticsearch :
@@ -78,6 +80,50 @@ def no_hit_response():
7880 return {"hits" : {"total" : {"value" : 0 }, "hits" : []}}
7981
8082
83+ @pytest .mark .asyncio
84+ async def test_create_normalized_node_aggregates_descriptions_when_requested ():
85+ node = NormalizedNode (
86+ curie = "NCIT:C34373" ,
87+ canonical_identifier = "MONDO:0004976" ,
88+ preferred_label = "amyotrophic lateral sclerosis" ,
89+ information_content = 74.9 ,
90+ identifiers = [
91+ {"i" : "MONDO:0004976" , "l" : "amyotrophic lateral sclerosis" , "d" : ["first description" ]},
92+ {"i" : "NCIT:C34373" , "l" : "Amyotrophic Lateral Sclerosis" , "d" : ["second description" ]},
93+ {"i" : "UMLS:C0002736" , "l" : "Amyotrophic Lateral Sclerosis" , "d" : ["first description" , "" ]},
94+ {"i" : "MESH:D000690" , "l" : "Amyotrophic Lateral Sclerosis" },
95+ ],
96+ types = ["biolink:Disease" ],
97+ taxa = [],
98+ )
99+
100+ response = await create_normalized_node (node , include_descriptions = True )
101+
102+ assert response ["id" ]["description" ] == "first description"
103+ assert response ["descriptions" ] == ["first description" , "second description" ]
104+ assert response ["equivalent_identifiers" ][0 ]["description" ] == "first description"
105+ assert response ["equivalent_identifiers" ][1 ]["description" ] == "second description"
106+
107+
108+ @pytest .mark .asyncio
109+ async def test_create_normalized_node_hides_descriptions_by_default ():
110+ node = NormalizedNode (
111+ curie = "NCIT:C34373" ,
112+ canonical_identifier = "MONDO:0004976" ,
113+ preferred_label = "amyotrophic lateral sclerosis" ,
114+ information_content = 74.9 ,
115+ identifiers = [{"i" : "MONDO:0004976" , "l" : "amyotrophic lateral sclerosis" , "d" : ["first description" ]}],
116+ types = ["biolink:Disease" ],
117+ taxa = [],
118+ )
119+
120+ response = await create_normalized_node (node )
121+
122+ assert "description" not in response ["id" ]
123+ assert "descriptions" not in response
124+ assert "description" not in response ["equivalent_identifiers" ][0 ]
125+
126+
81127@pytest .mark .asyncio
82128async def test_lookup_equivalent_identifiers_uses_shared_msearch_index ():
83129 namespace = fake_namespace ([[hit_response ("CHEBI:17310" ), no_hit_response ()]])
0 commit comments