Skip to content

Commit e5709b2

Browse files
committed
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 <[email protected]>
1 parent c1db739 commit e5709b2

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

tests/test_tutorial.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,38 @@ def test_tutorial(self):
207207
list_of_targets = repository.get_filepaths_in_directory(
208208
os.path.join('repository', 'targets'), recursive_walk=False, followlinks=True)
209209

210-
self.assertEqual(sorted(list_of_targets),
211-
['repository/targets/file1.txt', 'repository/targets/file2.txt',
212-
'repository/targets/file3.txt'])
210+
# Ensure that we have absolute paths. (Harmless before and after PR #774,
211+
# which fixes the issue with non-absolute paths coming from
212+
# get_filepaths_in_directory.)
213+
214+
list_of_targets_temp = []
215+
216+
for t in list_of_targets:
217+
list_of_targets_temp.append(os.path.abspath(t))
218+
219+
list_of_targets = list_of_targets_temp
220+
221+
222+
self.assertEqual(sorted(list_of_targets), [
223+
os.path.abspath(os.path.join('repository', 'targets', 'file1.txt')),
224+
os.path.abspath(os.path.join('repository', 'targets', 'file2.txt')),
225+
os.path.abspath(os.path.join('repository', 'targets', 'file3.txt'))])
213226

214227

215228
repository.targets.add_targets(list_of_targets)
216229

230+
self.assertTrue('file1.txt' in repository.targets.target_files)
231+
self.assertTrue('file2.txt' in repository.targets.target_files)
232+
self.assertTrue('file3.txt' in repository.targets.target_files)
233+
234+
217235
target4_filepath = os.path.abspath(os.path.join(
218236
'repository', 'targets', 'myproject', 'file4.txt'))
219237
octal_file_permissions = oct(os.stat(target4_filepath).st_mode)[4:]
220238
custom_file_permissions = {'file_permissions': octal_file_permissions}
221239
repository.targets.add_target(target4_filepath, custom_file_permissions)
240+
self.assertTrue(os.path.join(
241+
'myproject', 'file4.txt') in repository.targets.target_files)
222242

223243

224244
# Skipping user entry of password

0 commit comments

Comments
 (0)