mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Test: Correctly test target addition in tutorial despite #774
(that is, despite currently existing issue to be remedied in #774) Currently, repository_tool.get_filepaths_in_directory yields relative paths, not the absolute paths it promises in its docstring. This test will now function despite this and continue to function after #774 is merged. Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
This commit is contained in:
parent
6c850e062b
commit
bfcdfd5c5a
1 changed files with 23 additions and 3 deletions
|
|
@ -207,18 +207,38 @@ def test_tutorial(self):
|
|||
list_of_targets = repository.get_filepaths_in_directory(
|
||||
os.path.join('repository', 'targets'), recursive_walk=False, followlinks=True)
|
||||
|
||||
self.assertEqual(sorted(list_of_targets),
|
||||
['repository/targets/file1.txt', 'repository/targets/file2.txt',
|
||||
'repository/targets/file3.txt'])
|
||||
# Ensure that we have absolute paths. (Harmless before and after PR #774,
|
||||
# which fixes the issue with non-absolute paths coming from
|
||||
# get_filepaths_in_directory.)
|
||||
|
||||
list_of_targets_temp = []
|
||||
|
||||
for t in list_of_targets:
|
||||
list_of_targets_temp.append(os.path.abspath(t))
|
||||
|
||||
list_of_targets = list_of_targets_temp
|
||||
|
||||
|
||||
self.assertEqual(sorted(list_of_targets), [
|
||||
os.path.abspath(os.path.join('repository', 'targets', 'file1.txt')),
|
||||
os.path.abspath(os.path.join('repository', 'targets', 'file2.txt')),
|
||||
os.path.abspath(os.path.join('repository', 'targets', 'file3.txt'))])
|
||||
|
||||
|
||||
repository.targets.add_targets(list_of_targets)
|
||||
|
||||
self.assertTrue('file1.txt' in repository.targets.target_files)
|
||||
self.assertTrue('file2.txt' in repository.targets.target_files)
|
||||
self.assertTrue('file3.txt' in repository.targets.target_files)
|
||||
|
||||
|
||||
target4_filepath = os.path.abspath(os.path.join(
|
||||
'repository', 'targets', 'myproject', 'file4.txt'))
|
||||
octal_file_permissions = oct(os.stat(target4_filepath).st_mode)[4:]
|
||||
custom_file_permissions = {'file_permissions': octal_file_permissions}
|
||||
repository.targets.add_target(target4_filepath, custom_file_permissions)
|
||||
self.assertTrue(os.path.join(
|
||||
'myproject', 'file4.txt') in repository.targets.target_files)
|
||||
|
||||
|
||||
# Skipping user entry of password
|
||||
|
|
|
|||
Loading…
Reference in a new issue