mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
Update group unit test
This commit is contained in:
@@ -25,15 +25,12 @@ class MessageReply(models.Model):
|
|||||||
|
|
||||||
class MessageAttachment(models.Model):
|
class MessageAttachment(models.Model):
|
||||||
"""
|
"""
|
||||||
|
A model used to represents a file attachment related to a group message.
|
||||||
"""
|
"""
|
||||||
group_message = models.ForeignKey(GroupMessage)
|
group_message = models.ForeignKey(GroupMessage)
|
||||||
repo_id = models.CharField(max_length=40)
|
repo_id = models.CharField(max_length=40)
|
||||||
file_path = models.TextField()
|
file_path = models.TextField()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
at_pattern = re.compile(r'(\s|^)(@\w+)', flags=re.U)
|
at_pattern = re.compile(r'(\s|^)(@\w+)', flags=re.U)
|
||||||
|
|
||||||
@receiver(post_save, sender=MessageReply)
|
@receiver(post_save, sender=MessageReply)
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
# encoding: utf-8
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -105,3 +106,29 @@ class ReplyMessageTest(GroupTestCase):
|
|||||||
|
|
||||||
def test_no_notification_when_at_user_not_in_group(self):
|
def test_no_notification_when_at_user_not_in_group(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class GroupRecommendTest(GroupTestCase):
|
||||||
|
def test_recommend_file_with_error_format_group_name(self):
|
||||||
|
response = self.client.post('/group/recommend/', {
|
||||||
|
'groups': 'unparticipated_group,',
|
||||||
|
'repo_id': '0b21f61f-3015-4736-bd3f-9fd10cbff3c8',
|
||||||
|
'file_path': '/test.c',
|
||||||
|
'message': 'hello',
|
||||||
|
}, follow=True)
|
||||||
|
|
||||||
|
self.assertEquals(len(response.context['messages']), 1)
|
||||||
|
for message in response.context['messages']:
|
||||||
|
self.assert_('请检查小组名称' in str(message))
|
||||||
|
|
||||||
|
|
||||||
|
def test_recommend_file_to_unparticipated_group(self):
|
||||||
|
response = self.client.post('/group/recommend/', {
|
||||||
|
'groups': 'unparticipated_group <nobody@none.com>,',
|
||||||
|
'repo_id': '0b21f61f-3015-4736-bd3f-9fd10cbff3c8',
|
||||||
|
'file_path': '/test.c',
|
||||||
|
'message': 'hello',
|
||||||
|
}, follow=True)
|
||||||
|
|
||||||
|
self.assertEquals(len(response.context['messages']), 1)
|
||||||
|
for message in response.context['messages']:
|
||||||
|
self.assert_('请检查是否参加了该小组' in str(message))
|
||||||
|
@@ -520,7 +520,7 @@ def group_recommend(request):
|
|||||||
group_creator = e.split(' ')[1]
|
group_creator = e.split(' ')[1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
messages.add_message(request, messages.ERROR,
|
messages.add_message(request, messages.ERROR,
|
||||||
u'推荐到 %s 失败,请检查是否参加了该小组。' % \
|
u'推荐到 %s 失败,请检查小组名称。' % \
|
||||||
group_name)
|
group_name)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user