@@ -61,13 +61,22 @@ def test_get_deleted_sentinel():
61
61
assert id (sentinel ) == id (AtlanTagName .get_deleted_sentinel ())
62
62
63
63
64
- def _assert_asset_tags (asset ):
64
+ def _assert_asset_tags (asset , is_retranslated = False ):
65
65
assert asset and isinstance (asset , Purpose )
66
66
# 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
68
68
assert asset .atlan_tags [0 ].type_name .__repr__ () == f"AtlanTagName('{ DELETED_ } ')"
69
69
assert asset .atlan_tags [1 ].type_name .__repr__ () == f"AtlanTagName('{ DELETED_ } ')"
70
70
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_ } ')"
71
80
assert asset .purpose_atlan_tags and len (asset .purpose_atlan_tags ) == 2
72
81
assert asset .purpose_atlan_tags [0 ].__repr__ () == f"AtlanTagName('{ DELETED_ } ')"
73
82
assert asset .purpose_atlan_tags [1 ].__repr__ () == f"AtlanTagName('{ DELETED_ } ')"
@@ -80,8 +89,14 @@ def get_name_for_id(_, __):
80
89
def get_id_for_name (_ , __ ):
81
90
return None
82
91
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
85
100
86
101
monkeypatch .setattr (
87
102
pyatlan .cache .atlan_tag_cache .AtlanTagCache ,
@@ -132,22 +147,67 @@ def get_source_tags_attr_id(_, __):
132
147
"restrictPropagationThroughLineage" : True ,
133
148
"restrictPropagationThroughHierarchy" : False ,
134
149
},
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)
136
187
{
137
- "typeName" : "some- deleted-source-tag-1 " ,
188
+ "typeName" : "deleted-source-tag" ,
138
189
"attributes" : {
139
190
"XzEYmFzETBrS7nuxeImNie" : [
140
191
{
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
+ },
148
202
}
149
203
]
150
204
},
205
+ "entityGuid" : "46be9b92-170b-4c74-bf28-f9dc99021a2a" ,
206
+ "entityStatus" : "DELETED" ,
207
+ "propagate" : True ,
208
+ "removePropagationsOnEntityDelete" : True ,
209
+ "restrictPropagationThroughLineage" : False ,
210
+ "restrictPropagationThroughHierarchy" : False ,
151
211
},
152
212
],
153
213
}
@@ -173,5 +233,7 @@ def get_source_tags_attr_id(_, __):
173
233
)
174
234
175
235
_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