1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

update dir share item api test

test share failed when share the same item to the same user/group
This commit is contained in:
lian
2017-04-25 16:12:56 +08:00
parent 380aacbe89
commit 28c7fb5703

View File

@@ -105,6 +105,16 @@ class DirSharedItemsTest(BaseTestCase):
assert len(json_resp['success']) == 1
assert json_resp['success'][0]['permission'] == 'r'
# test share failed when share the same item to the same user
resp = self.client.put(
'/api2/repos/%s/dir/shared_items/?p=/' % self.repo_id,
"share_type=user&username=%s" % self.admin.email,
'application/x-www-form-urlencoded',
)
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
assert 'has been shared to' in json_resp['failed'][0]['error_msg']
def test_can_share_folder_to_users(self):
self.login_as(self.user)
@@ -119,6 +129,17 @@ class DirSharedItemsTest(BaseTestCase):
assert len(json_resp['success']) == 1
assert json_resp['success'][0]['permission'] == 'r'
# test share failed when share the same item to the same user
resp = self.client.put(
'/api2/repos/%s/dir/shared_items/?p=%s' % (self.repo.id,
self.folder),
"share_type=user&username=%s" % self.admin.email,
'application/x-www-form-urlencoded',
)
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
assert 'has been shared to' in json_resp['failed'][0]['error_msg']
def test_can_share_repo_to_groups(self):
self.login_as(self.user)
@@ -136,6 +157,16 @@ class DirSharedItemsTest(BaseTestCase):
assert len(json_resp['success']) == 2
assert json_resp['success'][0]['permission'] == 'rw'
# test share failed when share the same item to the same group
resp = self.client.put(
'/api2/repos/%s/dir/shared_items/?p=/' % (self.repo.id),
"share_type=group&group_id=%d&group_id=%d&permission=rw" % (grp1.id, grp2.id),
'application/x-www-form-urlencoded',
)
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
assert 'has been shared to' in json_resp['failed'][0]['error_msg']
def test_can_share_folder_to_groups(self):
self.login_as(self.user)
@@ -154,6 +185,17 @@ class DirSharedItemsTest(BaseTestCase):
assert len(json_resp['success']) == 2
assert json_resp['success'][0]['permission'] == 'rw'
# test share failed when share the same item to the same group
resp = self.client.put(
'/api2/repos/%s/dir/shared_items/?p=%s' % (self.repo.id,
self.folder),
"share_type=group&group_id=%d&group_id=%d&permission=rw" % (grp1.id, grp2.id),
'application/x-www-form-urlencoded',
)
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
assert 'has been shared to' in json_resp['failed'][0]['error_msg']
def test_share_with_invalid_email(self):
self.login_as(self.user)
invalid_email = '%s' % randstring(6)