1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-03 16:10:26 +00:00

file participants api-v2.1

This commit is contained in:
sniper-py
2019-06-10 16:08:45 +08:00
committed by Michael An
parent 0b7a3be295
commit ae543df9b7
11 changed files with 370 additions and 31 deletions

View File

@@ -7,6 +7,7 @@ from seaserv import seafile_api, ccnet_api
from seahub.base.models import FileComment
from seahub.notifications.models import UserNotification
from seahub.test_utils import BaseTestCase
from seahub.file_participants.models import FileParticipant
class FileCommentsTest(BaseTestCase):
def setUp(self):
@@ -86,12 +87,13 @@ class FileCommentsTest(BaseTestCase):
})
self.assertEqual(403, resp.status_code)
def test_can_notify_others(self):
def test_can_notify_participant(self):
assert len(UserNotification.objects.all()) == 0
username = self.user.username
seafile_api.share_repo(self.repo.id, username,
self.admin.username, 'rw')
# share repo and add participant
seafile_api.share_repo(self.repo.id, self.user.username, self.admin.username, 'rw')
FileParticipant.objects.add_by_file_path_and_username(
repo_id=self.repo.id, file_path=self.file, username=self.admin.username)
resp = self.client.post(self.endpoint, {
'comment': 'new comment'
@@ -100,28 +102,3 @@ class FileCommentsTest(BaseTestCase):
assert len(UserNotification.objects.all()) == 1
assert UserNotification.objects.all()[0].to_user == self.admin.username
def test_can_notify_others_including_group(self):
self.logout()
self.login_as(self.tmp_user)
assert len(UserNotification.objects.all()) == 0
# share repo to tmp_user
username = self.user.username
seafile_api.share_repo(self.repo.id, username,
self.tmp_user.username, 'rw')
# share repo to group(owner, admin)
ccnet_api.group_add_member(self.group.id, username,
self.admin.username)
seafile_api.set_group_repo(self.repo.id, self.group.id,
username, 'rw')
# tmp_user comment a file
resp = self.client.post(self.endpoint, {
'comment': 'new comment'
})
self.assertEqual(201, resp.status_code)
assert len(UserNotification.objects.all()) == 2