Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CADA31074D for ; Tue, 29 Oct 2013 22:23:03 +0000 (UTC) Received: (qmail 86599 invoked by uid 500); 29 Oct 2013 22:23:03 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 86556 invoked by uid 500); 29 Oct 2013 22:23:03 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 86534 invoked by uid 99); 29 Oct 2013 22:23:03 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Oct 2013 22:23:03 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 742C488BDEB; Tue, 29 Oct 2013 22:23:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: johnsca@apache.org To: allura-commits@incubator.apache.org Date: Tue, 29 Oct 2013 22:23:13 -0000 Message-Id: <052781aba4214966b84b6f58484a27ef@git.apache.org> In-Reply-To: <852bdea321d14c1cbaf3241f7163674b@git.apache.org> References: <852bdea321d14c1cbaf3241f7163674b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [12/42] git commit: [#6328] Test cleanup [#6328] Test cleanup Signed-off-by: Cory Johns Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/5da3d1f3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5da3d1f3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5da3d1f3 Branch: refs/heads/cj/6692 Commit: 5da3d1f309f2240ad7bb522231bac215e4d4631e Parents: 0b5ceda Author: Cory Johns Authored: Thu Oct 24 20:15:50 2013 +0000 Committer: Cory Johns Committed: Thu Oct 24 20:15:50 2013 +0000 ---------------------------------------------------------------------- .../forgetracker/tests/functional/test_root.py | 38 +++++++------------- 1 file changed, 13 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5da3d1f3/ForgeTracker/forgetracker/tests/functional/test_root.py ---------------------------------------------------------------------- diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py index d524563..6edf25f 100644 --- a/ForgeTracker/forgetracker/tests/functional/test_root.py +++ b/ForgeTracker/forgetracker/tests/functional/test_root.py @@ -2697,23 +2697,19 @@ class TestNotificationEmailGrouping(TrackerTestController): assert_equal(email.kwargs.in_reply_to, None) 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() ThreadLocalORMSession.flush_all() - # Messy code to add a comment - for f in ticket_view.html.findAll('form'): - if f.get('action', '').endswith('/post'): - break - post_content = 'top-level comment' - params = dict() - inputs = f.findAll('input') - for field in inputs: - if field.has_key('name'): - params[field['name']] = field.has_key('value') and field['value'] or '' - params[f.find('textarea')['name']] = post_content - r = self.app.post(f['action'].encode('utf-8'), params=params, - headers={'Referer': '/bugs/1/'.encode("utf-8")}) + _, form = find(ticket_view.forms, lambda f: f.action.endswith('/post')) + field, _ = find(form.fields, lambda f: f[0].tag == 'textarea') + form.set(field, 'top-level comment') + r = form.submit() ThreadLocalORMSession.flush_all() M.MonQTask.run_ready() ThreadLocalORMSession.flush_all() @@ -2728,20 +2724,12 @@ class TestNotificationEmailGrouping(TrackerTestController): ThreadLocalORMSession.flush_all() M.MonQTask.query.remove() ThreadLocalORMSession.flush_all() - # Messy code to add reply r = self.app.get('/bugs/1/') - post_link = str(r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action']) - post_form = r.html.find('form', {'action': post_link + 'reply'}) - params = dict() - inputs = post_form.findAll('input') - for field in inputs: - if field.has_key('name'): - params[field['name']] = field.has_key('value') and field['value'] or '' + _, form = find(r.forms, lambda f: f.action.endswith('/reply')) + field, _ = find(form.fields, lambda f: f[0].tag == 'textarea') reply_text = 'Reply to top-level-comment' - params[post_form.find('textarea')['name']] = reply_text - r = self.app.post(post_link + 'reply', - params=params, - headers={'Referer':post_link.encode("utf-8")}) + form.set(field, reply_text) + r = form.submit() ThreadLocalORMSession.flush_all() M.MonQTask.run_ready() ThreadLocalORMSession.flush_all()