1- """Tests for the get_artifact_relations tool."""
1+ """Tests for the get_artifact_relationships tool."""
22
33import pytest
44from unittest .mock import AsyncMock , MagicMock , patch
55
66from fastmcp import Context
77
8- from tools .artifact_relations import get_artifact_relations , _build_relations_xml , PROFILE_MAP
8+ from tools .artifact_relationships import get_artifact_relationships , _build_relationships_xml , PROFILE_MAP
99
1010
1111class TestProfileMapping :
@@ -25,15 +25,15 @@ def test_references_only_maps_correctly(self):
2525 assert PROFILE_MAP ["referencesOnly" ] == "ReferencesOnly"
2626
2727
28- class TestBuildRelationsXml :
29- """Test XML rendering of relation responses."""
28+ class TestBuildRelationshipsXml :
29+ """Test XML rendering of relationship responses."""
3030
31- def test_found_with_grouped_relations (self ):
31+ def test_found_with_grouped_relationships (self ):
3232 data = {
3333 "sourceIdentifier" : "org/repo::path::Symbol" ,
3434 "profile" : "CallsOnly" ,
3535 "found" : True ,
36- "relations " : [
36+ "relationships " : [
3737 {
3838 "relationType" : "OutgoingCalls" ,
3939 "totalCount" : 57 ,
@@ -64,7 +64,7 @@ def test_found_with_grouped_relations(self):
6464 ],
6565 }
6666
67- result = _build_relations_xml (data )
67+ result = _build_relationships_xml (data )
6868
6969 assert 'sourceIdentifier="org/repo::path::Symbol"' in result
7070 assert 'profile="callsOnly"' in result
@@ -86,21 +86,21 @@ def test_not_found_renders_self_closing(self):
8686 "sourceIdentifier" : "org/repo::path::Missing" ,
8787 "profile" : "CallsOnly" ,
8888 "found" : False ,
89- "relations " : [],
89+ "relationships " : [],
9090 }
9191
92- result = _build_relations_xml (data )
92+ result = _build_relationships_xml (data )
9393
9494 assert 'found="false"' in result
9595 assert result .endswith ("/>" )
96- assert "<relation_group " not in result
96+ assert "<relationship_group " not in result
9797
9898 def test_empty_group_still_rendered (self ):
9999 data = {
100100 "sourceIdentifier" : "org/repo::path::Symbol" ,
101101 "profile" : "InheritanceOnly" ,
102102 "found" : True ,
103- "relations " : [
103+ "relationships " : [
104104 {
105105 "relationType" : "Ancestors" ,
106106 "totalCount" : 0 ,
@@ -118,7 +118,7 @@ def test_empty_group_still_rendered(self):
118118 ],
119119 }
120120
121- result = _build_relations_xml (data )
121+ result = _build_relationships_xml (data )
122122
123123 assert 'type="ancestors"' in result
124124 assert 'type="descendants"' in result
@@ -129,7 +129,7 @@ def test_optional_fields_omitted_when_null(self):
129129 "sourceIdentifier" : "org/repo::path::Symbol" ,
130130 "profile" : "CallsOnly" ,
131131 "found" : True ,
132- "relations " : [
132+ "relationships " : [
133133 {
134134 "relationType" : "OutgoingCalls" ,
135135 "totalCount" : 1 ,
@@ -145,7 +145,7 @@ def test_optional_fields_omitted_when_null(self):
145145 ],
146146 }
147147
148- result = _build_relations_xml (data )
148+ result = _build_relationships_xml (data )
149149
150150 assert 'identifier="org/repo::path::Target"' in result
151151 assert "filePath" not in result
@@ -157,7 +157,7 @@ def test_html_entities_escaped(self):
157157 "sourceIdentifier" : "org/repo::path::Class<T>" ,
158158 "profile" : "CallsOnly" ,
159159 "found" : True ,
160- "relations " : [
160+ "relationships " : [
161161 {
162162 "relationType" : "OutgoingCalls" ,
163163 "totalCount" : 1 ,
@@ -173,7 +173,7 @@ def test_html_entities_escaped(self):
173173 ],
174174 }
175175
176- result = _build_relations_xml (data )
176+ result = _build_relationships_xml (data )
177177
178178 assert "Class<T>" in result
179179 assert "Method<T>" in result
@@ -187,17 +187,17 @@ def test_profile_mapped_back_to_mcp_name(self):
187187 "sourceIdentifier" : "id" ,
188188 "profile" : api_name ,
189189 "found" : False ,
190- "relations " : [],
190+ "relationships " : [],
191191 }
192- result = _build_relations_xml (data )
192+ result = _build_relationships_xml (data )
193193 assert f'profile="{ mcp_name } "' in result
194194
195195
196- class TestGetArtifactRelationsTool :
196+ class TestGetArtifactRelationshipsTool :
197197 """Test the async tool function."""
198198
199199 @pytest .mark .asyncio
200- @patch ("tools.artifact_relations .get_api_key_from_context" )
200+ @patch ("tools.artifact_relationships .get_api_key_from_context" )
201201 async def test_default_profile_sends_calls_only (self , mock_get_api_key ):
202202 mock_get_api_key .return_value = "test_key"
203203
@@ -210,7 +210,7 @@ async def test_default_profile_sends_calls_only(self, mock_get_api_key):
210210 "sourceIdentifier" : "org/repo::path::Symbol" ,
211211 "profile" : "CallsOnly" ,
212212 "found" : True ,
213- "relations " : [],
213+ "relationships " : [],
214214 }
215215 mock_response .raise_for_status = MagicMock ()
216216
@@ -222,7 +222,7 @@ async def test_default_profile_sends_calls_only(self, mock_get_api_key):
222222 mock_context .base_url = "https://app.codealive.ai"
223223 ctx .request_context .lifespan_context = mock_context
224224
225- result = await get_artifact_relations (
225+ result = await get_artifact_relationships (
226226 ctx = ctx ,
227227 identifier = "org/repo::path::Symbol" ,
228228 )
@@ -233,7 +233,7 @@ async def test_default_profile_sends_calls_only(self, mock_get_api_key):
233233 assert 'found="true"' in result
234234
235235 @pytest .mark .asyncio
236- @patch ("tools.artifact_relations .get_api_key_from_context" )
236+ @patch ("tools.artifact_relationships .get_api_key_from_context" )
237237 async def test_explicit_profile_maps_correctly (self , mock_get_api_key ):
238238 mock_get_api_key .return_value = "test_key"
239239
@@ -246,7 +246,7 @@ async def test_explicit_profile_maps_correctly(self, mock_get_api_key):
246246 "sourceIdentifier" : "id" ,
247247 "profile" : "InheritanceOnly" ,
248248 "found" : True ,
249- "relations " : [],
249+ "relationships " : [],
250250 }
251251 mock_response .raise_for_status = MagicMock ()
252252
@@ -258,7 +258,7 @@ async def test_explicit_profile_maps_correctly(self, mock_get_api_key):
258258 mock_context .base_url = "https://app.codealive.ai"
259259 ctx .request_context .lifespan_context = mock_context
260260
261- await get_artifact_relations (
261+ await get_artifact_relationships (
262262 ctx = ctx ,
263263 identifier = "id" ,
264264 profile = "inheritanceOnly" ,
@@ -270,21 +270,21 @@ async def test_explicit_profile_maps_correctly(self, mock_get_api_key):
270270 @pytest .mark .asyncio
271271 async def test_empty_identifier_returns_error (self ):
272272 ctx = MagicMock (spec = Context )
273- result = await get_artifact_relations (ctx = ctx , identifier = "" )
273+ result = await get_artifact_relationships (ctx = ctx , identifier = "" )
274274 assert "<error>" in result
275275 assert "required" in result
276276
277277 @pytest .mark .asyncio
278278 async def test_unsupported_profile_returns_error (self ):
279279 ctx = MagicMock (spec = Context )
280- result = await get_artifact_relations (
280+ result = await get_artifact_relationships (
281281 ctx = ctx , identifier = "id" , profile = "invalidProfile"
282282 )
283283 assert "<error>" in result
284284 assert "Unsupported profile" in result
285285
286286 @pytest .mark .asyncio
287- @patch ("tools.artifact_relations .get_api_key_from_context" )
287+ @patch ("tools.artifact_relationships .get_api_key_from_context" )
288288 async def test_api_error_returns_error_xml (self , mock_get_api_key ):
289289 import httpx
290290
@@ -309,13 +309,13 @@ async def test_api_error_returns_error_xml(self, mock_get_api_key):
309309 mock_context .base_url = "https://app.codealive.ai"
310310 ctx .request_context .lifespan_context = mock_context
311311
312- result = await get_artifact_relations (ctx = ctx , identifier = "id" )
312+ result = await get_artifact_relationships (ctx = ctx , identifier = "id" )
313313
314314 assert "<error>" in result
315315 assert "401" in result
316316
317317 @pytest .mark .asyncio
318- @patch ("tools.artifact_relations .get_api_key_from_context" )
318+ @patch ("tools.artifact_relationships .get_api_key_from_context" )
319319 async def test_not_found_response_renders_correctly (self , mock_get_api_key ):
320320 mock_get_api_key .return_value = "test_key"
321321
@@ -328,7 +328,7 @@ async def test_not_found_response_renders_correctly(self, mock_get_api_key):
328328 "sourceIdentifier" : "org/repo::path::Missing" ,
329329 "profile" : "CallsOnly" ,
330330 "found" : False ,
331- "relations " : [],
331+ "relationships " : [],
332332 }
333333 mock_response .raise_for_status = MagicMock ()
334334
@@ -340,7 +340,7 @@ async def test_not_found_response_renders_correctly(self, mock_get_api_key):
340340 mock_context .base_url = "https://app.codealive.ai"
341341 ctx .request_context .lifespan_context = mock_context
342342
343- result = await get_artifact_relations (ctx = ctx , identifier = "org/repo::path::Missing" )
343+ result = await get_artifact_relationships (ctx = ctx , identifier = "org/repo::path::Missing" )
344344
345345 assert 'found="false"' in result
346- assert "<relation_group " not in result
346+ assert "<relationship_group " not in result
0 commit comments