From fc294e7ec763c07817a592895f57aaee1b19bddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B5=AB=E7=84=B6?= Date: Thu, 4 Jul 2024 10:02:15 +0800 Subject: [PATCH] Add username to testcase --- tests/config.py | 2 + tests/conftest.py | 14 +++---- .../test_file_operation.py | 38 +++++++++---------- .../test_merge_virtual_repo.py | 16 ++++---- .../test_file_operation/test_search_files.py | 6 +-- .../test_upload_and_update.py | 12 +++--- .../test_upload_large_files.py | 12 +++--- .../test_file_operation/test_zip_download.py | 14 +++---- .../test_file_property_and_dir_listing.py | 12 +++--- .../test_repo_manipulation.py | 6 +-- .../test_shared_repo_perm.py | 10 ++--- 11 files changed, 72 insertions(+), 70 deletions(-) diff --git a/tests/config.py b/tests/config.py index c70841c..c6b7fde 100644 --- a/tests/config.py +++ b/tests/config.py @@ -1,6 +1,8 @@ USER = 'testuser@test.seafile.com' +USERNAME = 'test_friendly_name' PASSWORD = 'testuser' USER2 = 'testuser2@test.seafile.com' +USERNAME2 = 'test_friendly_name2' PASSWORD2 = 'testuser2' ADMIN_USER = 'adminuser@test.seafile.com' ADMIN_PASSWORD = 'adminuser' diff --git a/tests/conftest.py b/tests/conftest.py index 372c492..b3abd46 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,7 +7,7 @@ import pytest from tenacity import retry, stop_after_attempt, wait_fixed from tests.config import ( ADMIN_PASSWORD, ADMIN_USER, INACTIVE_PASSWORD, INACTIVE_USER, PASSWORD, - PASSWORD2, USER, USER2 + PASSWORD2, USER, USER2, USERNAME ) from tests.utils import create_and_get_repo, randstring, create_and_get_group @@ -43,10 +43,10 @@ def encrypted_repo(): 'test_repo_{}'.format(randstring(10)), '', USER, passwd='123' ) try: - seafile_api.post_dir(repo.id, '/', 'dir1', USER) - seafile_api.post_dir(repo.id, '/', 'dir2', USER) - seafile_api.post_dir(repo.id, '/dir1', 'subdir1', USER) - seafile_api.post_dir(repo.id, '/dir2', 'subdir2', USER) + seafile_api.post_dir(repo.id, '/', 'dir1', USER, USERNAME) + seafile_api.post_dir(repo.id, '/', 'dir2', USER, USERNAME) + seafile_api.post_dir(repo.id, '/dir1', 'subdir1', USER, USERNAME) + seafile_api.post_dir(repo.id, '/dir2', 'subdir2', USER, USERNAME) yield repo finally: if seafile_api.get_repo(repo.id): @@ -59,8 +59,8 @@ def repo(): 'test_repo_{}'.format(randstring(10)), '', USER, passwd=None ) try: - seafile_api.post_dir(repo.id, '/', 'dir1', USER) - seafile_api.post_dir(repo.id, '/', 'dir2', USER) + seafile_api.post_dir(repo.id, '/', 'dir1', USER, USERNAME) + seafile_api.post_dir(repo.id, '/', 'dir2', USER, USERNAME) yield repo finally: if seafile_api.get_repo(repo.id): diff --git a/tests/test_file_operation/test_file_operation.py b/tests/test_file_operation/test_file_operation.py index 994abcb..06ff5e6 100644 --- a/tests/test_file_operation/test_file_operation.py +++ b/tests/test_file_operation/test_file_operation.py @@ -1,7 +1,7 @@ import pytest import os import time -from tests.config import USER +from tests.config import USER, USERNAME from seaserv import seafile_api as api file_name = 'test.txt' @@ -24,16 +24,16 @@ def test_file_operation(): create_the_file() # test post_file - assert api.post_file(t_repo_id1, file_path, '/', file_name, USER) == 0 + assert api.post_file(t_repo_id1, file_path, '/', file_name, USER, USERNAME) == 0 t_file_id = api.get_file_id_by_path(t_repo_id1, '/' + file_name) t_file_size = len(file_content) assert t_file_size == api.get_file_size(t_repo_id1, t_repo_version, t_file_id) # test post_dir - assert api.post_dir(t_repo_id1, '/', dir_name, USER) == 0 + assert api.post_dir(t_repo_id1, '/', dir_name, USER, USERNAME) == 0 # test copy_file (synchronize) - t_copy_file_result1 = api.copy_file(t_repo_id1, '/', '[\"'+file_name+'\"]', t_repo_id1, '/', '[\"'+new_file_name+'\"]', USER, 0, 1) + t_copy_file_result1 = api.copy_file(t_repo_id1, '/', '[\"'+file_name+'\"]', t_repo_id1, '/', '[\"'+new_file_name+'\"]', USER, USERNAME, 0, 1) assert t_copy_file_result1 assert t_copy_file_result1.task_id is None assert not t_copy_file_result1.background @@ -44,7 +44,7 @@ def test_file_operation(): t_repo_id2 = api.create_repo('test_file_operation2', '', USER, passwd = None) usage = api.get_user_self_usage (USER) api.set_user_quota(USER, usage + 1); - t_copy_file_result2 = api.copy_file(t_repo_id1, '/', '[\"'+file_name+'\"]', t_repo_id2, '/', '[\"'+file_name+'\"]', USER, 1, 0) + t_copy_file_result2 = api.copy_file(t_repo_id1, '/', '[\"'+file_name+'\"]', t_repo_id2, '/', '[\"'+file_name+'\"]', USER, USERNAME, 1, 0) assert t_copy_file_result2 assert t_copy_file_result2.background while True: @@ -56,7 +56,7 @@ def test_file_operation(): break; api.set_user_quota(USER, -1); - t_copy_file_result2 = api.copy_file(t_repo_id1, '/', '[\"'+file_name+'\"]', t_repo_id2, '/', '[\"'+file_name+'\"]', USER, 1, 0) + t_copy_file_result2 = api.copy_file(t_repo_id1, '/', '[\"'+file_name+'\"]', t_repo_id2, '/', '[\"'+file_name+'\"]', USER, USERNAME, 1, 0) assert t_copy_file_result2 assert t_copy_file_result2.task_id assert t_copy_file_result2.background @@ -70,7 +70,7 @@ def test_file_operation(): # test move_file (synchronize) t_move_file_info1 = api.get_dirent_by_path(t_repo_id1, '/' + new_file_name) - t_move_file_result1 = api.move_file(t_repo_id1, '/', '[\"'+new_file_name+'\"]', t_repo_id1, '/' + dir_name, '[\"'+new_file_name+'\"]', 1, USER, 0, 1) + t_move_file_result1 = api.move_file(t_repo_id1, '/', '[\"'+new_file_name+'\"]', t_repo_id1, '/' + dir_name, '[\"'+new_file_name+'\"]', 1, USER, USERNAME, 0, 1) assert t_move_file_result1 t_move_file_info2 = api.get_dirent_by_path(t_repo_id1, '/' + dir_name + '/' + new_file_name) assert t_move_file_info1.mtime == t_move_file_info2.mtime @@ -78,7 +78,7 @@ def test_file_operation(): assert t_file_id is None # test move_file (synchronize) - t_move_file_result1 = api.move_file(t_repo_id1, '/' + dir_name, '[\"'+new_file_name+'\"]', t_repo_id1, '/', '[\"'+new_file_name_2+'\"]', 1, USER, 0, 1) + t_move_file_result1 = api.move_file(t_repo_id1, '/' + dir_name, '[\"'+new_file_name+'\"]', t_repo_id1, '/', '[\"'+new_file_name_2+'\"]', 1, USER, USERNAME, 0, 1) assert t_move_file_result1 t_file_id = api.get_file_id_by_path(t_repo_id1, '/' + dir_name + '/' + new_file_name) assert t_file_id is None @@ -86,7 +86,7 @@ def test_file_operation(): # test move_file (asynchronous) usage = api.get_user_self_usage (USER) api.set_user_quota(USER, usage + 1); - t_move_file_result2 = api.move_file(t_repo_id1, '/', '[\"'+file_name+'\"]', t_repo_id2, '/' , '[\"'+new_file_name+'\"]', 1, USER, 1, 0) + t_move_file_result2 = api.move_file(t_repo_id1, '/', '[\"'+file_name+'\"]', t_repo_id2, '/' , '[\"'+new_file_name+'\"]', 1, USER, USERNAME, 1, 0) assert t_move_file_result2 assert t_move_file_result2.task_id assert t_move_file_result2.background @@ -99,7 +99,7 @@ def test_file_operation(): break api.set_user_quota(USER, -1); - t_move_file_result2 = api.move_file(t_repo_id1, '/', '[\"'+file_name+'\"]', t_repo_id2, '/' , '[\"'+new_file_name+'\"]', 1, USER, 1, 0) + t_move_file_result2 = api.move_file(t_repo_id1, '/', '[\"'+file_name+'\"]', t_repo_id2, '/' , '[\"'+new_file_name+'\"]', 1, USER, USERNAME, 1, 0) assert t_move_file_result2 assert t_move_file_result2.task_id assert t_move_file_result2.background @@ -112,15 +112,15 @@ def test_file_operation(): assert t_file_size == api.get_file_size(t_repo_id2, t_repo_version, t_file_id) # test post_empty_file - assert api.post_empty_file(t_repo_id1, '/' + dir_name, empty_file_name, USER) == 0 + assert api.post_empty_file(t_repo_id1, '/' + dir_name, empty_file_name, USER, USERNAME) == 0 t_file_id = api.get_file_id_by_path(t_repo_id1, '/' + dir_name + '/' + empty_file_name) assert api.get_file_size(t_repo_id1, t_repo_version, t_file_id) == 0 # test rename_file - assert api.rename_file(t_repo_id1, '/' + dir_name, empty_file_name, new_empty_file_name, USER) == 0 + assert api.rename_file(t_repo_id1, '/' + dir_name, empty_file_name, new_empty_file_name, USER, USERNAME) == 0 #test put_file - t_new_file_id = api.put_file(t_repo_id1, file_path, '/' + dir_name, new_empty_file_name, USER, None) + t_new_file_id = api.put_file(t_repo_id1, file_path, '/' + dir_name, new_empty_file_name, USER, USERNAME, None) assert t_new_file_id # test get_file_revisions @@ -130,7 +130,7 @@ def test_file_operation(): assert t_commit_list[0].creator_name == USER # test del_file - assert api.del_file(t_repo_id2, '/', '[\"'+file_name+'\"]', USER) == 0 + assert api.del_file(t_repo_id2, '/', '[\"'+file_name+'\"]', USER, USERNAME) == 0 # test get_deleted t_deleted_file_list = api.get_deleted(t_repo_id2, 1) @@ -140,12 +140,12 @@ def test_file_operation(): assert t_deleted_file_list[0].basedir == '/' # test del a non-exist file. should return 0. - assert api.del_file(t_repo_id2, '/', '[\"'+file_name+'\"]', USER) == 0 + assert api.del_file(t_repo_id2, '/', '[\"'+file_name+'\"]', USER, USERNAME) == 0 - assert api.del_file(t_repo_id1, '/' + dir_name, '[\"'+new_empty_file_name+'\"]', USER) == 0 - assert api.del_file(t_repo_id1, '/' + dir_name, '[\"'+new_file_name+'\"]', USER) == 0 - assert api.del_file(t_repo_id2, '/', '[\"'+new_file_name+'\"]', USER) == 0 - assert api.del_file(t_repo_id1, '/', '[\"'+new_file_name_2+'\"]', USER) == 0 + assert api.del_file(t_repo_id1, '/' + dir_name, '[\"'+new_empty_file_name+'\"]', USER, USERNAME) == 0 + assert api.del_file(t_repo_id1, '/' + dir_name, '[\"'+new_file_name+'\"]', USER, USERNAME) == 0 + assert api.del_file(t_repo_id2, '/', '[\"'+new_file_name+'\"]', USER, USERNAME) == 0 + assert api.del_file(t_repo_id1, '/', '[\"'+new_file_name_2+'\"]', USER, USERNAME) == 0 time.sleep(1) api.remove_repo(t_repo_id1) diff --git a/tests/test_file_operation/test_merge_virtual_repo.py b/tests/test_file_operation/test_merge_virtual_repo.py index de1c42b..4ab79a1 100644 --- a/tests/test_file_operation/test_merge_virtual_repo.py +++ b/tests/test_file_operation/test_merge_virtual_repo.py @@ -2,7 +2,7 @@ import pytest import requests import os import time -from tests.config import USER, USER2 +from tests.config import USER, USER2, USERNAME, USERNAME2 from seaserv import seafile_api as api from requests_toolbelt import MultipartEncoder @@ -36,7 +36,7 @@ def create_test_file(): def create_test_dir(repo, dir_name): parent_dir = '/' - api.post_dir(repo.id,parent_dir,dir_name,USER) + api.post_dir(repo.id,parent_dir,dir_name,USER, USERNAME) def assert_upload_response(response, replace, file_exist): assert response.status_code == 200 @@ -103,8 +103,8 @@ def del_local_files(): os.remove(chunked_part2_path) def test_merge_virtual_repo(repo): - api.post_dir(repo.id, '/dir1', 'subdir1', USER) - api.post_dir(repo.id, '/dir2', 'subdir2', USER) + api.post_dir(repo.id, '/dir1', 'subdir1', USER, USERNAME) + api.post_dir(repo.id, '/dir2', 'subdir2', USER, USERNAME) v_repo_id = api.share_subdir_to_user(repo.id, '/dir1', USER, USER2, 'rw') create_test_file() @@ -183,7 +183,7 @@ def test_merge_virtual_repo(repo): repo_size = api.get_repo_size (repo.id) assert repo_size == total_size + file_size - api.del_file(v_repo_id, '/', '[\"'+file_name+'\"]', USER2) + api.del_file(v_repo_id, '/', '[\"'+file_name+'\"]', USER2, USERNAME2) time.sleep (1.5) v_repo_size = api.get_repo_size (v_repo_id) @@ -192,7 +192,7 @@ def test_merge_virtual_repo(repo): repo_size = api.get_repo_size (repo.id) assert repo_size == total_size - api.del_file(v_repo_id, '/', '[\"'+resumable_file_name+'\"]', USER2) + api.del_file(v_repo_id, '/', '[\"'+resumable_file_name+'\"]', USER2, USERNAME2) time.sleep (1.5) v_repo_size = api.get_repo_size (v_repo_id) @@ -201,7 +201,7 @@ def test_merge_virtual_repo(repo): repo_size = api.get_repo_size (repo.id) assert repo_size == 0 - api.del_file(repo.id, '/dir1', '[\"subdir1\"]', USER) - api.del_file(repo.id, '/dir2', '[\"subdir1\"]', USER) + api.del_file(repo.id, '/dir1', '[\"subdir1\"]', USER, USERNAME) + api.del_file(repo.id, '/dir2', '[\"subdir1\"]', USER, USERNAME) assert api.unshare_subdir_for_user(repo.id, '/dir1', USER, USER2) == 0 del_local_files() diff --git a/tests/test_file_operation/test_search_files.py b/tests/test_file_operation/test_search_files.py index c755895..fc0fae0 100644 --- a/tests/test_file_operation/test_search_files.py +++ b/tests/test_file_operation/test_search_files.py @@ -1,7 +1,7 @@ import pytest import os import time -from tests.config import USER +from tests.config import USER, USERNAME from seaserv import seafile_api as api file_name = 'test.txt' @@ -19,8 +19,8 @@ def test_file_operation(): create_the_file() - assert api.post_file(t_repo_id1, file_path, '/', file_name, USER) == 0 - assert api.post_dir(t_repo_id1, '/', dir_name, USER) == 0 + assert api.post_file(t_repo_id1, file_path, '/', file_name, USER, USERNAME) == 0 + assert api.post_dir(t_repo_id1, '/', dir_name, USER, USERNAME) == 0 #test search files file_list = api.search_files (t_repo_id1, "test") diff --git a/tests/test_file_operation/test_upload_and_update.py b/tests/test_file_operation/test_upload_and_update.py index 0727ede..3b81554 100644 --- a/tests/test_file_operation/test_upload_and_update.py +++ b/tests/test_file_operation/test_upload_and_update.py @@ -2,7 +2,7 @@ import pytest import requests import os import time -from tests.config import USER +from tests.config import USER, USERNAME from seaserv import seafile_api as api from requests_toolbelt import MultipartEncoder @@ -36,7 +36,7 @@ def create_test_file(): def create_test_dir(repo, dir_name): parent_dir = '/' - api.post_dir(repo.id,parent_dir,dir_name,USER) + api.post_dir(repo.id,parent_dir,dir_name,USER, USERNAME) def assert_upload_response(response, replace, file_exist): assert response.status_code == 200 @@ -98,10 +98,10 @@ def write_file(file_path, file_content): fp.close() def del_repo_files(repo_id): - api.del_file(repo_id, '/', '[\"'+file_name+'\"]', USER) - api.del_file(repo_id, '/', '[\"'+file_name_not_replaced+'\"]', USER) - api.del_file(repo_id, '/', '[\"subdir\"]', USER) - api.del_file(repo_id, '/', '[\"'+resumable_file_name+'\"]', USER) + api.del_file(repo_id, '/', '[\"'+file_name+'\"]', USER, USERNAME) + api.del_file(repo_id, '/', '[\"'+file_name_not_replaced+'\"]', USER, USERNAME) + api.del_file(repo_id, '/', '[\"subdir\"]', USER, USERNAME) + api.del_file(repo_id, '/', '[\"'+resumable_file_name+'\"]', USER, USERNAME) def del_local_files(): os.remove(file_path) diff --git a/tests/test_file_operation/test_upload_large_files.py b/tests/test_file_operation/test_upload_large_files.py index 8f4b2f4..49816f1 100644 --- a/tests/test_file_operation/test_upload_large_files.py +++ b/tests/test_file_operation/test_upload_large_files.py @@ -2,7 +2,7 @@ import pytest import requests import os import hashlib -from tests.config import USER +from tests.config import USER, USERNAME from seaserv import seafile_api as api from requests_toolbelt import MultipartEncoder @@ -43,7 +43,7 @@ def create_test_file(): def create_test_dir(repo, dir_name): parent_dir = '/' - api.post_dir(repo.id,parent_dir,dir_name,USER) + api.post_dir(repo.id,parent_dir,dir_name,USER, USERNAME) def assert_upload_response(response): assert response.status_code == 200 @@ -87,10 +87,10 @@ def write_file(file_path, file_content): fp.close() def del_repo_files(repo_id): - api.del_file(repo_id, '/', '[\"'+file_name+'\"]', USER) - api.del_file(repo_id, '/', '[\"'+file_name_not_replaced+'\"]', USER) - api.del_file(repo_id, '/', '[\"subdir\"]', USER) - api.del_file(repo_id, '/', '[\"'+resumable_file_name+'\"]', USER) + api.del_file(repo_id, '/', '[\"'+file_name+'\"]', USER, USERNAME) + api.del_file(repo_id, '/', '[\"'+file_name_not_replaced+'\"]', USER, USERNAME) + api.del_file(repo_id, '/', '[\"subdir\"]', USER, USERNAME) + api.del_file(repo_id, '/', '[\"'+resumable_file_name+'\"]', USER, USERNAME) def del_local_files(): os.remove(file_path) diff --git a/tests/test_file_operation/test_zip_download.py b/tests/test_file_operation/test_zip_download.py index 3082379..b8062be 100644 --- a/tests/test_file_operation/test_zip_download.py +++ b/tests/test_file_operation/test_zip_download.py @@ -4,7 +4,7 @@ import os import time import zipfile import json -from tests.config import USER +from tests.config import USER, USERNAME from seaserv import seafile_api as api file1_name = 'file1.txt' @@ -34,9 +34,9 @@ def test_zip_download(): #test zip download dir dir_name = 'dir' - api.post_dir(t_repo_id, '/', dir_name, USER) - api.post_file(t_repo_id, file1_path, '/dir', file1_name, USER) - api.post_file(t_repo_id, file2_path, '/dir', file2_name, USER) + api.post_dir(t_repo_id, '/', dir_name, USER, USERNAME) + api.post_file(t_repo_id, file1_path, '/dir', file1_name, USER, USERNAME) + api.post_file(t_repo_id, file2_path, '/dir', file2_name, USER, USERNAME) dir_id = api.get_dir_id_by_path(t_repo_id, '/dir') obj_id = {'obj_id': dir_id, 'dir_name': dir_name, 'is_windows': 0} @@ -74,7 +74,7 @@ def test_zip_download(): #test zip download empty dir empty_dir_name = 'empty_dir' - api.post_dir(t_repo_id, '/', empty_dir_name, USER) + api.post_dir(t_repo_id, '/', empty_dir_name, USER, USERNAME) dir_id = api.get_dir_id_by_path(t_repo_id, '/empty_dir') obj_id = {'obj_id': dir_id, 'dir_name': empty_dir_name, 'is_windows': 0} @@ -100,8 +100,8 @@ def test_zip_download(): os.remove(download_dir_path + '/empty_dir.zip') #test zip download mutliple files - api.post_file(t_repo_id, file1_path, '/', file1_name, USER) - api.post_file(t_repo_id, file2_path, '/', file2_name, USER) + api.post_file(t_repo_id, file1_path, '/', file1_name, USER, USERNAME) + api.post_file(t_repo_id, file2_path, '/', file2_name, USER, USERNAME) obj_id = {'parent_dir': '/', 'file_list': [file1_name, file2_name], 'is_windows' : 0} obj_id_json_str = json.dumps(obj_id) token = api.get_fileserver_access_token(t_repo_id, obj_id_json_str, diff --git a/tests/test_file_property_and_dir_listing/test_file_property_and_dir_listing.py b/tests/test_file_property_and_dir_listing/test_file_property_and_dir_listing.py index c68a72e..8dd5a70 100644 --- a/tests/test_file_property_and_dir_listing/test_file_property_and_dir_listing.py +++ b/tests/test_file_property_and_dir_listing/test_file_property_and_dir_listing.py @@ -1,7 +1,7 @@ import pytest import os import time -from tests.config import USER +from tests.config import USER, USERNAME from seaserv import seafile_api as api file_name = 'test.txt' @@ -21,9 +21,9 @@ def test_file_property_and_dir_listing (): create_the_file() - api.post_file(t_repo_id, file_path, '/', file_name, USER) - api.post_dir(t_repo_id, '/', dir_name, USER) - api.post_file(t_repo_id, file_path, '/' + dir_name, file_name, USER) + api.post_file(t_repo_id, file_path, '/', file_name, USER, USERNAME) + api.post_dir(t_repo_id, '/', dir_name, USER, USERNAME) + api.post_file(t_repo_id, file_path, '/' + dir_name, file_name, USER, USERNAME) #test is_valid_filename t_valid_file_name = 'valid_filename' @@ -73,7 +73,7 @@ def test_file_property_and_dir_listing (): assert t_dirent_obj.mode == std_file_mode assert t_dirent_obj.version == t_repo_version assert t_dirent_obj.size == t_file_size - assert t_dirent_obj.modifier == USER + assert t_dirent_obj.modifier == USERNAME #test list_file_by_file_id t_block_list = api.list_file_by_file_id(t_repo_id, t_file_id) @@ -104,7 +104,7 @@ def test_file_property_and_dir_listing (): assert len(t_dir_list) == 1 #test mkdir_with_parent - api.mkdir_with_parents (t_repo_id, '/test_dir', 'test_subdir', USER) + api.mkdir_with_parents (t_repo_id, '/test_dir', 'test_subdir', USER, USERNAME) t_dir_id = api.get_dir_id_by_path(t_repo_id, '/test_dir/test_subdir') assert t_dir_id diff --git a/tests/test_repo_manipulation/test_repo_manipulation.py b/tests/test_repo_manipulation/test_repo_manipulation.py index 0ecdced..dbe81e6 100644 --- a/tests/test_repo_manipulation/test_repo_manipulation.py +++ b/tests/test_repo_manipulation/test_repo_manipulation.py @@ -1,5 +1,5 @@ import pytest -from tests.config import USER, USER2 +from tests.config import USER, USER2, USERNAME from seaserv import seafile_api as api def get_repo_list_order_by(t_start, t_limit, order_by): @@ -39,10 +39,10 @@ def test_repo_manipulation(): #test revert_repo and get_commit t_commit_id_before_changing = t_repo.head_cmmt_id - api.post_dir(t_repo_id, '/', 'dir1', USER) + api.post_dir(t_repo_id, '/', 'dir1', USER, USERNAME) t_repo = api.get_repo(t_repo_id) - api.revert_repo(t_repo_id, t_commit_id_before_changing, USER) + api.revert_repo(t_repo_id, t_commit_id_before_changing, USER, USERNAME) t_repo = api.get_repo(t_repo_id) t_commit_id_after_revert = t_repo.head_cmmt_id diff --git a/tests/test_share_and_perm/test_shared_repo_perm.py b/tests/test_share_and_perm/test_shared_repo_perm.py index d8a2465..7485209 100644 --- a/tests/test_share_and_perm/test_shared_repo_perm.py +++ b/tests/test_share_and_perm/test_shared_repo_perm.py @@ -3,7 +3,7 @@ import time from seaserv import seafile_api as api from seaserv import ccnet_api -from tests.config import ADMIN_USER, USER, USER2 +from tests.config import ADMIN_USER, USER, USER2, USERNAME from tests.utils import assert_repo_with_permission @@ -112,7 +112,7 @@ def test_share_dir_to_user(repo, permission): users = api.get_shared_users_for_subdir(repo.id, '/dir1', USER) assert len(users) == 1 and users[0].user == USER2 - assert api.del_file(repo.id, '/', '[\"dir1\"]', USER) == 0 + assert api.del_file(repo.id, '/', '[\"dir1\"]', USER, USERNAME) == 0 assert api.unshare_subdir_for_user(repo.id, '/dir2', USER, USER2) == 0 time.sleep(2) @@ -135,7 +135,7 @@ def test_share_dir_to_group(repo, group, permission): users = api.get_shared_groups_for_subdir(repo.id, '/dir1', USER) assert len(users) == 1 - assert api.del_file(repo.id, '/', '[\"dir1\"]', USER) == 0 + assert api.del_file(repo.id, '/', '[\"dir1\"]', USER, USERNAME) == 0 assert api.unshare_subdir_for_group(repo.id, '/dir2', USER, group.id) == 0 time.sleep(2) @@ -205,8 +205,8 @@ def test_get_shared_users_by_repo(repo, group, permission): @pytest.mark.parametrize('permission', ['r', 'rw']) def test_subdir_permission_in_virtual_repo(repo, group, permission): - api.post_dir(repo.id, '/dir1', 'subdir1', USER) - api.post_dir(repo.id, '/dir2', 'subdir2', USER) + api.post_dir(repo.id, '/dir1', 'subdir1', USER, USERNAME) + api.post_dir(repo.id, '/dir2', 'subdir2', USER, USERNAME) v_repo_id_1 = api.share_subdir_to_user(repo.id, '/dir1', USER, USER2, permission) v_subdir_repo_id_1 = api.create_virtual_repo(v_repo_id_1, '/subdir1', 'subdir1', 'test_desc', USER, passwd='')