You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by sh...@apache.org on 2019/08/25 06:26:45 UTC
[allura] branch ss/8323 updated: [#8323] Add a test case for user
notification task
This is an automated email from the ASF dual-hosted git repository.
shalithasuranga pushed a commit to branch ss/8323
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/ss/8323 by this push:
new 1d8155b [#8323] Add a test case for user notification task
1d8155b is described below
commit 1d8155b24717d9e68bc720d1e9303c59f9631812
Author: Shalitha Suranga <sh...@gmail.com>
AuthorDate: Sun Aug 25 11:56:25 2019 +0530
[#8323] Add a test case for user notification task
---
Allura/allura/tests/test_tasks.py | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 37a89f1..ec03dd9 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -33,7 +33,7 @@ from ming.orm import FieldProperty, Mapper
from ming.orm import ThreadLocalORMSession
from testfixtures import LogCapture
-from alluratest.controller import setup_basic_test, setup_global_objects
+from alluratest.controller import setup_basic_test, setup_global_objects, TestController
from allura import model as M
from allura.lib import helpers as h
@@ -494,6 +494,35 @@ I'm not here'''
message)
assert_equal(hm.call_count, 0)
+class TestUserNotificationTasks(TestController):
+ def setUp(self):
+ super(TestUserNotificationTasks, self).setUp()
+ self.setup_with_tools()
+
+ @td.with_wiki
+ def setup_with_tools(self):
+ pass
+
+ def test_send_usermentions_notification(self):
+ c.user = M.User.by_username('test-admin')
+ test_user = M.User.by_username('test-user-1')
+ test_user.set_pref('mention_notifications', True)
+ M.MonQTask.query.remove()
+ d = dict(title='foo', text='Hey @test-user-1!')
+ self.app.post('/wiki/foo/update', params=d)
+ M.MonQTask.run_ready()
+ # check email notification
+ tasks = M.MonQTask.query.find(
+ dict(task_name='allura.tasks.mail_tasks.sendsimplemail')).all()
+ assert_equal(len(tasks), 1)
+ assert_equal(tasks[0].kwargs['subject'],
+ '[test:wiki] Your name was mentioned')
+ assert_equal(tasks[0].kwargs['toaddr'], 'test-user-1@allura.local')
+ assert_equal(tasks[0].kwargs['reply_to'], g.noreply)
+ text = tasks[0].kwargs['text']
+ assert_in('Your name was mentioned at [foo]', text)
+ assert_in('by Test Admin', text)
+ assert_in('auth/subscriptions#notifications', text)
class TestNotificationTasks(unittest.TestCase):