@@ -492,3 +492,28 @@ class Cmd:
492492
493493 assert [j ["kind" ] for j in i ["shortcuts" ]] == ["b" ]
494494 assert [j ["kind" ] for j in i ["__original-shortcuts" ]] == ["a" , "b" , "c" ]
495+
496+
497+ def test_finalize_metadata_merge_from (tmp_path ):
498+ class Cmd :
499+ enable_shortcut_kinds = []
500+ disable_shortcut_kinds = []
501+ fallback_source = None
502+
503+ merge_from = tmp_path / "file.json"
504+ test_url_1 = "https://example.com/"
505+ test_url_2 = "https://example.com/path2"
506+
507+ # merge_from does not exist, but we shouldn't fail
508+ i = {"url" : test_url_1 }
509+ IC ._finalize_metadata (Cmd , i , merge_from )
510+ assert i ["url" ] == test_url_1
511+
512+ # Update missing fields from merge_from, but don't touch existing ones
513+ with open (merge_from , "w" , encoding = "utf-8" ) as f :
514+ json .dump ({"url" : test_url_1 , "data1" : "b" , "data2" : "c" }, f )
515+ i = {"url" : test_url_2 , "data1" : "a" }
516+ IC ._finalize_metadata (Cmd , i , merge_from )
517+ assert i ["url" ] == test_url_2
518+ assert i ["data1" ] == "a"
519+ assert i ["data2" ] == "c"
0 commit comments