Skip to content

Commit

Permalink
Add a test for add_target_to_bin that adds a fileinfo
Browse files Browse the repository at this point in the history
Add some additional checks to test_add_target_to_bin to ensure the code
to add a target passing a fileinfo is tested.

Signed-off-by: Joshua Lock <[email protected]>
  • Loading branch information
joshuagl committed Apr 1, 2020
1 parent 8609927 commit 62e4364
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_repository_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,20 @@ def test_add_target_to_bin(self):
self.targets_object.add_target_to_bin,
os.path.basename(target1_filepath), 16)

# Test adding a target with fileinfo
target2_hashes = {'sha256': '517c0ce943e7274a2431fa5751e17cfd5225accd23e479bfaad13007751e87ef'}
target2_fileinfo = tuf.formats.make_fileinfo(37, target2_hashes)
target2_filepath = os.path.join(self.targets_directory, 'file2.txt')

self.targets_object.add_target_to_bin(os.path.basename(target2_filepath), 16, fileinfo=target2_fileinfo)

for delegation in self.targets_object.delegations:
if delegation.rolename == '0':
self.assertTrue('file2.txt' in delegation.target_files)

else:
self.assertFalse('file2.txt' in delegation.target_files)

# Test improperly formatted argument.
self.assertRaises(securesystemslib.exceptions.FormatError,
self.targets_object.add_target_to_bin, 3, 'foo')
Expand Down

0 comments on commit 62e4364

Please sign in to comment.