@@ -61,13 +61,22 @@ def test_get_deleted_sentinel():
6161 assert id (sentinel ) == id (AtlanTagName .get_deleted_sentinel ())
6262
6363
64- def _assert_asset_tags (asset ):
64+ def _assert_asset_tags (asset , is_retranslated = False ):
6565 assert asset and isinstance (asset , Purpose )
6666 # Verify that deleted tags are correctly set to `None`
67- assert asset .atlan_tags and len (asset .atlan_tags ) == 3
67+ assert asset .atlan_tags and len (asset .atlan_tags ) == 5
6868 assert asset .atlan_tags [0 ].type_name .__repr__ () == f"AtlanTagName('{ DELETED_ } ')"
6969 assert asset .atlan_tags [1 ].type_name .__repr__ () == f"AtlanTagName('{ DELETED_ } ')"
7070 assert asset .atlan_tags [2 ].type_name .__repr__ () == f"AtlanTagName('{ DELETED_ } ')"
71+ if not is_retranslated :
72+ assert (
73+ asset .atlan_tags [2 ].source_tag_attachments
74+ and len (asset .atlan_tags [2 ].source_tag_attachments ) == 1
75+ )
76+ assert asset .atlan_tags [3 ].type_name .__repr__ () == f"AtlanTagName('{ DELETED_ } ')"
77+ if not is_retranslated :
78+ assert asset .atlan_tags [3 ].source_tag_attachments == []
79+ assert asset .atlan_tags [4 ].type_name .__repr__ () == f"AtlanTagName('{ DELETED_ } ')"
7180 assert asset .purpose_atlan_tags and len (asset .purpose_atlan_tags ) == 2
7281 assert asset .purpose_atlan_tags [0 ].__repr__ () == f"AtlanTagName('{ DELETED_ } ')"
7382 assert asset .purpose_atlan_tags [1 ].__repr__ () == f"AtlanTagName('{ DELETED_ } ')"
@@ -80,8 +89,14 @@ def get_name_for_id(_, __):
8089 def get_id_for_name (_ , __ ):
8190 return None
8291
83- def get_source_tags_attr_id (_ , __ ):
84- return None
92+ def get_source_tags_attr_id (_ , tag_id ):
93+ # Return different values based on tag_id to test different scenarios
94+ source_tag_ids = {
95+ "source-tag-with-attributes" : "ZLVyaOlGWDrkLFZgmZCjLa" , # source tag with attributes
96+ "source-tag-without-attributes" : "BLVyaOlGWDrkLFZgmZCjLa" ,
97+ "deleted-source-tag" : None , # deleted source tag with attributes
98+ }
99+ return source_tag_ids .get (tag_id , None ) # Return None for non-source tags
85100
86101 monkeypatch .setattr (
87102 pyatlan .cache .atlan_tag_cache .AtlanTagCache ,
@@ -132,22 +147,67 @@ def get_source_tags_attr_id(_, __):
132147 "restrictPropagationThroughLineage" : True ,
133148 "restrictPropagationThroughHierarchy" : False ,
134149 },
135- # Source tags
150+ # Source tags with attributes
151+ {
152+ "typeName" : "source-tag-with-attributes" ,
153+ "attributes" : {
154+ "ZLVyaOlGWDrkLFZgmZCjLa" : [
155+ {
156+ "typeName" : "SourceTagAttachment" ,
157+ "attributes" : {
158+ "sourceTagName" : "CONFIDENTIAL" ,
159+ "sourceTagQualifiedName" : "default/snowflake/1747816988/ANALYTICS/WIDE_WORLD_IMPORTERS/CONFIDENTIAL" ,
160+ "sourceTagGuid" : "2a9dab90-1b86-432d-a28a-9f3d9b61192b" ,
161+ "sourceTagConnectorName" : "snowflake" ,
162+ "sourceTagValue" : [
163+ {"tagAttachmentValue" : "Not Restricted" }
164+ ],
165+ },
166+ }
167+ ]
168+ },
169+ "entityGuid" : "46be9b92-170b-4c74-bf28-f9dc99021a2a" ,
170+ "entityStatus" : "ACTIVE" ,
171+ "propagate" : True ,
172+ "removePropagationsOnEntityDelete" : True ,
173+ "restrictPropagationThroughLineage" : False ,
174+ "restrictPropagationThroughHierarchy" : False ,
175+ },
176+ # Source tags (without attributes)
177+ {
178+ "typeName" : "source-tag-without-attributes" ,
179+ "entityGuid" : "46be9b92-170b-4c74-bf28-f9dc99021a2a" ,
180+ "entityStatus" : "ACTIVE" ,
181+ "propagate" : True ,
182+ "removePropagationsOnEntityDelete" : True ,
183+ "restrictPropagationThroughLineage" : False ,
184+ "restrictPropagationThroughHierarchy" : False ,
185+ },
186+ # Deleted source tags (with attributes)
136187 {
137- "typeName" : "some- deleted-source-tag-1 " ,
188+ "typeName" : "deleted-source-tag" ,
138189 "attributes" : {
139190 "XzEYmFzETBrS7nuxeImNie" : [
140191 {
141- "sourceTagName" : "CONFIDENTIAL" ,
142- "sourceTagQualifiedName" : "default/snowflake/1747816988/ANALYTICS/WIDE_WORLD_IMPORTERS/CONFIDENTIAL" ,
143- "sourceTagGuid" : "2a9dab90-1b86-432d-a28a-9f3d9b61192b" ,
144- "sourceTagConnectorName" : "snowflake" ,
145- "sourceTagValue" : [
146- {"tagAttachmentValue" : "Not Restricted" }
147- ],
192+ "typeName" : "SourceTagAttachment" ,
193+ "attributes" : {
194+ "sourceTagName" : "CONFIDENTIAL" ,
195+ "sourceTagQualifiedName" : "default/snowflake/1747816988/ANALYTICS/WIDE_WORLD_IMPORTERS/CONFIDENTIAL" ,
196+ "sourceTagGuid" : "2a9dab90-1b86-432d-a28a-9f3d9b61192b" ,
197+ "sourceTagConnectorName" : "snowflake" ,
198+ "sourceTagValue" : [
199+ {"tagAttachmentValue" : "Not Restricted" }
200+ ],
201+ },
148202 }
149203 ]
150204 },
205+ "entityGuid" : "46be9b92-170b-4c74-bf28-f9dc99021a2a" ,
206+ "entityStatus" : "DELETED" ,
207+ "propagate" : True ,
208+ "removePropagationsOnEntityDelete" : True ,
209+ "restrictPropagationThroughLineage" : False ,
210+ "restrictPropagationThroughHierarchy" : False ,
151211 },
152212 ],
153213 }
@@ -173,5 +233,7 @@ def get_source_tags_attr_id(_, __):
173233 )
174234
175235 _assert_asset_tags (purpose_with_translation )
176- _assert_asset_tags (purpose_with_translation_and_retranslation )
177- _assert_asset_tags (purpose_without_translation_and_retranslation )
236+ _assert_asset_tags (purpose_with_translation_and_retranslation , is_retranslated = True )
237+ _assert_asset_tags (
238+ purpose_without_translation_and_retranslation , is_retranslated = True
239+ )
0 commit comments