1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-08 10:22:46 +00:00

Add notification when comment a file

This commit is contained in:
zhengxie
2016-06-04 17:25:27 +08:00
parent bf0493ad0f
commit 00661b9be1
13 changed files with 233 additions and 5 deletions

View File

@@ -1,8 +1,11 @@
import json
from django.core.urlresolvers import reverse
import seaserv
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
class FileCommentsTest(BaseTestCase):
@@ -75,3 +78,43 @@ class FileCommentsTest(BaseTestCase):
'comment': 'new comment'
})
self.assertEqual(403, resp.status_code)
def test_can_notify_others(self):
assert len(UserNotification.objects.all()) == 0
username = self.user.username
seafile_api.share_repo(self.repo.id, username,
self.admin.username, 'rw')
resp = self.client.post(self.endpoint, {
'comment': 'new comment'
})
self.assertEqual(201, resp.status_code)
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