Skip to content

Commit

Permalink
Test: Correctly test target addition in tutorial despite #774
Browse files Browse the repository at this point in the history
(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 <[email protected]>
  • Loading branch information
awwad committed Aug 21, 2018
1 parent 5f43274 commit f7f003d
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions tests/test_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f7f003d

Please sign in to comment.