mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 01:44:13 +00:00
Merge branch '6.2'
Conflicts: seahub/views/__init__.py static/scripts/app/views/myhome-repos.js
This commit is contained in:
@@ -355,7 +355,6 @@ class FilesApiTest(ApiTestBase):
|
||||
|
||||
def test_list_recursive_dir(self):
|
||||
with self.get_tmp_repo() as repo:
|
||||
|
||||
# create test dir
|
||||
data = {'operation': 'mkdir'}
|
||||
dir_list = ['/1/', '/1/2/', '/1/2/3/', '/4/', '/4/5/', '/6/']
|
||||
@@ -372,6 +371,22 @@ class FilesApiTest(ApiTestBase):
|
||||
full_path = posixpath.join(dirent['parent_dir'], dirent['name']) + '/'
|
||||
self.assertIn(full_path, dir_list)
|
||||
|
||||
# get recursive dir with files info
|
||||
# create test file
|
||||
tmp_file_name = '%s.txt' % randstring()
|
||||
self.create_file(repo, fname=tmp_file_name)
|
||||
|
||||
dirents = self.get(repo.dir_url + '?t=d&recursive=1&with_files=1').json()
|
||||
self.assertHasLen(dirents, len(dir_list) + 1)
|
||||
for dirent in dirents:
|
||||
self.assertIsNotNone(dirent['id'])
|
||||
if dirent['type'] == 'dir':
|
||||
full_dir_path = posixpath.join(dirent['parent_dir'], dirent['name']) + '/'
|
||||
self.assertIn(full_dir_path, dir_list)
|
||||
else:
|
||||
full_file_path = posixpath.join(dirent['parent_dir'], dirent['name'])
|
||||
self.assertEqual('/' + tmp_file_name, full_file_path)
|
||||
|
||||
def test_remove_dir(self):
|
||||
with self.get_tmp_repo() as repo:
|
||||
_, durl = self.create_dir(repo)
|
||||
|
@@ -61,3 +61,17 @@ class SearchTest(BaseTestCase):
|
||||
self.login_as(self.user)
|
||||
resp = self.client.get(self.url)
|
||||
self.assertEqual(400, resp.status_code)
|
||||
|
||||
@patch('seahub.api2.views.HAS_FILE_SEARCH', True)
|
||||
@patch('seahub.api2.views.search_files')
|
||||
@pytest.mark.skipif(TRAVIS, reason="")
|
||||
def test_can_search_with_search_path(self, mock_search_files):
|
||||
mock_search_files.return_value = self.mock_results, \
|
||||
self.mock_total
|
||||
|
||||
self.login_as(self.user)
|
||||
resp = self.client.get(self.url + '?q=lian&search_repo=%s&search_path=%s' % (self.repo_id, '/'))
|
||||
json_resp = json.loads(resp.content)
|
||||
print json_resp
|
||||
assert json_resp['total'] == self.mock_total
|
||||
assert json_resp['results'][0]['repo_id'] == self.mock_results[0]['repo_id']
|
||||
|
Reference in New Issue
Block a user