Port Nicola's fix to dev.

This commit is contained in:
Dave Bouvier
2016-02-25 12:36:52 -05:00
parent e3b1fc1bef
commit bae03bfe3e
+7 -7
View File
@@ -368,7 +368,7 @@ class ShedTwillTestCase( TwillTestCase ):
def delete_files_from_repository( self, repository, filenames=[], strings_displayed=[ 'were deleted from the repository' ], strings_not_displayed=[] ):
files_to_delete = []
basepath = self.get_repo_path( repository )
repository_files = self.get_repository_file_list( base_path=basepath, current_path=None )
repository_files = self.get_repository_file_list( repository=repository, base_path=basepath, current_path=None )
# Verify that the files to delete actually exist in the repository.
for filename in repository_files:
if filename in filenames:
@@ -451,9 +451,9 @@ class ShedTwillTestCase( TwillTestCase ):
relative_path = os.path.join( basepath, filepath )
else:
relative_path = basepath
repository_file_list = self.get_repository_file_list( base_path=relative_path, current_path=None )
repository_file_list = self.get_repository_file_list( repository=repository, base_path=relative_path, current_path=None )
assert filename in repository_file_list, 'File %s not found in the repository under %s.' % ( filename, relative_path )
url = '/repository/get_file_contents?file_path=%s' % os.path.join( relative_path, filename )
url = '/repository/get_file_contents?file_path=%s&repository_id=%s' % (os.path.join( relative_path, filename ), self.security.encode_id(repository.id))
self.visit_url( url )
self.check_for_strings( strings_displayed, strings_not_displayed )
@@ -701,14 +701,14 @@ class ShedTwillTestCase( TwillTestCase ):
else:
return len( metadata[ 'datatypes' ] )
def get_repository_file_list( self, base_path, current_path=None ):
def get_repository_file_list( self, repository, base_path, current_path=None ):
'''Recursively load repository folder contents and append them to a list. Similar to os.walk but via /repository/open_folder.'''
if current_path is None:
request_param_path = base_path
else:
request_param_path = os.path.join( base_path, current_path )
# Get the current folder's contents.
url = '/repository/open_folder?folder_path=%s' % request_param_path
url = '/repository/open_folder?folder_path=%s&repository_id=%s' % (request_param_path, self.security.encode_id(repository.id))
self.visit_url( url )
file_list = loads( self.last_page() )
returned_file_list = []
@@ -720,10 +720,10 @@ class ShedTwillTestCase( TwillTestCase ):
# This is a folder. Get the contents of the folder and append it to the list,
# prefixed with the path relative to the repository root, if any.
if current_path is None:
returned_file_list.extend( self.get_repository_file_list( base_path=base_path, current_path=file_dict[ 'title' ] ) )
returned_file_list.extend( self.get_repository_file_list( repository=repository, base_path=base_path, current_path=file_dict[ 'title' ] ) )
else:
sub_path = os.path.join( current_path, file_dict[ 'title' ] )
returned_file_list.extend( self.get_repository_file_list( base_path=base_path, current_path=sub_path ) )
returned_file_list.extend( self.get_repository_file_list( repository=repository, base_path=base_path, current_path=sub_path ) )
else:
# This is a regular file, prefix the filename with the current path and append it to the list.
if current_path is not None: