@@ -725,6 +725,34 @@ def test_targetfile_from_data(self) -> None:
725725 targetfile_from_data = TargetFile .from_data (target_file_path , data )
726726 targetfile_from_data .verify_length_and_hashes (data )
727727
728+ def test_targetfile_get_prefixed_paths (self ) -> None :
729+ target = TargetFile (100 , {"sha256" : "abc" , "md5" : "def" }, "a/b/f.ext" )
730+ self .assertEqual (
731+ target .get_prefixed_paths (), ["a/b/abc.f.ext" , "a/b/def.f.ext" ]
732+ )
733+
734+ target = TargetFile (100 , {"sha256" : "abc" , "md5" : "def" }, "" )
735+ self .assertEqual (target .get_prefixed_paths (), ["abc." , "def." ])
736+
737+ target = TargetFile (100 , {"sha256" : "abc" , "md5" : "def" }, "a/b/" )
738+ self .assertEqual (target .get_prefixed_paths (), ["a/b/abc." , "a/b/def." ])
739+
740+ target = TargetFile (100 , {"sha256" : "abc" , "md5" : "def" }, "f.ext" )
741+ self .assertEqual (
742+ target .get_prefixed_paths (), ["abc.f.ext" , "def.f.ext" ]
743+ )
744+
745+ target = TargetFile (100 , {"sha256" : "abc" , "md5" : "def" }, "a/b/.ext" )
746+ self .assertEqual (
747+ target .get_prefixed_paths (), ["a/b/abc..ext" , "a/b/def..ext" ]
748+ )
749+
750+ target = TargetFile (100 , {"sha256" : "abc" }, "/root/file.ext" )
751+ self .assertEqual (target .get_prefixed_paths (), ["/root/abc.file.ext" ])
752+
753+ target = TargetFile (100 , {"sha256" : "abc" }, "/" )
754+ self .assertEqual (target .get_prefixed_paths (), ["/abc." ])
755+
728756 def test_is_delegated_role (self ) -> None :
729757 # test path matches
730758 # see more extensive tests in test_is_target_in_pathpattern()
0 commit comments