allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [48/50] [abbrv] allura git commit: [#7919] fix tests
Date Fri, 08 Jan 2016 19:30:53 GMT
[#7919] fix tests


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6f154b43
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6f154b43
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6f154b43

Branch: refs/heads/master
Commit: 6f154b4361240027a31ebbc844d900f21ce568fd
Parents: a974d51
Author: Dave Brondsema <dave@brondsema.net>
Authored: Fri Dec 18 13:44:08 2015 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Fri Jan 8 14:06:19 2016 -0500

----------------------------------------------------------------------
 Allura/allura/model/project.py                  |   2 +-
 .../templates/discussion_widgets/add_forum.html |   2 +-
 .../discussionforums/admin_forums.html          |   2 +-
 .../tests/functional/test_forum.py              |  16 +--
 .../tests/functional/test_forum_admin.py        | 101 +++++++++++--------
 .../tests/functional/test_rest.py               |   4 +-
 .../tests/functional/test_controllers.py        |   2 +-
 .../forgetracker/templates/tracker/bin.html     |   3 +-
 .../templates/tracker_widgets/ticket_form.html  |   2 +-
 .../forgetracker/tests/functional/test_root.py  |  20 ++--
 10 files changed, 85 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6f154b43/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index eadd4d7..e26e405 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -625,7 +625,7 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
             if admin_options and s.tool_name and mount_point:
                 try:
                     entry['admin_options'] = ProjectAdminRestController().admin_options(mount_point)['options']
-                except exc.HTTPNotFound:
+                except exc.HTTPError:
                     log.debug('Could not get admin_options mount_point for tool: %s', s.url)
             if admin_options and not s.tool_name:
                 entry['admin_options'] = [dict(text='Subproject Admin', href=s.url + 'admin',
className=None)]

http://git-wip-us.apache.org/repos/asf/allura/blob/6f154b43/ForgeDiscussion/forgediscussion/templates/discussion_widgets/add_forum.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/discussion_widgets/add_forum.html b/ForgeDiscussion/forgediscussion/templates/discussion_widgets/add_forum.html
index 2bbfab4..5c633bf 100644
--- a/ForgeDiscussion/forgediscussion/templates/discussion_widgets/add_forum.html
+++ b/ForgeDiscussion/forgediscussion/templates/discussion_widgets/add_forum.html
@@ -20,7 +20,7 @@
 {% if value == c.add_forum -%}
     {% set value = {} -%}
 {% endif -%}
-<form method="{{method}}" action="{{action}}" enctype="multipart/form-data">
+<form method="{{method}}" action="{{action}}" enctype="multipart/form-data" id="add-forum">
   <input type="hidden" name="add_forum.app_id" value="{{app and app.config._id}}">
   <div id="add_forum_form" style="display:none">
     <label class="grid-5">Name:</label>

http://git-wip-us.apache.org/repos/asf/allura/blob/6f154b43/ForgeDiscussion/forgediscussion/templates/discussionforums/admin_forums.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/discussionforums/admin_forums.html
b/ForgeDiscussion/forgediscussion/templates/discussionforums/admin_forums.html
index aaa06cd..fc72f79 100644
--- a/ForgeDiscussion/forgediscussion/templates/discussionforums/admin_forums.html
+++ b/ForgeDiscussion/forgediscussion/templates/discussionforums/admin_forums.html
@@ -24,7 +24,7 @@
 {% block header %}{{app.config.options.mount_label}} Admin Forums{% endblock %}
 
 {% block content %}
-<form method="POST" action="update_forums" enctype="multipart/form-data">
+<form method="POST" action="update_forums" enctype="multipart/form-data" id="edit-forums">
   <table id="forums">
     <thead>
       <tr>

http://git-wip-us.apache.org/repos/asf/allura/blob/6f154b43/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index 7385357..5c6a180 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -45,7 +45,7 @@ class TestForumEmail(TestController):
         c.user = M.User.by_username('test-admin')
         self.app.get('/discussion/')
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[3]
+        form = r.forms['add-forum']
         form['add_forum.shortname'] = 'testforum'
         form['add_forum.name'] = 'Test Forum'
         form.submit()
@@ -131,13 +131,13 @@ class TestForumAsync(TestController):
         TestController.setUp(self)
         self.app.get('/discussion/')
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[3]
+        form = r.forms['add-forum']
         form['add_forum.shortname'] = 'testforum'
         form['add_forum.name'] = 'Test Forum'
         form.submit()
         r = self.app.get('/admin/discussion/forums')
         assert 'Test Forum' in r
-        form = r.forms[3]
+        form = r.forms['add-forum']
         form['add_forum.shortname'] = 'test1'
         form['add_forum.name'] = 'Test Forum 1'
         form.submit()
@@ -270,7 +270,7 @@ class TestForum(TestController):
         TestController.setUp(self)
         self.app.get('/discussion/')
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[3]
+        form = r.forms['add-forum']
         form['add_forum.shortname'] = 'testforum'
         form['add_forum.name'] = 'Test Forum'
         form.submit()
@@ -280,7 +280,7 @@ class TestForum(TestController):
         h.set_context('test', 'discussion', neighborhood='Projects')
         frm = FM.Forum.query.get(shortname='testforum')
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[3]
+        form = r.forms['add-forum']
         form['add_forum.shortname'] = 'childforum'
         form['add_forum.name'] = 'Child Forum'
         form['add_forum.parent'] = str(frm._id)
@@ -316,7 +316,7 @@ class TestForum(TestController):
 
     def test_unicode_name(self):
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[3]
+        form = r.forms['add-forum']
         form['add_forum.shortname'] = u'téstforum'.encode('utf-8')
         form['add_forum.name'] = u'Tést Forum'.encode('utf-8')
         form.submit()
@@ -325,7 +325,7 @@ class TestForum(TestController):
 
     def test_markdown_description(self):
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[3]
+        form = r.forms['add-forum']
         form['add_forum.shortname'] = 'tester'
         form['add_forum.name'] = 'Tester'
         form['add_forum.description'] = '<a href="http://cnn.com">This is CNN</a>'
@@ -825,7 +825,7 @@ class TestForum(TestController):
 
     def test_create_topic_unicode(self):
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[3]
+        form = r.forms['add-forum']
         form['add_forum.shortname'] = u'téstforum'.encode('utf-8')
         form['add_forum.name'] = u'Tést Forum'.encode('utf-8')
         form.submit()

http://git-wip-us.apache.org/repos/asf/allura/blob/6f154b43/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
index 983a8be..ed23054 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
@@ -38,9 +38,10 @@ class TestForumAdmin(TestController):
 
     def test_forum_CRUD(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'testforum'
-        r.forms[3]['add_forum.name'] = 'Test Forum'
-        r = r.forms[3].submit().follow()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'testforum'
+        form['add_forum.name'] = 'Test Forum'
+        r = form.submit().follow()
         assert 'Test Forum' in r
         h.set_context('test', 'Forum', neighborhood='Projects')
         frm = FM.Forum.query.get(shortname='testforum')
@@ -57,47 +58,54 @@ class TestForumAdmin(TestController):
 
     def test_forum_CRUD_hier(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'testforum'
-        r.forms[3]['add_forum.name'] = 'Test Forum'
-        r = r.forms[3].submit().follow()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'testforum'
+        form['add_forum.name'] = 'Test Forum'
+        r = form.submit().follow()
         r = self.app.get('/admin/discussion/forums')
         assert 'testforum' in r
         h.set_context('test', 'discussion', neighborhood='Projects')
         frm = FM.Forum.query.get(shortname='testforum')
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'childforum'
-        r.forms[3]['add_forum.name'] = 'Child Forum'
-        r.forms[3]['add_forum.parent'] = str(frm._id)
-        r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'childforum'
+        form['add_forum.name'] = 'Child Forum'
+        form['add_forum.parent'] = str(frm._id)
+        form.submit()
         r = self.app.get('/admin/discussion/forums')
         assert 'Child Forum' in r
 
     def test_bad_forum_names(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'Test.Forum'
-        r.forms[3]['add_forum.name'] = 'Test Forum'
-        r = r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'Test.Forum'
+        form['add_forum.name'] = 'Test Forum'
+        r = form.submit()
         assert 'error' in r
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'Test/Forum'
-        r.forms[3]['add_forum.name'] = 'Test Forum'
-        r = r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'Test/Forum'
+        form['add_forum.name'] = 'Test Forum'
+        r = form.submit()
         assert 'error' in r
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'Test Forum'
-        r.forms[3]['add_forum.name'] = 'Test Forum'
-        r = r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'Test Forum'
+        form['add_forum.name'] = 'Test Forum'
+        r = form.submit()
         assert 'error' in r
 
     def test_duplicate_forum_names(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'a'
-        r.forms[3]['add_forum.name'] = 'Forum A'
-        r = r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'a'
+        form['add_forum.name'] = 'Forum A'
+        r = form.submit()
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'b'
-        r.forms[3]['add_forum.name'] = 'Forum B'
-        r = r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'b'
+        form['add_forum.name'] = 'Forum B'
+        r = form.submit()
         h.set_context('test', 'Forum', neighborhood='Projects')
         forum_a = FM.Forum.query.get(shortname='a')
         self.app.post('/admin/discussion/update_forums',
@@ -109,22 +117,24 @@ class TestForumAdmin(TestController):
         # Now we have two forums: 'a', and 'b'.  'a' is deleted.
         # Let's try to create new forums with these names.
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'a'
-        r.forms[3]['add_forum.name'] = 'Forum A'
-        r = r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'a'
+        form['add_forum.name'] = 'Forum A'
+        r = form.submit()
         assert 'error' in r
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'b'
-        r.forms[3]['add_forum.name'] = 'Forum B'
-        r = r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'b'
+        form['add_forum.name'] = 'Forum B'
+        r = form.submit()
         assert 'error' in r
 
     def test_delete_undelete(self):
         r = self.app.get('/admin/discussion/forums')
-        r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'testforum'
-        r.forms[3]['add_forum.name'] = 'Test Forum'
-        r = r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'testforum'
+        form['add_forum.name'] = 'Test Forum'
+        r = form.submit()
         r = self.app.get('/admin/discussion/forums')
         soup_form = r.html.find('form', action='update_forums')
         assert len(soup_form.findAll('input', {'value': 'Delete'})) == 2
@@ -151,9 +161,10 @@ class TestForumAdmin(TestController):
     def test_members_only(self):
         # make a forum anyone can see
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'secret'
-        r.forms[3]['add_forum.name'] = 'Secret'
-        r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'secret'
+        form['add_forum.name'] = 'Secret'
+        form.submit()
         # forum can be viewed by member and non-member
         self.app.get('/discussion/secret')
         self.app.get('/discussion/secret',
@@ -210,9 +221,10 @@ class TestForumAdmin(TestController):
     def test_anon_posts(self):
         # make a forum anons can't post in
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'testforum'
-        r.forms[3]['add_forum.name'] = 'Test Forum'
-        r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'testforum'
+        form['add_forum.name'] = 'Test Forum'
+        form.submit()
         # try to post in the forum and get a 403
         r = self.app.get('/discussion/create_topic/')
         f = r.html.find(
@@ -255,9 +267,10 @@ class TestForumAdmin(TestController):
 
     def test_footer_monitoring_email(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[3]['add_forum.shortname'] = 'testforum'
-        r.forms[3]['add_forum.name'] = 'Test Forum'
-        r.forms[3].submit()
+        form = r.forms['add-forum']
+        form['add_forum.shortname'] = 'testforum'
+        form['add_forum.name'] = 'Test Forum'
+        form.submit()
         testforum = FM.Forum.query.get(shortname='testforum')
         self.app.post('/admin/discussion/update_forums',
                       params={'forum-0.anon_posts': 'on',

http://git-wip-us.apache.org/repos/asf/allura/blob/6f154b43/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py b/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
index bf677e9..e537ad6 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
@@ -42,7 +42,7 @@ class TestDiscussionApiBase(TestRestApiBase):
 
     def create_forum(self, shortname, name, description):
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[3]
+        form = r.forms['add-forum']
         form['add_forum.shortname'] = 'héllo'
         form['add_forum.name'] = 'Say Héllo'
         form['add_forum.description'] = 'Say héllo here'
@@ -235,7 +235,7 @@ class TestRootRestController(TestDiscussionApiBase):
 
     def test_private_forums(self):
         r = self.app.get('/p/test/admin/discussion/forums')
-        form = r.forms[2]
+        form = r.forms['edit-forums']
         if form['forum-0.shortname'].value == u'héllo':
             form['forum-0.members_only'] = True
         else:

http://git-wip-us.apache.org/repos/asf/allura/blob/6f154b43/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 5f68409..9cc9b79 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -617,7 +617,7 @@ class TestFork(_TestCase):
         assert 'git checkout master' in merge_instructions
         assert 'git fetch git://git.localhost/p/test2/code master' in merge_instructions
         assert 'git merge {}'.format(c_id) in merge_instructions
-        assert_in('less than 1 minute ago', r.html.findAll('p')[2].getText())
+        assert_in('less than 1 minute ago', r)
 
         merge_form = r.html.find('form', action='merge')
         assert merge_form

http://git-wip-us.apache.org/repos/asf/allura/blob/6f154b43/ForgeTracker/forgetracker/templates/tracker/bin.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/bin.html b/ForgeTracker/forgetracker/templates/tracker/bin.html
index 58dce0f..2f33ff3 100644
--- a/ForgeTracker/forgetracker/templates/tracker/bin.html
+++ b/ForgeTracker/forgetracker/templates/tracker/bin.html
@@ -30,7 +30,8 @@
 {% block header %}Saved Searches{% endblock %}
 
 {% block content %}
-  <form action="{{c.project.url()}}admin/{{app.config.options.mount_point}}/bins/update_bins"
method="post" class="update_bins">
+  <form action="{{c.project.url()}}admin/{{app.config.options.mount_point}}/bins/update_bins"
method="post"
+        class="update_bins" id="saved-search-form">
     <table>
       <thead>
         <tr>

http://git-wip-us.apache.org/repos/asf/allura/blob/6f154b43/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
index 67323a6..4c1c045 100644
--- a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
+++ b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
@@ -17,7 +17,7 @@
        under the License.
 -#}
 {% import 'allura:templates/jinja_master/lib.html' as lib with context %}
-<form method="POST" action="{{action}}" enctype="multipart/form-data">
+<form method="POST" action="{{action}}" enctype="multipart/form-data" id="ticket-form">
   {{widget.display_field_by_name('ticket_num')|safe}}
   {% if help_msg %}
     <div id="new-ticket-help-msg" class="grid-19 info">{{g.markdown.convert(help_msg)}}</div>

http://git-wip-us.apache.org/repos/asf/allura/blob/6f154b43/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 987ad03..2f1337a 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1410,7 +1410,7 @@ class TestFunctionalController(TrackerTestController):
             'sort': ''})
         assert err in r
         r = self.app.get('/admin/bugs/bins/')
-        edit_form = r.forms[2]
+        edit_form = r.forms['saved-search-form']
         edit_form['bins-2.summary'] = 'Original'
         edit_form['bins-2.terms'] = 'label:foo'
         r = edit_form.submit()
@@ -1434,7 +1434,7 @@ class TestFunctionalController(TrackerTestController):
 
     def test_edit_saved_search(self):
         r = self.app.get('/admin/bugs/bins/')
-        edit_form = r.forms[2]
+        edit_form = r.forms['saved-search-form']
         edit_form['bins-2.summary'] = 'Original'
         edit_form['bins-2.terms'] = 'aaa'
         edit_form.submit()
@@ -1442,7 +1442,7 @@ class TestFunctionalController(TrackerTestController):
         assert sidebar_contains(r, 'Original')
         assert not sidebar_contains(r, 'New')
         r = self.app.get('/admin/bugs/bins/')
-        edit_form = r.forms[2]
+        edit_form = r.forms['saved-search-form']
         edit_form['bins-2.summary'] = 'New'
         edit_form.submit()
         r = self.app.get('/bugs/')
@@ -2241,12 +2241,13 @@ class TestFunctionalController(TrackerTestController):
         M.Notification.query.remove()
         r = self.app.get('/p/test/bugs/2/')
         field_name = None  # comment text textarea name
-        for name, field in r.forms[2].fields.iteritems():
+        form = r.forms['ticket-form']
+        for name, field in form.fields.iteritems():
             if field[0].tag == 'textarea':
                 field_name = name
         assert field_name, "Can't find comment field"
-        r.forms[2].fields[field_name][0].value = 'Hi there'
-        r.forms[2].submit()
+        form.fields[field_name][0].value = 'Hi there'
+        form.submit()
 
         # notification for ticket 2 should reference [test:bugs], not
         # [test:dummy]
@@ -2298,12 +2299,13 @@ class TestFunctionalController(TrackerTestController):
         self.new_ticket(summary='test ticket')
         r = self.app.get('/p/test/bugs/1/')
         field_name = None  # comment text textarea name
-        for name, field in r.forms[2].fields.iteritems():
+        form = r.forms['ticket-form']
+        for name, field in form.fields.iteritems():
             if field[0].tag == 'textarea':
                 field_name = name
         assert field_name, "Can't find comment field"
-        r.forms[2].fields[field_name][0].value = 'I am comment'
-        r.forms[2].submit()
+        form.fields[field_name][0].value = 'I am comment'
+        form.submit()
         r = self.app.get('/p/test/bugs/1/')
         assert_in('I am comment', r)
 


Mime
View raw message