@@ -212,3 +212,55 @@ async def test_diff_and_merge_with_attribute_value_conflict(
212212 assert action == DiffAction .UPDATED
213213 assert node_changelog .attributes ["name" ].value == "John-branch"
214214 assert node_changelog .attributes ["name" ].value_previous == "John"
215+
216+ @pytest .mark .parametrize (
217+ "conflict_selection" ,
218+ [ConflictSelection .BASE_BRANCH , ConflictSelection .DIFF_BRANCH ],
219+ )
220+ async def test_diff_and_merge_with_attribute_property_conflict (
221+ self ,
222+ db : InfrahubDatabase ,
223+ default_branch : Branch ,
224+ diff_repository : DiffRepository ,
225+ person_john_main : Node ,
226+ person_jane_main : Node ,
227+ person_alfred_main : Node ,
228+ car_accord_main : Node ,
229+ conflict_selection : ConflictSelection ,
230+ ):
231+ branch2 = await create_branch (db = db , branch_name = "branch2" )
232+ john_main = await NodeManager .get_one (db = db , id = person_john_main .id )
233+ john_main .name .source = person_alfred_main
234+ await john_main .save (db = db )
235+ john_branch = await NodeManager .get_one (db = db , branch = branch2 , id = person_john_main .id )
236+ john_branch .name .source = person_jane_main
237+ await john_branch .save (db = db )
238+
239+ at = Timestamp ()
240+ diff_coordinator = await self ._get_diff_coordinator (db = db , branch = branch2 )
241+ enriched_diff_metadata = await diff_coordinator .update_branch_diff (
242+ base_branch = default_branch , diff_branch = branch2
243+ )
244+ enriched_diff = await diff_repository .get_one (
245+ diff_branch_name = enriched_diff_metadata .diff_branch_name , diff_id = enriched_diff_metadata .uuid
246+ )
247+ conflicts_map = enriched_diff .get_all_conflicts ()
248+ assert len (conflicts_map ) == 1
249+ conflict = next (iter (conflicts_map .values ()))
250+ await diff_repository .update_conflict_by_id (conflict_id = conflict .uuid , selection = conflict_selection )
251+ diff_merger = await self ._get_diff_merger (db = db , branch = branch2 )
252+ diff = await diff_merger .merge_graph (at = at )
253+ diff_events = DiffChangelogCollector (diff = diff , db = db , branch = branch2 )
254+ events = diff_events .collect_changelogs ()
255+ match conflict_selection :
256+ case ConflictSelection .BASE_BRANCH :
257+ # When we want to keep the conflict in the base branch we don't expect to see any updates after the merge
258+ assert len (events ) == 0
259+ case ConflictSelection .DIFF_BRANCH :
260+ # Expect to see changes on the diff branch when we keep changes from that branch
261+ assert len (events ) == 1
262+ event = events [0 ]
263+ action , node_changelog = event
264+ assert action == DiffAction .UPDATED
265+ assert node_changelog .attributes ["name" ].properties ["source" ].value == person_jane_main .id
266+ assert node_changelog .attributes ["name" ].properties ["source" ].value_previous is None
0 commit comments