mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
udpate group transfer test
This commit is contained in:
@@ -6,9 +6,17 @@ from seaserv import ccnet_api
|
|||||||
from seahub.test_utils import BaseTestCase
|
from seahub.test_utils import BaseTestCase
|
||||||
from tests.common.utils import randstring
|
from tests.common.utils import randstring
|
||||||
|
|
||||||
|
try:
|
||||||
|
from seahub.settings import LOCAL_PRO_DEV_ENV
|
||||||
|
except ImportError:
|
||||||
|
LOCAL_PRO_DEV_ENV = False
|
||||||
|
|
||||||
class GroupsTest(BaseTestCase):
|
class GroupsTest(BaseTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
if not LOCAL_PRO_DEV_ENV:
|
||||||
|
return
|
||||||
|
|
||||||
self.user_name = self.user.username
|
self.user_name = self.user.username
|
||||||
self.admin_name = self.admin.username
|
self.admin_name = self.admin.username
|
||||||
|
|
||||||
@@ -20,9 +28,15 @@ class GroupsTest(BaseTestCase):
|
|||||||
args=[self.top_group_id])
|
args=[self.top_group_id])
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
if not LOCAL_PRO_DEV_ENV:
|
||||||
|
return
|
||||||
|
|
||||||
self.remove_group(self.top_group_id)
|
self.remove_group(self.top_group_id)
|
||||||
|
|
||||||
def test_can_list_child_groups(self):
|
def test_can_list_child_groups(self):
|
||||||
|
if not LOCAL_PRO_DEV_ENV:
|
||||||
|
return
|
||||||
|
|
||||||
child_group_id = ccnet_api.create_group('child group xxx',
|
child_group_id = ccnet_api.create_group('child group xxx',
|
||||||
self.user.username,
|
self.user.username,
|
||||||
parent_group_id=self.top_group_id)
|
parent_group_id=self.top_group_id)
|
||||||
@@ -37,6 +51,9 @@ class GroupsTest(BaseTestCase):
|
|||||||
self.remove_group(child_group_id)
|
self.remove_group(child_group_id)
|
||||||
|
|
||||||
def test_can_ancestor_groups(self):
|
def test_can_ancestor_groups(self):
|
||||||
|
if not LOCAL_PRO_DEV_ENV:
|
||||||
|
return
|
||||||
|
|
||||||
child_group_id = ccnet_api.create_group('child group xxx',
|
child_group_id = ccnet_api.create_group('child group xxx',
|
||||||
self.user.username,
|
self.user.username,
|
||||||
parent_group_id=self.top_group_id)
|
parent_group_id=self.top_group_id)
|
||||||
@@ -52,10 +69,16 @@ class GroupsTest(BaseTestCase):
|
|||||||
self.remove_group(child_group_id)
|
self.remove_group(child_group_id)
|
||||||
|
|
||||||
def test_can_delete_group(self):
|
def test_can_delete_group(self):
|
||||||
|
if not LOCAL_PRO_DEV_ENV:
|
||||||
|
return
|
||||||
|
|
||||||
resp = self.client.delete(self.url)
|
resp = self.client.delete(self.url)
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
|
|
||||||
def test_cannot_delete_group_with_child(self):
|
def test_cannot_delete_group_with_child(self):
|
||||||
|
if not LOCAL_PRO_DEV_ENV:
|
||||||
|
return
|
||||||
|
|
||||||
child_group_id = ccnet_api.create_group('child group xxx',
|
child_group_id = ccnet_api.create_group('child group xxx',
|
||||||
self.user.username,
|
self.user.username,
|
||||||
parent_group_id=self.top_group_id)
|
parent_group_id=self.top_group_id)
|
||||||
|
@@ -6,6 +6,11 @@ from seaserv import ccnet_api
|
|||||||
from seahub.test_utils import BaseTestCase
|
from seahub.test_utils import BaseTestCase
|
||||||
from tests.common.utils import randstring
|
from tests.common.utils import randstring
|
||||||
|
|
||||||
|
try:
|
||||||
|
from seahub.settings import LOCAL_PRO_DEV_ENV
|
||||||
|
except ImportError:
|
||||||
|
LOCAL_PRO_DEV_ENV = False
|
||||||
|
|
||||||
|
|
||||||
class GroupsTest(BaseTestCase):
|
class GroupsTest(BaseTestCase):
|
||||||
|
|
||||||
@@ -17,6 +22,9 @@ class GroupsTest(BaseTestCase):
|
|||||||
self.url = reverse('api-v2.1-admin-address-book-groups')
|
self.url = reverse('api-v2.1-admin-address-book-groups')
|
||||||
|
|
||||||
def test_can_list_top_groups(self):
|
def test_can_list_top_groups(self):
|
||||||
|
if not LOCAL_PRO_DEV_ENV:
|
||||||
|
return
|
||||||
|
|
||||||
top_group_id = ccnet_api.create_group('top group xxx', self.user.username,
|
top_group_id = ccnet_api.create_group('top group xxx', self.user.username,
|
||||||
parent_group_id=-1)
|
parent_group_id=-1)
|
||||||
|
|
||||||
@@ -29,6 +37,9 @@ class GroupsTest(BaseTestCase):
|
|||||||
self.remove_group(top_group_id)
|
self.remove_group(top_group_id)
|
||||||
|
|
||||||
def test_can_create_top_group(self):
|
def test_can_create_top_group(self):
|
||||||
|
if not LOCAL_PRO_DEV_ENV:
|
||||||
|
return
|
||||||
|
|
||||||
resp = self.client.post(self.url, {
|
resp = self.client.post(self.url, {
|
||||||
'group_name': randstring(10),
|
'group_name': randstring(10),
|
||||||
'parent_group': -1,
|
'parent_group': -1,
|
||||||
@@ -43,6 +54,9 @@ class GroupsTest(BaseTestCase):
|
|||||||
self.remove_group(json_resp['id'])
|
self.remove_group(json_resp['id'])
|
||||||
|
|
||||||
def test_can_create_child_group(self):
|
def test_can_create_child_group(self):
|
||||||
|
if not LOCAL_PRO_DEV_ENV:
|
||||||
|
return
|
||||||
|
|
||||||
top_group_id = ccnet_api.create_group('top group xxx', self.user.username,
|
top_group_id = ccnet_api.create_group('top group xxx', self.user.username,
|
||||||
parent_group_id=-1)
|
parent_group_id=-1)
|
||||||
|
|
||||||
|
@@ -123,7 +123,7 @@ class GroupTest(BaseTestCase):
|
|||||||
|
|
||||||
# invalid new owner
|
# invalid new owner
|
||||||
url = reverse('api-v2.1-admin-group', args=[self.group_id])
|
url = reverse('api-v2.1-admin-group', args=[self.group_id])
|
||||||
data = 'invalid_new_owner=%s' % self.admin_name
|
data = 'new_owner=%s' % randstring(6)
|
||||||
resp = self.client.put(url, data, 'application/x-www-form-urlencoded')
|
resp = self.client.put(url, data, 'application/x-www-form-urlencoded')
|
||||||
self.assertEqual(400, resp.status_code)
|
self.assertEqual(400, resp.status_code)
|
||||||
|
|
||||||
|
@@ -13,6 +13,11 @@ from seahub.test_utils import BaseTestCase
|
|||||||
from seahub.notifications.management.commands.send_notices import Command
|
from seahub.notifications.management.commands.send_notices import Command
|
||||||
from seahub.share.utils import share_dir_to_user, share_dir_to_group
|
from seahub.share.utils import share_dir_to_user, share_dir_to_group
|
||||||
|
|
||||||
|
try:
|
||||||
|
from seahub.settings import LOCAL_PRO_DEV_ENV
|
||||||
|
except ImportError:
|
||||||
|
LOCAL_PRO_DEV_ENV = False
|
||||||
|
|
||||||
|
|
||||||
class CommandTest(BaseTestCase):
|
class CommandTest(BaseTestCase):
|
||||||
|
|
||||||
@@ -115,6 +120,9 @@ class CommandTest(BaseTestCase):
|
|||||||
assert 'Guest test@test.com' in mail.outbox[0].body
|
assert 'Guest test@test.com' in mail.outbox[0].body
|
||||||
|
|
||||||
def test_format_repo_share_msg(self):
|
def test_format_repo_share_msg(self):
|
||||||
|
if not LOCAL_PRO_DEV_ENV:
|
||||||
|
return
|
||||||
|
|
||||||
detail = repo_share_msg_to_json('share@share.com', self.repo.id, '', -1)
|
detail = repo_share_msg_to_json('share@share.com', self.repo.id, '', -1)
|
||||||
notice = UserNotification.objects.add_repo_share_msg('to@to.com', detail)
|
notice = UserNotification.objects.add_repo_share_msg('to@to.com', detail)
|
||||||
resp = Command().format_repo_share_msg(notice)
|
resp = Command().format_repo_share_msg(notice)
|
||||||
@@ -129,6 +137,9 @@ class CommandTest(BaseTestCase):
|
|||||||
assert resp.group_url == '/#group/%(group_id)s/discussions/' % {'group_id': self.group.id}
|
assert resp.group_url == '/#group/%(group_id)s/discussions/' % {'group_id': self.group.id}
|
||||||
|
|
||||||
def test_format_repo_share_to_group_msg(self):
|
def test_format_repo_share_to_group_msg(self):
|
||||||
|
if not LOCAL_PRO_DEV_ENV:
|
||||||
|
return
|
||||||
|
|
||||||
detail = repo_share_to_group_msg_to_json('repo@share.com', self.repo.id, self.group.id, '', -1)
|
detail = repo_share_to_group_msg_to_json('repo@share.com', self.repo.id, self.group.id, '', -1)
|
||||||
notice = UserNotification.objects.add_repo_share_to_group_msg('group@share.com', detail)
|
notice = UserNotification.objects.add_repo_share_to_group_msg('group@share.com', detail)
|
||||||
resp = Command().format_repo_share_to_group_msg(notice)
|
resp = Command().format_repo_share_to_group_msg(notice)
|
||||||
|
Reference in New Issue
Block a user