You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/10/28 14:45:21 UTC

[allura] branch master updated: Test fix: create regular comments instead of "meta" comments from ticket edit

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git


The following commit(s) were added to refs/heads/master by this push:
     new a095ac6  Test fix: create regular comments instead of "meta" comments from ticket edit
a095ac6 is described below

commit a095ac6e4ef40c5874ed5c271641ba4e3ffd0d44
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Wed Oct 28 10:45:12 2020 -0400

    Test fix: create regular comments instead of "meta" comments from ticket edit
---
 .../forgetracker/tests/functional/test_root.py     | 31 +++++++++++-----------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index bb6ff6f..31d2977 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -63,6 +63,12 @@ import six
 from six.moves import range
 
 
+def find(d, pred):
+    for n, v in d.items():
+        if pred(v):
+            return n, v
+
+
 class TrackerTestController(TestController):
     def setUp(self):
         super(TrackerTestController, self).setUp()
@@ -2746,11 +2752,11 @@ class TestEmailMonitoring(TrackerTestController):
     @patch('allura.model.discuss.Thread.is_spam')
     def test_notifications_moderators(self, is_spam, send_direct):
         is_spam.return_value = False
-        self.new_ticket(summary='test moderation', mount_point='/doc-bugs/')
-        self.app.post('/doc-bugs/1/update_ticket', {
-            'summary': 'test moderation',
-            'comment': 'test unmoderated post'
-        }, extra_environ=dict(username=str('*anonymous')))
+        ticket_view = self.new_ticket(summary='test moderation', mount_point='/doc-bugs/').follow()
+        _, form = find(ticket_view.forms, lambda f: f.action.endswith('/post'))
+        field, _ = find(form.fields, lambda f: f[0].tag == 'textarea')
+        form.set(field, 'this is an anonymous comment')
+        form.submit(extra_environ=dict(username=str('*anonymous')))
         send_direct.assert_called_with(
             str(M.User.query.get(username='test-admin')._id))
 
@@ -2760,11 +2766,11 @@ class TestEmailMonitoring(TrackerTestController):
     def test_notifications_off_spam(self, is_spam, send_direct):
         # like test_notifications_moderators but no notification because it goes straight to spam status
         is_spam.return_value = True
-        self.new_ticket(summary='test moderation', mount_point='/doc-bugs/')
-        self.app.post('/doc-bugs/1/update_ticket', {
-            'summary': 'test moderation',
-            'comment': 'test unmoderated post'
-        }, extra_environ=dict(username=str('*anonymous')))
+        ticket_view = self.new_ticket(summary='test moderation', mount_point='/doc-bugs/').follow()
+        _, form = find(ticket_view.forms, lambda f: f.action.endswith('/post'))
+        field, _ = find(form.fields, lambda f: f[0].tag == 'textarea')
+        form.set(field, 'this is an anonymous comment')
+        form.submit(extra_environ=dict(username=str('*anonymous')))
         assert not send_direct.called
 
     @patch('forgetracker.model.ticket.Notification.send_simple')
@@ -3289,11 +3295,6 @@ class TestNotificationEmailGrouping(TrackerTestController):
         assert_equal(email.kwargs.references, [])
 
     def test_comments(self):
-        def find(d, pred):
-            for n, v in d.items():
-                if pred(v):
-                    return (n, v)
-
         ticket_view = self.new_ticket(summary='Test Ticket').follow()
         ThreadLocalORMSession.flush_all()
         M.MonQTask.query.remove()