@@ -212,6 +212,56 @@ def test_tags_empty_when_none(self, client):
212212 loc = resp .get_json ()["locations" ][1 ]
213213 assert loc ["tags" ] == []
214214
215+ def test_tags_fallback_with_brief_nested_object (self , client ):
216+ """When tags are brief (id+url only), the fallback map resolves names."""
217+ brief_locations = {
218+ "count" : 1 ,
219+ "next" : None ,
220+ "results" : [
221+ {
222+ "id" : "loc-tags" ,
223+ "name" : "Tagged Location" ,
224+ "slug" : "tagged-loc" ,
225+ "status" : {"label" : "Active" },
226+ "location_type" : {"name" : "Data Center" },
227+ "parent" : None ,
228+ "latitude" : "55.0" ,
229+ "longitude" : "12.0" ,
230+ "description" : "" ,
231+ "physical_address" : "" ,
232+ "tenant" : None ,
233+ "asn" : None ,
234+ "time_zone" : "" ,
235+ "facility" : "" ,
236+ "tags" : [
237+ {"id" : "tag-1" , "url" : "http://nautobot/api/extras/tags/tag-1/" },
238+ {"id" : "tag-2" , "url" : "http://nautobot/api/extras/tags/tag-2/" },
239+ ],
240+ "url" : "" ,
241+ },
242+ ],
243+ }
244+ tags_page = {
245+ "count" : 2 ,
246+ "next" : None ,
247+ "results" : [
248+ {"id" : "tag-1" , "name" : "critical" },
249+ {"id" : "tag-2" , "name" : "production" },
250+ ],
251+ }
252+
253+ def mock_get (endpoint , params = None ):
254+ if "extras/tags" in endpoint :
255+ return tags_page
256+ if "dcim/locations" in endpoint :
257+ return brief_locations
258+ return {"count" : 0 , "next" : None , "results" : []}
259+
260+ with patch .object (flask_app , "nautobot_get" , side_effect = mock_get ):
261+ resp = client .get ("/api/locations" )
262+ loc = resp .get_json ()["locations" ][0 ]
263+ assert loc ["tags" ] == ["critical" , "production" ]
264+
215265 def test_location_type_fallback_with_brief_nested_object (self , client ):
216266 """When location_type is brief (id+url only), the fallback map resolves the name."""
217267 brief_locations = {
0 commit comments