You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/08/20 18:57:49 UTC

[1/9] allura git commit: [#7970] expand HTTP codes for retry, and retry all types of socket errors (they subclass IOError)

Repository: allura
Updated Branches:
  refs/heads/hs/7963 497474035 -> da5deaf02 (forced update)


[#7970] expand HTTP codes for retry, and retry all types of socket errors (they subclass IOError)


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

Branch: refs/heads/hs/7963
Commit: 6aa2289f36d9548b3f398c8d6d6e16f322a6da53
Parents: 7c5a5de
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Aug 18 15:23:25 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Aug 18 15:23:25 2015 +0000

----------------------------------------------------------------------
 Allura/allura/lib/helpers.py          | 10 +++++-----
 Allura/allura/tests/test_helpers.py   | 11 +++++++++++
 ForgeImporters/forgeimporters/base.py |  2 +-
 3 files changed, 17 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6aa2289f/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 3a85c19..68330ba 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -1021,10 +1021,10 @@ class exceptionless(object):
         return inner
 
 
-def urlopen(url, retries=3, codes=(408,), timeout=None):
+def urlopen(url, retries=3, codes=(408, 500, 502, 503, 504), timeout=None):
     """Open url, optionally retrying if an error is encountered.
 
-    Socket timeouts will always be retried if retries > 0.
+    Socket and other IO errors will always be retried if retries > 0.
     HTTP errors are retried if the error code is passed in ``codes``.
 
     :param retries: Number of time to retry.
@@ -1035,9 +1035,9 @@ def urlopen(url, retries=3, codes=(408,), timeout=None):
     while True:
         try:
             return urllib2.urlopen(url, timeout=timeout)
-        except (urllib2.HTTPError, socket.timeout) as e:
-            if attempts < retries and (isinstance(e, socket.timeout) or
-                                       e.code in codes):
+        except IOError as e:
+            no_retry = isinstance(e, urllib2.HTTPError) and e.code not in codes
+            if attempts < retries and not no_retry:
                 attempts += 1
                 continue
             else:

http://git-wip-us.apache.org/repos/asf/allura/blob/6aa2289f/Allura/allura/tests/test_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 22d5b94..e9d13d2 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -449,6 +449,17 @@ class TestUrlOpen(TestCase):
         self.assertEqual(urlopen.call_count, 4)
 
     @patch('allura.lib.helpers.urllib2.urlopen')
+    def test_socket_reset(self, urlopen):
+        import socket
+        import errno
+
+        def side_effect(url, timeout=None):
+            raise socket.error(errno.ECONNRESET, 'Connection reset by peer')
+        urlopen.side_effect = side_effect
+        self.assertRaises(socket.error, h.urlopen, 'myurl')
+        self.assertEqual(urlopen.call_count, 4)
+
+    @patch('allura.lib.helpers.urllib2.urlopen')
     def test_handled_http_error(self, urlopen):
         from urllib2 import HTTPError
 

http://git-wip-us.apache.org/repos/asf/allura/blob/6aa2289f/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 8428142..8cc7e72 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -166,7 +166,7 @@ class ProjectExtractor(object):
             self.get_page(page_name, **kw)
 
     @staticmethod
-    def urlopen(url, retries=3, codes=(408,), **kw):
+    def urlopen(url, retries=3, codes=(408, 500, 502, 503, 504), **kw):
         req = urllib2.Request(url, **kw)
         req.add_header(
             'User-Agent', 'Allura Data Importer (https://allura.apache.org/)')


[8/9] allura git commit: [#7963] Add copy detection option for commit view

Posted by he...@apache.org.
[#7963] Add copy detection option for commit view


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

Branch: refs/heads/hs/7963
Commit: 55ab72b740d369e5dfcb79525a015a2e385ebd43
Parents: 1cb99fa
Author: Heith Seewald <hs...@hsmb.local>
Authored: Tue Aug 18 12:41:59 2015 -0400
Committer: Heith Seewald <hs...@hsmb.local>
Committed: Thu Aug 20 12:56:27 2015 -0400

----------------------------------------------------------------------
 Allura/development.ini              |  4 ++++
 ForgeGit/forgegit/model/git_repo.py | 26 +++++++++++++-------------
 2 files changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/55ab72b7/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 934ea67..af7b5f6 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -313,6 +313,10 @@ scm.import.retry_sleep_secs = 5
 ; Set to 0 to cache all references. Remove entirely to cache nothing.
 repo_refs_cache_threshold = .01
 
+; Enabling copy detection will display copies and renames in the commit views
+; at the expense of much longer response times.
+scm.commits.detect_copies = false
+
 ; One-click merge is enabled by default, but can be turned off on for each type of repo
 scm.merge.git.disabled = false
 scm.merge.hg.disabled = false

http://git-wip-us.apache.org/repos/asf/allura/blob/55ab72b7/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 8229b7e..14374a6 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -647,18 +647,18 @@ class GitImplementation(M.RepositoryImplementation):
 
     def paged_diffs(self, commit_id, start=0, end=None):
         result = {'added': [], 'removed': [], 'changed': [], 'copied': [], 'renamed': []}
-
-        cmd_output = self._git.git.diff_tree(
-            '--no-commit-id',
-            '-M',  # detect renames
-            '-C',  # detect copies
-            '--name-status',
-            '--no-abbrev',
-            '--root',
-            # show tree entry itself as well as subtrees (Commit.added_paths relies on this)
-            '-t',
-            '-z',  # don't escape filenames and use \x00 as fields delimiter
-            commit_id).split('\x00')[:-1]
+        cmd_args = ['--no-commit-id',
+                    '--name-status',
+                    '--no-abbrev',
+                    '--root',
+                    # show tree entry itself as well as subtrees (Commit.added_paths relies on this)
+                    '-t',
+                    '-z'  # don't escape filenames and use \x00 as fields delimiter
+                    ]
+        if asbool(tg.config.get('scm.commits.detect_copies', False)):
+            cmd_args += ['-M', '-C']
+
+        cmd_output = self._git.git.diff_tree(commit_id, *cmd_args).split('\x00')[:-1]  # don't escape filenames and use \x00 as fields delimiter
 
         ''' cmd_output will be like:
         [
@@ -668,7 +668,7 @@ class GitImplementation(M.RepositoryImplementation):
         'another filename',
         'M',
         'po',
-        'R100',
+        'R100',  # <-- These next three lines would only show up with 'detect_copies' enabled
         'po/sr.po',
         'po/sr_Latn.po',
         ]


[9/9] allura git commit: [#7963] Add tests for paged_diffs

Posted by he...@apache.org.
[#7963] Add tests for paged_diffs


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

Branch: refs/heads/hs/7963
Commit: da5deaf0264a22531ba67bfd7471a9a3ae764e6e
Parents: 55ab72b
Author: Heith Seewald <hs...@hsmb.local>
Authored: Tue Aug 18 15:29:19 2015 -0400
Committer: Heith Seewald <hs...@hsmb.local>
Committed: Thu Aug 20 12:57:07 2015 -0400

----------------------------------------------------------------------
 Allura/development.ini                          |   5 +-
 ForgeGit/forgegit/model/git_repo.py             |   5 +-
 .../2d/14b961ade8540113df9107be045e4ae4136ac5   | Bin 0 -> 161 bytes
 .../34/6c52c1dddc729e2c2711f809336401f0ff925e   |   2 +
 .../3c/b2bbcd7997f89060a14fe8b1a363f01883087f   |   2 +
 .../3c/bb55013cbb01ccb8d473e686e1a57d9c489243   | Bin 0 -> 161 bytes
 .../5a/3a87cf4d70ddae8f993254fb78e7974b812852   | Bin 0 -> 168 bytes
 .../86/2e77e5e7b157ade8c862a0dd6e73383e0f919f   | Bin 0 -> 139 bytes
 .../96/060b218ad9724646371e479775c7f664c141d1   | Bin 0 -> 134 bytes
 .../b7/07968ce4752b27410cc1fc71ced036314d6fbe   | Bin 0 -> 168 bytes
 .../c6/0e405e7150f65b19a3622dfe983ca37d28fe53   | Bin 0 -> 162 bytes
 .../d4/018e3cd5ff24921c0d31076e8bb44f54e77ce0   | Bin 0 -> 36 bytes
 .../data/weird-chars.git/refs/heads/master      |   2 +-
 .../tests/functional/test_controllers.py        |   1 +
 .../forgegit/tests/model/test_repository.py     |  59 +++++++++++++++++++
 15 files changed, 71 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index af7b5f6..42adb14 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -314,8 +314,9 @@ scm.import.retry_sleep_secs = 5
 repo_refs_cache_threshold = .01
 
 ; Enabling copy detection will display copies and renames in the commit views
-; at the expense of much longer response times.
-scm.commits.detect_copies = false
+; at the expense of much longer response times. SVN tracks copies by default.
+scm.git.commit.detect_copies = true
+scm.hg.commit.detect_copies = false
 
 ; One-click merge is enabled by default, but can be turned off on for each type of repo
 scm.merge.git.disabled = false

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 14374a6..0795bfd 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -655,7 +655,7 @@ class GitImplementation(M.RepositoryImplementation):
                     '-t',
                     '-z'  # don't escape filenames and use \x00 as fields delimiter
                     ]
-        if asbool(tg.config.get('scm.commits.detect_copies', False)):
+        if asbool(tg.config.get('scm.git.commit.detect_copies', False)):
             cmd_args += ['-M', '-C']
 
         cmd_output = self._git.git.diff_tree(commit_id, *cmd_args).split('\x00')[:-1]  # don't escape filenames and use \x00 as fields delimiter
@@ -687,7 +687,7 @@ class GitImplementation(M.RepositoryImplementation):
                 }))
                 x += 3
             else:
-                files.append((status, h.really_unicode(cmd_output[x+1])))
+                files.append((status, h.really_unicode(cmd_output[x + 1])))
                 x += 2
 
         for status, name in files[start:end]:
@@ -701,6 +701,7 @@ class GitImplementation(M.RepositoryImplementation):
             change_list.append(name)
 
         result['total'] = len(files)
+
         return result
 
     @contextmanager

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/data/weird-chars.git/objects/2d/14b961ade8540113df9107be045e4ae4136ac5
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/2d/14b961ade8540113df9107be045e4ae4136ac5 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/2d/14b961ade8540113df9107be045e4ae4136ac5
new file mode 100644
index 0000000..08a3877
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/2d/14b961ade8540113df9107be045e4ae4136ac5 differ

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/data/weird-chars.git/objects/34/6c52c1dddc729e2c2711f809336401f0ff925e
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/34/6c52c1dddc729e2c2711f809336401f0ff925e b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/34/6c52c1dddc729e2c2711f809336401f0ff925e
new file mode 100644
index 0000000..0d89789
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/34/6c52c1dddc729e2c2711f809336401f0ff925e
@@ -0,0 +1,2 @@
+x��Mj�0��}
+]�aF���e�=�X�92�'8*�~M{����o��un΋\���B=G�R9kH�ۄ<���7?L��{���2��j�s�)3�#H"D!����w���>1�꾀]����>�s��^tyw,!g9��+�
/��?f���\����>����M�
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/data/weird-chars.git/objects/3c/b2bbcd7997f89060a14fe8b1a363f01883087f
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/3c/b2bbcd7997f89060a14fe8b1a363f01883087f b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/3c/b2bbcd7997f89060a14fe8b1a363f01883087f
new file mode 100644
index 0000000..f72de10
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/3c/b2bbcd7997f89060a14fe8b1a363f01883087f
@@ -0,0 +1,2 @@
+x��M
+�0@a�9�\@��$���K��`�Lh���F��Eo��m>xe�籃u��WHA���\YAJD�P�AS�z�*��G*
+�ZYbK�Y�-S�]a��Fo����p��py�T�<l��ۜO�Rx��A��EKG�Z����'W�)�R������H�
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/data/weird-chars.git/objects/3c/bb55013cbb01ccb8d473e686e1a57d9c489243
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/3c/bb55013cbb01ccb8d473e686e1a57d9c489243 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/3c/bb55013cbb01ccb8d473e686e1a57d9c489243
new file mode 100644
index 0000000..ab1097a
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/3c/bb55013cbb01ccb8d473e686e1a57d9c489243 differ

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/data/weird-chars.git/objects/5a/3a87cf4d70ddae8f993254fb78e7974b812852
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/5a/3a87cf4d70ddae8f993254fb78e7974b812852 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/5a/3a87cf4d70ddae8f993254fb78e7974b812852
new file mode 100644
index 0000000..c5661ae
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/5a/3a87cf4d70ddae8f993254fb78e7974b812852 differ

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/data/weird-chars.git/objects/86/2e77e5e7b157ade8c862a0dd6e73383e0f919f
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/86/2e77e5e7b157ade8c862a0dd6e73383e0f919f b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/86/2e77e5e7b157ade8c862a0dd6e73383e0f919f
new file mode 100644
index 0000000..31448c7
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/86/2e77e5e7b157ade8c862a0dd6e73383e0f919f differ

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/data/weird-chars.git/objects/96/060b218ad9724646371e479775c7f664c141d1
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/96/060b218ad9724646371e479775c7f664c141d1 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/96/060b218ad9724646371e479775c7f664c141d1
new file mode 100644
index 0000000..319159e
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/96/060b218ad9724646371e479775c7f664c141d1 differ

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/data/weird-chars.git/objects/b7/07968ce4752b27410cc1fc71ced036314d6fbe
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/b7/07968ce4752b27410cc1fc71ced036314d6fbe b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/b7/07968ce4752b27410cc1fc71ced036314d6fbe
new file mode 100644
index 0000000..e760d93
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/b7/07968ce4752b27410cc1fc71ced036314d6fbe differ

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/data/weird-chars.git/objects/c6/0e405e7150f65b19a3622dfe983ca37d28fe53
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/c6/0e405e7150f65b19a3622dfe983ca37d28fe53 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/c6/0e405e7150f65b19a3622dfe983ca37d28fe53
new file mode 100644
index 0000000..33147cd
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/c6/0e405e7150f65b19a3622dfe983ca37d28fe53 differ

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/data/weird-chars.git/objects/d4/018e3cd5ff24921c0d31076e8bb44f54e77ce0
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/d4/018e3cd5ff24921c0d31076e8bb44f54e77ce0 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/d4/018e3cd5ff24921c0d31076e8bb44f54e77ce0
new file mode 100644
index 0000000..d84e12d
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/d4/018e3cd5ff24921c0d31076e8bb44f54e77ce0 differ

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/data/weird-chars.git/refs/heads/master
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/refs/heads/master b/ForgeGit/forgegit/tests/data/weird-chars.git/refs/heads/master
index ff3a92b..f76e179 100644
--- a/ForgeGit/forgegit/tests/data/weird-chars.git/refs/heads/master
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/refs/heads/master
@@ -1 +1 @@
-f3de6a0e7601cdde326054a1cc708afdc1dbe70b
+346c52c1dddc729e2c2711f809336401f0ff925e

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/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 dcc975f..164ea1e 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -851,6 +851,7 @@ class TestGitRename(TestController):
         resp = self.app.get('/src-git/ci/7c09182e61af959e4f1fb0e354bab49f14ef810d/tree/f.txt')
         assert "2 lines (1 with data), 10 Bytes" in resp
 
+    @patch.dict(h.tg.config, {'scm.git.commit.detect_copies': 'true'})
     def test_commit(self):
         # get the rename commit itself
         resp = self.app.get('/src-git/ci/b120505a61225e6c14bee3e5b5862db81628c35c/')

http://git-wip-us.apache.org/repos/asf/allura/blob/da5deaf0/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 25daa62..14d90bb 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -650,6 +650,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             tempfile.mkdtemp.return_value,
             ignore_errors=True)
 
+    @mock.patch.dict('allura.lib.app_globals.config',  {'scm.git.commit.detect_copies': 'false'})
     @td.with_tool('test', 'Git', 'src-weird', 'Git', type='git')
     def test_paged_diffs(self):
         # setup
@@ -722,6 +723,64 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             'total': 2,
         }
         assert_equals(diffs, expected)
+        diffs = repo.paged_diffs('346c52c1dddc729e2c2711f809336401f0ff925e')  # Test copy
+        expected = {
+            'added': [u'README.copy'],
+            'removed': [],
+            'copied': [],
+            'renamed': [],
+            'changed': [u'README'],
+            'total': 2,
+        }
+        assert_equals(diffs, expected)
+        diffs = repo.paged_diffs('3cb2bbcd7997f89060a14fe8b1a363f01883087f')  # Test rename
+        expected = {
+            'added': [u'README'],
+            'removed': [u'README-copy.md'],
+            'copied': [],
+            'renamed': [],
+            'changed': [],
+            'total': 2,
+        }
+        assert_equals(diffs, expected)
+
+    @mock.patch.dict('allura.lib.app_globals.config',  {'scm.git.commit.detect_copies': 'true'})
+    @td.with_tool('test', 'Git', 'src-weird', 'Git', type='git')
+    def test_paged_diffs_with_detect_copies(self):
+        # setup
+        h.set_context('test', 'src-weird', neighborhood='Projects')
+        repo_dir = pkg_resources.resource_filename(
+            'forgegit', 'tests/data')
+        repo = GM.Repository(
+            name='weird-chars.git',
+            fs_path=repo_dir,
+            url_path='/src-weird/',
+            tool='git',
+            status='creating')
+        repo.refresh()
+        ThreadLocalORMSession.flush_all()
+        ThreadLocalORMSession.close_all()
+
+        diffs = repo.paged_diffs('346c52c1dddc729e2c2711f809336401f0ff925e')  # Test copy
+        expected = {
+            'added': [],
+            'removed': [],
+            'copied': [{'new': u'README.copy', 'old': u'README', 'ratio': 1.0}],
+            'renamed': [],
+            'changed': [u'README'],
+            'total': 2,
+        }
+        assert_equals(diffs, expected)
+        diffs = repo.paged_diffs('3cb2bbcd7997f89060a14fe8b1a363f01883087f')  # Test rename
+        expected = {
+            'added': [],
+            'removed': [],
+            'copied': [],
+            'renamed': [{'new': u'README', 'old': u'README-copy.md', 'ratio': 1.0}],
+            'changed': [],
+            'total': 1,
+        }
+        assert_equals(diffs, expected)
 
     def test_merge_base(self):
         res = self.repo._impl.merge_base(self.merge_request)


[5/9] allura git commit: [#7923] ticket:827 Make wiki "Subscribe/Unsubscribe" from admin/tools menu (when left bar is disabled)

Posted by he...@apache.org.
[#7923] ticket:827 Make wiki "Subscribe/Unsubscribe" from admin/tools menu (when left bar is disabled)


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

Branch: refs/heads/hs/7963
Commit: c6df9664c73e413241ebaaeb7bf5391bcd4780a3
Parents: ac01413
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Aug 14 12:20:33 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Aug 18 22:18:00 2015 +0000

----------------------------------------------------------------------
 Allura/allura/app.py                                 |  7 +++++++
 Allura/allura/ext/admin/templates/project_tools.html |  3 +++
 ForgeWiki/forgewiki/wiki_main.py                     | 12 +++++++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/c6df9664/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 46770af..bd6f36b 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -657,6 +657,13 @@ class Application(object):
                     'data-mount-point': self.config.options.mount_point,
                 })
 
+    def admin_menu_widgets(self):
+        """Return widgets needed by the admin menu of this Application.
+
+        :return: a list of widgets
+        """
+        return []
+
     def handle_message(self, topic, message):
         """Handle incoming email msgs addressed to this tool.
         Default is a no-op.

http://git-wip-us.apache.org/repos/asf/allura/blob/c6df9664/Allura/allura/ext/admin/templates/project_tools.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_tools.html b/Allura/allura/ext/admin/templates/project_tools.html
index aa825f1..ec83e0a 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -94,6 +94,9 @@
                 </ul>
                 {# for ordering #}
                 <input type="hidden" class="mount_point" value="{{mount['ac'].options.mount_point}}"/>
+                {% for w in app.admin_menu_widgets() %}
+                  {{ w.display() }}
+                {% endfor %}
             </div>
         {% endif %}
         {% if 'sub' in mount and not mount['sub'].deleted %}

http://git-wip-us.apache.org/repos/asf/allura/blob/c6df9664/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 8747e87..f78a9b0 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -244,7 +244,7 @@ The wiki uses [Markdown](%s) syntax.
                     'Moderate', discussion.url() + 'moderate', ui_icon=g.icons['pencil'],
                     small=pending_mod_count))
         if not c.user.is_anonymous():
-            subscribed = M.Mailbox.subscribed()
+            subscribed = M.Mailbox.subscribed(app_config_id=self.config._id)
             subscribe_action = 'unsubscribe' if subscribed else 'subscribe'
             subscribe_title = '{}{}'.format(
                 subscribe_action.capitalize(),
@@ -276,6 +276,16 @@ The wiki uses [Markdown](%s) syntax.
         return links
 
     @h.exceptionless([], log)
+    def admin_menu_widgets(self):
+        widgets = super(ForgeWikiApp, self).admin_menu_widgets()
+        if not c.user.is_anonymous():
+            form = WikiSubscribeForm(
+                action=self.url + 'subscribe',
+                subscribed=M.Mailbox.subscribed(app_config_id=self.config._id))
+            widgets.append(form)
+        return widgets
+
+    @h.exceptionless([], log)
     def sidebar_menu(self):
         return self.create_common_wiki_menu(has_access(self, 'create'), c.app.url, 'add_wiki_page')
 


[3/9] allura git commit: [#7923] ticket:827 Show app's menu instead of the admin on admin pages

Posted by he...@apache.org.
[#7923] ticket:827 Show app's menu instead of the admin on admin pages


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

Branch: refs/heads/hs/7963
Commit: 82a08dd4c7d971c7238fbf0ef2612d64d44d00ae
Parents: 6aa2289
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Aug 14 10:44:55 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Aug 18 22:17:59 2015 +0000

----------------------------------------------------------------------
 Allura/allura/app.py                      |  9 +++++++--
 Allura/allura/webhooks.py                 |  3 ++-
 ForgeSVN/forgesvn/svn_main.py             |  4 ++--
 ForgeTracker/forgetracker/tracker_main.py | 11 ++++++++---
 4 files changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/82a08dd4/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index a0542c4..2d748c5 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -745,9 +745,14 @@ class Application(object):
                 'label': self.config.options.mount_label}
 
 
+class AdminControllerMixin(object):
+    """Provides common functionality admin controllers need"""
+    def _before(self, *remainder, **params):
+        # Display app's sidebar on admin page, instead of :class:`AdminApp`'s
+        c.app = self.app
 
 
-class DefaultAdminController(BaseController):
+class DefaultAdminController(BaseController, AdminControllerMixin):
 
     """Provides basic admin functionality for an :class:`Application`.
 
@@ -961,7 +966,7 @@ class DefaultAdminController(BaseController):
         redirect(request.referer)
 
 
-class WebhooksLookup(BaseController):
+class WebhooksLookup(BaseController, AdminControllerMixin):
 
     def __init__(self, app):
         super(WebhooksLookup, self).__init__()

http://git-wip-us.apache.org/repos/asf/allura/blob/82a08dd4/Allura/allura/webhooks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/webhooks.py b/Allura/allura/webhooks.py
index 1447802..d902e71 100644
--- a/Allura/allura/webhooks.py
+++ b/Allura/allura/webhooks.py
@@ -35,6 +35,7 @@ from webob import exc
 from pymongo.errors import DuplicateKeyError
 from paste.deploy.converters import asint, aslist
 
+from allura.app import AdminControllerMixin
 from allura.controllers import BaseController
 from allura.lib import helpers as h
 from allura.lib.decorators import require_post, task
@@ -97,7 +98,7 @@ class WebhookControllerMeta(type):
         return type.__call__(cls, sender, app, *args, **kw)
 
 
-class WebhookController(BaseController):
+class WebhookController(BaseController, AdminControllerMixin):
     __metaclass__ = WebhookControllerMeta
     create_form = WebhookCreateForm
     edit_form = WebhookEditForm

http://git-wip-us.apache.org/repos/asf/allura/blob/82a08dd4/ForgeSVN/forgesvn/svn_main.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index 5dda325..e87d106 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -33,7 +33,7 @@ from allura.controllers import BaseController
 from allura.controllers.repository import RepoRootController
 from allura.lib.decorators import require_post
 from allura.lib.repository import RepositoryApp, RepoAdminController
-from allura.app import SitemapEntry, ConfigOption
+from allura.app import SitemapEntry, ConfigOption, AdminControllerMixin
 from allura.lib import helpers as h
 from allura.lib import validators as v
 from allura import model as M
@@ -144,7 +144,7 @@ class SVNRepoAdminController(RepoAdminController):
             flash("Invalid external checkout URL: %s" % c.form_errors['external_checkout_url'], "error")
 
 
-class SVNImportController(BaseController):
+class SVNImportController(BaseController, AdminControllerMixin):
     import_form = widgets.ImportForm()
 
     def __init__(self, app):

http://git-wip-us.apache.org/repos/asf/allura/blob/82a08dd4/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 47a5d8b..ad63b74 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -46,7 +46,13 @@ from ming.utils import LazyProperty
 from allura import model as M
 from allura.lib import helpers as h
 from allura.lib import utils
-from allura.app import Application, SitemapEntry, DefaultAdminController, ConfigOption
+from allura.app import (
+    Application,
+    SitemapEntry,
+    DefaultAdminController,
+    AdminControllerMixin,
+    ConfigOption,
+)
 from allura.lib.search import search_artifact, SearchError
 from allura.lib.solr import escape_solr_arg
 from allura.lib.decorators import require_post
@@ -1104,7 +1110,7 @@ class RootController(BaseController, FeedController):
         }
 
 
-class BinController(BaseController):
+class BinController(BaseController, AdminControllerMixin):
 
     def __init__(self, summary=None, app=None):
         if summary is not None:
@@ -1640,7 +1646,6 @@ class TrackerAdminController(DefaultAdminController):
     @expose('jinja:forgetracker:templates/tracker/admin_fields.html')
     def fields(self, **kw):
         c.form = W.field_admin
-        c.app = self.app
         columns = dict((column, get_label(column))
                        for column in self.app.globals['show_in_search'].keys())
         return dict(app=self.app, globals=self.app.globals, columns=columns)


[2/9] allura git commit: [#7923] ticket:827 Make wiki "Create Page" and "Subscribe/Unsubscribe" work from sidebar on admin pages

Posted by he...@apache.org.
[#7923] ticket:827 Make wiki "Create Page" and "Subscribe/Unsubscribe" work from sidebar on admin pages


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

Branch: refs/heads/hs/7963
Commit: ac0141399af95ffe552dba5076a3495c842b590f
Parents: 82a08dd
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Aug 14 12:04:45 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Aug 18 22:17:59 2015 +0000

----------------------------------------------------------------------
 Allura/allura/app.py                            |  7 +++++
 .../templates/jinja_master/sidebar_menu.html    |  5 ++++
 .../templates/wiki/create_page_widget.html      | 25 ++++++++++++++++++
 ForgeWiki/forgewiki/templates/wiki/master.html  |  9 -------
 .../forgewiki/templates/wiki/page_view.html     | 19 --------------
 .../templates/wiki/wiki_subscribe_form.html     | 27 ++++++++++++++++++++
 ForgeWiki/forgewiki/widgets/wiki.py             | 16 ++++++++++++
 ForgeWiki/forgewiki/wiki_main.py                | 17 ++++++++----
 8 files changed, 92 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 2d748c5..46770af 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -581,6 +581,13 @@ class Application(object):
         """
         return ""
 
+    def sidebar_menu_widgets(self):
+        """Return widgets needed by the sidebar menu of this Application.
+
+        :return: a list of widgets
+        """
+        return []
+
     @LazyProperty
     def _webhooks(self):
         """A list of webhooks that can be triggered by this app.

http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/Allura/allura/templates/jinja_master/sidebar_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/sidebar_menu.html b/Allura/allura/templates/jinja_master/sidebar_menu.html
index df06d18..af70a48 100644
--- a/Allura/allura/templates/jinja_master/sidebar_menu.html
+++ b/Allura/allura/templates/jinja_master/sidebar_menu.html
@@ -89,6 +89,11 @@
       </ul>
       {% do ul_active.append(False) %}
     {% endif %}
+    {% if c.app and c.app.sidebar_menu_widgets() %}
+      {% for w in c.app.sidebar_menu_widgets() %}
+        {{ w.display() }}
+      {% endfor %}
+    {% endif %}
     {% if c.app and c.app.sidebar_menu_js() %}
       <script>
         {{c.app.sidebar_menu_js()|safe}}

http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/templates/wiki/create_page_widget.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/create_page_widget.html b/ForgeWiki/forgewiki/templates/wiki/create_page_widget.html
new file mode 100644
index 0000000..43ab051
--- /dev/null
+++ b/ForgeWiki/forgewiki/templates/wiki/create_page_widget.html
@@ -0,0 +1,25 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+<h1>Add a Wiki Page</h1>
+<form class="grid-10">
+    <label class="grid-2">Name</label>
+    <div class="grid-7"><input type="text" name="name"></div>
+    <label class="grid-2">&nbsp;</label>
+    <div class="grid-7"><input type="submit" value="Create page"></div>
+</form>

http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/templates/wiki/master.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/master.html b/ForgeWiki/forgewiki/templates/wiki/master.html
index 529c483..9f0ada1 100644
--- a/ForgeWiki/forgewiki/templates/wiki/master.html
+++ b/ForgeWiki/forgewiki/templates/wiki/master.html
@@ -34,15 +34,6 @@
 {% endblock %}
 
 {% block extra_js %}
-  {{c.create_page_lightbox.display(content='''
-    <h1>Add a Wiki Page</h1>
-    <form class="grid-10">
-        <label class="grid-2">Name</label>
-        <div class="grid-7"><input type="text" name="name"></div>
-        <label class="grid-2">&nbsp;</label>
-        <div class="grid-7"><input type="submit" value="Create page"></div>
-    </form>
-  ''')}}
     <script type="text/javascript">
         $('.post-link').click(function () {
             var version = $(this).data("dialog-id");

http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/templates/wiki/page_view.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_view.html b/ForgeWiki/forgewiki/templates/wiki/page_view.html
index 7a6135e..5762064 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_view.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_view.html
@@ -116,23 +116,4 @@
       {% endif %}
   {% endif %}
   {{c.confirmation.display(content='')}}
-  {% if not c.user.is_anonymous() %}
-    <form action="{{c.app.url}}subscribe" id="wiki_subscribe_form" style="display:none;" method="POST">
-      {{lib.csrf_token()}}
-      {% if c.subscribed %}
-        <input type="hidden" name="unsubscribe" value="1">
-      {% else %}
-        <input type="hidden" name="subscribe" value="1">
-      {% endif %}
-    </form>
-  {% endif %}
 {% endblock %}
-
-{% block wiki_extra_js %}
-  <script type="text/javascript">
-    $('a[href$="#toggle-subscribe"]').click(function() {
-      $('#wiki_subscribe_form').submit();
-      return false;
-    })
-  </script>
-{% endblock wiki_extra_js %}

http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/templates/wiki/wiki_subscribe_form.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/wiki_subscribe_form.html b/ForgeWiki/forgewiki/templates/wiki/wiki_subscribe_form.html
new file mode 100644
index 0000000..9ac328e
--- /dev/null
+++ b/ForgeWiki/forgewiki/templates/wiki/wiki_subscribe_form.html
@@ -0,0 +1,27 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+<form action="{{action}}" id="wiki_subscribe_form" class="hidden" method="POST">
+  {% if subscribed %}
+    <input type="hidden" name="unsubscribe" value="1">
+  {% else %}
+    <input type="hidden" name="subscribe" value="1">
+  {% endif %}
+  {{lib.csrf_token()}}
+</form>

http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/widgets/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/widgets/wiki.py b/ForgeWiki/forgewiki/widgets/wiki.py
index 7dc8b56..ffd2727 100644
--- a/ForgeWiki/forgewiki/widgets/wiki.py
+++ b/ForgeWiki/forgewiki/widgets/wiki.py
@@ -17,9 +17,11 @@
 
 import ew.jinja2_ew as ew
 from allura.lib.widgets import form_fields as ffw
+from allura.lib.widgets.forms import ForgeForm
 
 
 class CreatePageWidget(ffw.Lightbox):
+    content_template='forgewiki:templates/wiki/create_page_widget.html'
 
     def resources(self):
         for r in super(CreatePageWidget, self).resources():
@@ -31,3 +33,17 @@ class CreatePageWidget(ffw.Lightbox):
                 return false;
             });
         });''')
+
+
+class WikiSubscribeForm(ForgeForm):
+    template='jinja:forgewiki:templates/wiki/wiki_subscribe_form.html'
+    defaults = dict(ForgeForm.defaults, subscribed=False)
+
+    def resources(self):
+        for r in super(WikiSubscribeForm, self).resources():
+            yield r
+        yield ew.JSScript("""
+            $('a[href$="#toggle-subscribe"]').click(function() {
+                $('#wiki_subscribe_form').submit();
+                return false;
+            })""")

http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index a43be58..8747e87 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -51,7 +51,7 @@ from allura.lib.widgets.search import SearchResults, SearchHelp
 # Local imports
 from forgewiki import model as WM
 from forgewiki import version
-from forgewiki.widgets.wiki import CreatePageWidget
+from forgewiki.widgets.wiki import CreatePageWidget, WikiSubscribeForm
 
 log = logging.getLogger(__name__)
 
@@ -279,6 +279,17 @@ The wiki uses [Markdown](%s) syntax.
     def sidebar_menu(self):
         return self.create_common_wiki_menu(has_access(self, 'create'), c.app.url, 'add_wiki_page')
 
+    @h.exceptionless([], log)
+    def sidebar_menu_widgets(self):
+        widgets = super(ForgeWikiApp, self).sidebar_menu_widgets()
+        widgets.append(W.create_page_lightbox)
+        if not c.user.is_anonymous():
+            form = WikiSubscribeForm(
+                action=self.url + 'subscribe',
+                subscribed=M.Mailbox.subscribed())
+            widgets.append(form)
+        return widgets
+
     def install(self, project):
         'Set up any default permissions and roles here'
         self.config.options['project_name'] = project.name
@@ -336,7 +347,6 @@ The wiki uses [Markdown](%s) syntax.
 class RootController(BaseController, DispatchIndex, FeedController):
 
     def __init__(self):
-        c.create_page_lightbox = W.create_page_lightbox
         self._discuss = AppDiscussionController()
 
     def _check_security(self):
@@ -483,9 +493,6 @@ class PageController(BaseController, FeedController):
             app_config_id=c.app.config._id, title=self.title)
         if self.page is not None:
             self.attachment = WikiAttachmentsController(self.page)
-        c.create_page_lightbox = W.create_page_lightbox
-        if not c.user.is_anonymous():
-            c.subscribed = M.Mailbox.subscribed()
 
     def _check_security(self):
         if self.page:


[4/9] allura git commit: [#7923] fixes after rebasing with master (incl. [#7922] changes)

Posted by he...@apache.org.
[#7923] fixes after rebasing with master (incl. [#7922] changes)


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

Branch: refs/heads/hs/7963
Commit: 644a2988fa140b6865bd9a1ce2e088c40bebf922
Parents: da69a59
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Aug 18 20:04:36 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Aug 18 22:18:00 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_admin.py    |  1 +
 Allura/allura/tests/test_webhooks.py            |  4 +-
 .../tests/functional/test_forum.py              | 16 ++--
 .../tests/functional/test_forum_admin.py        | 97 ++++++++++----------
 .../tests/functional/test_rest.py               |  4 +-
 .../forgetracker/tests/functional/test_root.py  |  6 +-
 .../forgewiki/tests/functional/test_rest.py     |  2 +-
 7 files changed, 67 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/644a2988/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 28931c0..16590d7 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -324,6 +324,7 @@ class TestProjectAdmin(TestController):
                 tag for tag in r.html.findAll('input')
                 if (
                     tag.get('type') == 'hidden' and
+                    tag.get('name') and
                     tag['name'].startswith('card-') and
                     tag['name'].endswith('.id'))]
             assert len(cards) == len(app.permissions), cards

http://git-wip-us.apache.org/repos/asf/allura/blob/644a2988/Allura/allura/tests/test_webhooks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_webhooks.py b/Allura/allura/tests/test_webhooks.py
index d7fb75c..93da118 100644
--- a/Allura/allura/tests/test_webhooks.py
+++ b/Allura/allura/tests/test_webhooks.py
@@ -261,7 +261,7 @@ class TestWebhookController(TestController):
         assert_equal(M.Webhook.query.find().count(), 2)
         wh1 = M.Webhook.query.get(hook_url=data1['url'])
         r = self.app.get(self.url + '/repo-push/%s' % wh1._id)
-        form = r.forms[0]
+        form = r.forms[1]
         assert_equal(form['url'].value, data1['url'])
         assert_equal(form['secret'].value, data1['secret'])
         assert_equal(form['webhook'].value, unicode(wh1._id))
@@ -283,7 +283,7 @@ class TestWebhookController(TestController):
 
         # Duplicates
         r = self.app.get(self.url + '/repo-push/%s' % wh1._id)
-        form = r.forms[0]
+        form = r.forms[1]
         form['url'] = data2['url']
         r = form.submit()
         self.find_error(r, '_the_form',

http://git-wip-us.apache.org/repos/asf/allura/blob/644a2988/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 1efa395..33e1fb9 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[2]
+        form = r.forms[3]
         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[2]
+        form = r.forms[3]
         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[2]
+        form = r.forms[3]
         form['add_forum.shortname'] = 'test1'
         form['add_forum.name'] = 'Test Forum 1'
         form.submit()
@@ -273,7 +273,7 @@ class TestForum(TestController):
         TestController.setUp(self)
         self.app.get('/discussion/')
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[2]
+        form = r.forms[3]
         form['add_forum.shortname'] = 'testforum'
         form['add_forum.name'] = 'Test Forum'
         form.submit()
@@ -283,7 +283,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[2]
+        form = r.forms[3]
         form['add_forum.shortname'] = 'childforum'
         form['add_forum.name'] = 'Child Forum'
         form['add_forum.parent'] = str(frm._id)
@@ -320,7 +320,7 @@ class TestForum(TestController):
 
     def test_unicode_name(self):
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[2]
+        form = r.forms[3]
         form['add_forum.shortname'] = u'téstforum'.encode('utf-8')
         form['add_forum.name'] = u'Tést Forum'.encode('utf-8')
         form.submit()
@@ -329,7 +329,7 @@ class TestForum(TestController):
 
     def test_markdown_description(self):
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[2]
+        form = r.forms[3]
         form['add_forum.shortname'] = 'tester'
         form['add_forum.name'] = 'Tester'
         form['add_forum.description'] = '<a href="http://cnn.com">This is CNN</a>'
@@ -829,7 +829,7 @@ class TestForum(TestController):
 
     def test_create_topic_unicode(self):
         r = self.app.get('/admin/discussion/forums')
-        form = r.forms[2]
+        form = r.forms[3]
         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/644a2988/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 12a401e..4597017 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
@@ -38,9 +38,9 @@ class TestForumAdmin(TestController):
 
     def test_forum_CRUD(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[2]['add_forum.shortname'] = 'testforum'
-        r.forms[2]['add_forum.name'] = 'Test Forum'
-        r = r.forms[2].submit().follow()
+        r.forms[3]['add_forum.shortname'] = 'testforum'
+        r.forms[3]['add_forum.name'] = 'Test Forum'
+        r = r.forms[3].submit().follow()
         assert 'Test Forum' in r
         h.set_context('test', 'Forum', neighborhood='Projects')
         frm = FM.Forum.query.get(shortname='testforum')
@@ -57,47 +57,47 @@ class TestForumAdmin(TestController):
 
     def test_forum_CRUD_hier(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[2]['add_forum.shortname'] = 'testforum'
-        r.forms[2]['add_forum.name'] = 'Test Forum'
-        r = r.forms[2].submit().follow()
+        r.forms[3]['add_forum.shortname'] = 'testforum'
+        r.forms[3]['add_forum.name'] = 'Test Forum'
+        r = r.forms[3].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[2]['add_forum.shortname'] = 'childforum'
-        r.forms[2]['add_forum.name'] = 'Child Forum'
-        r.forms[2]['add_forum.parent'] = str(frm._id)
-        r.forms[2].submit()
+        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()
         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[2]['add_forum.shortname'] = 'Test.Forum'
-        r.forms[2]['add_forum.name'] = 'Test Forum'
-        r = r.forms[2].submit()
+        r.forms[3]['add_forum.shortname'] = 'Test.Forum'
+        r.forms[3]['add_forum.name'] = 'Test Forum'
+        r = r.forms[3].submit()
         assert 'error' in r
         r = self.app.get('/admin/discussion/forums')
-        r.forms[2]['add_forum.shortname'] = 'Test/Forum'
-        r.forms[2]['add_forum.name'] = 'Test Forum'
-        r = r.forms[2].submit()
+        r.forms[3]['add_forum.shortname'] = 'Test/Forum'
+        r.forms[3]['add_forum.name'] = 'Test Forum'
+        r = r.forms[3].submit()
         assert 'error' in r
         r = self.app.get('/admin/discussion/forums')
-        r.forms[2]['add_forum.shortname'] = 'Test Forum'
-        r.forms[2]['add_forum.name'] = 'Test Forum'
-        r = r.forms[2].submit()
+        r.forms[3]['add_forum.shortname'] = 'Test Forum'
+        r.forms[3]['add_forum.name'] = 'Test Forum'
+        r = r.forms[3].submit()
         assert 'error' in r
 
     def test_duplicate_forum_names(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[2]['add_forum.shortname'] = 'a'
-        r.forms[2]['add_forum.name'] = 'Forum A'
-        r = r.forms[2].submit()
+        r.forms[3]['add_forum.shortname'] = 'a'
+        r.forms[3]['add_forum.name'] = 'Forum A'
+        r = r.forms[3].submit()
         r = self.app.get('/admin/discussion/forums')
-        r.forms[2]['add_forum.shortname'] = 'b'
-        r.forms[2]['add_forum.name'] = 'Forum B'
-        r = r.forms[2].submit()
+        r.forms[3]['add_forum.shortname'] = 'b'
+        r.forms[3]['add_forum.name'] = 'Forum B'
+        r = r.forms[3].submit()
         h.set_context('test', 'Forum', neighborhood='Projects')
         forum_a = FM.Forum.query.get(shortname='a')
         self.app.post('/admin/discussion/update_forums',
@@ -109,14 +109,14 @@ 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[2]['add_forum.shortname'] = 'a'
-        r.forms[2]['add_forum.name'] = 'Forum A'
-        r = r.forms[2].submit()
+        r.forms[3]['add_forum.shortname'] = 'a'
+        r.forms[3]['add_forum.name'] = 'Forum A'
+        r = r.forms[3].submit()
         assert 'error' in r
         r = self.app.get('/admin/discussion/forums')
-        r.forms[2]['add_forum.shortname'] = 'b'
-        r.forms[2]['add_forum.name'] = 'Forum B'
-        r = r.forms[2].submit()
+        r.forms[3]['add_forum.shortname'] = 'b'
+        r.forms[3]['add_forum.name'] = 'Forum B'
+        r = r.forms[3].submit()
         assert 'error' in r
 
     def test_forum_icon(self):
@@ -128,7 +128,7 @@ class TestForumAdmin(TestController):
 
         h.set_context('test', 'discussion', neighborhood='Projects')
         r = self.app.get('/admin/discussion/forums')
-        app_id = r.forms[2]['add_forum.app_id'].value
+        app_id = r.forms[3]['add_forum.app_id'].value
         r = self.app.post('/admin/discussion/add_forum',
                           params={'add_forum.shortname': 'testforum',
                                   'add_forum.app_id': app_id,
@@ -144,11 +144,12 @@ class TestForumAdmin(TestController):
     def test_delete_undelete(self):
         r = self.app.get('/admin/discussion/forums')
         r = self.app.get('/admin/discussion/forums')
-        r.forms[2]['add_forum.shortname'] = 'testforum'
-        r.forms[2]['add_forum.name'] = 'Test Forum'
-        r = r.forms[2].submit()
+        r.forms[3]['add_forum.shortname'] = 'testforum'
+        r.forms[3]['add_forum.name'] = 'Test Forum'
+        r = r.forms[3].submit()
         r = self.app.get('/admin/discussion/forums')
-        assert len(r.html.findAll('input', {'value': 'Delete'})) == 2
+        soup_form = r.html.find('form', action='update_forums')
+        assert len(soup_form.findAll('input', {'value': 'Delete'})) == 2
         h.set_context('test', 'Forum', neighborhood='Projects')
         frm = FM.Forum.query.get(shortname='testforum')
 
@@ -158,21 +159,23 @@ class TestForumAdmin(TestController):
                                   'forum-0.name': 'New Test Forum',
                                   'forum-0.description': 'My desc'})
         r = self.app.get('/admin/discussion/forums')
-        assert len(r.html.findAll('input', {'value': 'Delete'})) == 1
+        soup_form = r.html.find('form', action='update_forums')
+        assert len(soup_form.findAll('input', {'value': 'Delete'})) == 1
         r = self.app.post('/admin/discussion/update_forums',
                           params={'forum-0.undelete': 'on',
                                   'forum-0.id': str(frm._id),
                                   'forum-0.name': 'New Test Forum',
                                   'forum-0.description': 'My desc'})
         r = self.app.get('/admin/discussion/forums')
-        assert len(r.html.findAll('input', {'value': 'Delete'})) == 2
+        soup_form = r.html.find('form', action='update_forums')
+        assert len(soup_form.findAll('input', {'value': 'Delete'})) == 2
 
     def test_members_only(self):
         # make a forum anyone can see
         r = self.app.get('/admin/discussion/forums')
-        r.forms[2]['add_forum.shortname'] = 'secret'
-        r.forms[2]['add_forum.name'] = 'Secret'
-        r.forms[2].submit()
+        r.forms[3]['add_forum.shortname'] = 'secret'
+        r.forms[3]['add_forum.name'] = 'Secret'
+        r.forms[3].submit()
         # forum can be viewed by member and non-member
         self.app.get('/discussion/secret')
         self.app.get('/discussion/secret',
@@ -230,9 +233,9 @@ 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[2]['add_forum.shortname'] = 'testforum'
-        r.forms[2]['add_forum.name'] = 'Test Forum'
-        r.forms[2].submit()
+        r.forms[3]['add_forum.shortname'] = 'testforum'
+        r.forms[3]['add_forum.name'] = 'Test Forum'
+        r.forms[3].submit()
         # try to post in the forum and get a 403
         r = self.app.get('/discussion/create_topic/')
         f = r.html.find(
@@ -277,9 +280,9 @@ class TestForumAdmin(TestController):
 
     def test_footer_monitoring_email(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[2]['add_forum.shortname'] = 'testforum'
-        r.forms[2]['add_forum.name'] = 'Test Forum'
-        r.forms[2].submit()
+        r.forms[3]['add_forum.shortname'] = 'testforum'
+        r.forms[3]['add_forum.name'] = 'Test Forum'
+        r.forms[3].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/644a2988/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 c8b69f2..c7624a4 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[2]
+        form = r.forms[3]
         form['add_forum.shortname'] = 'héllo'
         form['add_forum.name'] = 'Say Héllo'
         form['add_forum.description'] = 'Say héllo here'
@@ -236,7 +236,7 @@ class TestRootRestController(TestDiscussionApiBase):
 
     def test_private_forums(self):
         r = self.app.get('/p/test/admin/discussion/forums')
-        form = r.forms[1]
+        form = r.forms[2]
         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/644a2988/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 5f1339b..efcc59d 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1408,7 +1408,7 @@ class TestFunctionalController(TrackerTestController):
             'sort': ''})
         assert err in r
         r = self.app.get('/admin/bugs/bins/')
-        edit_form = r.forms[1]
+        edit_form = r.forms[2]
         edit_form['bins-2.summary'] = 'Original'
         edit_form['bins-2.terms'] = 'label:foo'
         r = edit_form.submit()
@@ -1432,7 +1432,7 @@ class TestFunctionalController(TrackerTestController):
 
     def test_edit_saved_search(self):
         r = self.app.get('/admin/bugs/bins/')
-        edit_form = r.forms[1]
+        edit_form = r.forms[2]
         edit_form['bins-2.summary'] = 'Original'
         edit_form['bins-2.terms'] = 'aaa'
         edit_form.submit()
@@ -1440,7 +1440,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[1]
+        edit_form = r.forms[2]
         edit_form['bins-2.summary'] = 'New'
         edit_form.submit()
         r = self.app.get('/bugs/')

http://git-wip-us.apache.org/repos/asf/allura/blob/644a2988/ForgeWiki/forgewiki/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_rest.py b/ForgeWiki/forgewiki/tests/functional/test_rest.py
index 9069705..3bc61bb 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_rest.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_rest.py
@@ -42,7 +42,7 @@ class TestWikiApi(TestRestApiBase):
 
     def test_get_page(self):
         r = self.app.get('/p/test/wiki/Home/')
-        discussion_url = r.html.findAll('form')[4]['action'][:-4]
+        discussion_url = r.html.findAll('form')[5]['action'][:-4]
         content = file(__file__).read()
         self.app.post('/wiki/Home/attach',
                       upload_files=[('file_info', 'test_root.py', content)])


[6/9] allura git commit: [#7923] ticket:827 Fix tests

Posted by he...@apache.org.
[#7923] ticket:827 Fix tests


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

Branch: refs/heads/hs/7963
Commit: da69a59e06b99edb1426b14f5c20fae78ac3d59a
Parents: c6df966
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Aug 14 14:10:06 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Aug 18 22:18:00 2015 +0000

----------------------------------------------------------------------
 .../tests/functional/test_forum.py              | 61 ++++++++------
 .../tests/functional/test_forum_admin.py        | 88 ++++++++++----------
 .../tests/functional/test_rest.py               | 11 +--
 .../forgetracker/tests/functional/test_root.py  |  6 +-
 .../forgewiki/tests/functional/test_rest.py     |  2 +-
 5 files changed, 88 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/da69a59e/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 23ec71f..1efa395 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -45,9 +45,10 @@ class TestForumEmail(TestController):
         c.user = M.User.by_username('test-admin')
         self.app.get('/discussion/')
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'testforum'
-        r.forms[1]['add_forum.name'] = 'Test Forum'
-        r.forms[1].submit()
+        form = r.forms[2]
+        form['add_forum.shortname'] = 'testforum'
+        form['add_forum.name'] = 'Test Forum'
+        form.submit()
         r = self.app.get('/admin/discussion/forums')
         assert 'testforum' in r
         self.email_address = c.user.email_addresses[0]
@@ -130,14 +131,16 @@ class TestForumAsync(TestController):
         TestController.setUp(self)
         self.app.get('/discussion/')
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'testforum'
-        r.forms[1]['add_forum.name'] = 'Test Forum'
-        r.forms[1].submit()
+        form = r.forms[2]
+        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
-        r.forms[1]['add_forum.shortname'] = 'test1'
-        r.forms[1]['add_forum.name'] = 'Test Forum 1'
-        r.forms[1].submit()
+        form = r.forms[2]
+        form['add_forum.shortname'] = 'test1'
+        form['add_forum.name'] = 'Test Forum 1'
+        form.submit()
         r = self.app.get('/admin/discussion/forums')
         assert 'Test Forum 1' in r
         h.set_context('test', 'discussion', neighborhood='Projects')
@@ -270,19 +273,21 @@ class TestForum(TestController):
         TestController.setUp(self)
         self.app.get('/discussion/')
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'testforum'
-        r.forms[1]['add_forum.name'] = 'Test Forum'
-        r.forms[1].submit()
+        form = r.forms[2]
+        form['add_forum.shortname'] = 'testforum'
+        form['add_forum.name'] = 'Test Forum'
+        form.submit()
         r = self.app.get('/admin/discussion/forums')
         frm = FM.Forum.query.get(shortname='testforum')
         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[1]['add_forum.shortname'] = 'childforum'
-        r.forms[1]['add_forum.name'] = 'Child Forum'
-        r.forms[1]['add_forum.parent'] = str(frm._id)
-        r.forms[1].submit()
+        form = r.forms[2]
+        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 'childforum' in r
 
@@ -315,19 +320,20 @@ class TestForum(TestController):
 
     def test_unicode_name(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = u'téstforum'.encode('utf-8')
-        r.forms[1]['add_forum.name'] = u'Tést Forum'.encode('utf-8')
-        r.forms[1].submit()
+        form = r.forms[2]
+        form['add_forum.shortname'] = u'téstforum'.encode('utf-8')
+        form['add_forum.name'] = u'Tést Forum'.encode('utf-8')
+        form.submit()
         r = self.app.get('/admin/discussion/forums')
         assert u'téstforum'.encode('utf-8') in r
 
     def test_markdown_description(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'tester'
-        r.forms[1]['add_forum.name'] = 'Tester'
-        r.forms[1][
-            'add_forum.description'] = '<a href="http://cnn.com">This is CNN</a>'
-        r.forms[1].submit()
+        form = r.forms[2]
+        form['add_forum.shortname'] = 'tester'
+        form['add_forum.name'] = 'Tester'
+        form['add_forum.description'] = '<a href="http://cnn.com">This is CNN</a>'
+        form.submit()
         r = self.app.get('/discussion/')
         assert_equal(len(r.html.findAll('a', rel='nofollow')), 1)
 
@@ -823,9 +829,10 @@ class TestForum(TestController):
 
     def test_create_topic_unicode(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = u'téstforum'.encode('utf-8')
-        r.forms[1]['add_forum.name'] = u'Tést Forum'.encode('utf-8')
-        r.forms[1].submit()
+        form = r.forms[2]
+        form['add_forum.shortname'] = u'téstforum'.encode('utf-8')
+        form['add_forum.name'] = u'Tést Forum'.encode('utf-8')
+        form.submit()
         r = self.app.get('/admin/discussion/forums')
         assert u'téstforum'.encode('utf-8') in r
         r = self.app.get(u'/p/test/discussion/create_topic/téstforum/'.encode('utf-8'))

http://git-wip-us.apache.org/repos/asf/allura/blob/da69a59e/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 0eb4168..12a401e 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
@@ -38,9 +38,9 @@ class TestForumAdmin(TestController):
 
     def test_forum_CRUD(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'testforum'
-        r.forms[1]['add_forum.name'] = 'Test Forum'
-        r = r.forms[1].submit().follow()
+        r.forms[2]['add_forum.shortname'] = 'testforum'
+        r.forms[2]['add_forum.name'] = 'Test Forum'
+        r = r.forms[2].submit().follow()
         assert 'Test Forum' in r
         h.set_context('test', 'Forum', neighborhood='Projects')
         frm = FM.Forum.query.get(shortname='testforum')
@@ -57,47 +57,47 @@ class TestForumAdmin(TestController):
 
     def test_forum_CRUD_hier(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'testforum'
-        r.forms[1]['add_forum.name'] = 'Test Forum'
-        r = r.forms[1].submit().follow()
+        r.forms[2]['add_forum.shortname'] = 'testforum'
+        r.forms[2]['add_forum.name'] = 'Test Forum'
+        r = r.forms[2].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[1]['add_forum.shortname'] = 'childforum'
-        r.forms[1]['add_forum.name'] = 'Child Forum'
-        r.forms[1]['add_forum.parent'] = str(frm._id)
-        r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'childforum'
+        r.forms[2]['add_forum.name'] = 'Child Forum'
+        r.forms[2]['add_forum.parent'] = str(frm._id)
+        r.forms[2].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[1]['add_forum.shortname'] = 'Test.Forum'
-        r.forms[1]['add_forum.name'] = 'Test Forum'
-        r = r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'Test.Forum'
+        r.forms[2]['add_forum.name'] = 'Test Forum'
+        r = r.forms[2].submit()
         assert 'error' in r
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'Test/Forum'
-        r.forms[1]['add_forum.name'] = 'Test Forum'
-        r = r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'Test/Forum'
+        r.forms[2]['add_forum.name'] = 'Test Forum'
+        r = r.forms[2].submit()
         assert 'error' in r
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'Test Forum'
-        r.forms[1]['add_forum.name'] = 'Test Forum'
-        r = r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'Test Forum'
+        r.forms[2]['add_forum.name'] = 'Test Forum'
+        r = r.forms[2].submit()
         assert 'error' in r
 
     def test_duplicate_forum_names(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'a'
-        r.forms[1]['add_forum.name'] = 'Forum A'
-        r = r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'a'
+        r.forms[2]['add_forum.name'] = 'Forum A'
+        r = r.forms[2].submit()
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'b'
-        r.forms[1]['add_forum.name'] = 'Forum B'
-        r = r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'b'
+        r.forms[2]['add_forum.name'] = 'Forum B'
+        r = r.forms[2].submit()
         h.set_context('test', 'Forum', neighborhood='Projects')
         forum_a = FM.Forum.query.get(shortname='a')
         self.app.post('/admin/discussion/update_forums',
@@ -109,14 +109,14 @@ 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[1]['add_forum.shortname'] = 'a'
-        r.forms[1]['add_forum.name'] = 'Forum A'
-        r = r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'a'
+        r.forms[2]['add_forum.name'] = 'Forum A'
+        r = r.forms[2].submit()
         assert 'error' in r
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'b'
-        r.forms[1]['add_forum.name'] = 'Forum B'
-        r = r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'b'
+        r.forms[2]['add_forum.name'] = 'Forum B'
+        r = r.forms[2].submit()
         assert 'error' in r
 
     def test_forum_icon(self):
@@ -128,7 +128,7 @@ class TestForumAdmin(TestController):
 
         h.set_context('test', 'discussion', neighborhood='Projects')
         r = self.app.get('/admin/discussion/forums')
-        app_id = r.forms[1]['add_forum.app_id'].value
+        app_id = r.forms[2]['add_forum.app_id'].value
         r = self.app.post('/admin/discussion/add_forum',
                           params={'add_forum.shortname': 'testforum',
                                   'add_forum.app_id': app_id,
@@ -144,9 +144,9 @@ class TestForumAdmin(TestController):
     def test_delete_undelete(self):
         r = self.app.get('/admin/discussion/forums')
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'testforum'
-        r.forms[1]['add_forum.name'] = 'Test Forum'
-        r = r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'testforum'
+        r.forms[2]['add_forum.name'] = 'Test Forum'
+        r = r.forms[2].submit()
         r = self.app.get('/admin/discussion/forums')
         assert len(r.html.findAll('input', {'value': 'Delete'})) == 2
         h.set_context('test', 'Forum', neighborhood='Projects')
@@ -170,9 +170,9 @@ class TestForumAdmin(TestController):
     def test_members_only(self):
         # make a forum anyone can see
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'secret'
-        r.forms[1]['add_forum.name'] = 'Secret'
-        r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'secret'
+        r.forms[2]['add_forum.name'] = 'Secret'
+        r.forms[2].submit()
         # forum can be viewed by member and non-member
         self.app.get('/discussion/secret')
         self.app.get('/discussion/secret',
@@ -230,9 +230,9 @@ 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[1]['add_forum.shortname'] = 'testforum'
-        r.forms[1]['add_forum.name'] = 'Test Forum'
-        r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'testforum'
+        r.forms[2]['add_forum.name'] = 'Test Forum'
+        r.forms[2].submit()
         # try to post in the forum and get a 403
         r = self.app.get('/discussion/create_topic/')
         f = r.html.find(
@@ -277,9 +277,9 @@ class TestForumAdmin(TestController):
 
     def test_footer_monitoring_email(self):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'testforum'
-        r.forms[1]['add_forum.name'] = 'Test Forum'
-        r.forms[1].submit()
+        r.forms[2]['add_forum.shortname'] = 'testforum'
+        r.forms[2]['add_forum.name'] = 'Test Forum'
+        r.forms[2].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/da69a59e/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 1f64eb5..c8b69f2 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
@@ -42,10 +42,11 @@ class TestDiscussionApiBase(TestRestApiBase):
 
     def create_forum(self, shortname, name, description):
         r = self.app.get('/admin/discussion/forums')
-        r.forms[1]['add_forum.shortname'] = 'héllo'
-        r.forms[1]['add_forum.name'] = 'Say Héllo'
-        r.forms[1]['add_forum.description'] = 'Say héllo here'
-        r.forms[1].submit()
+        form = r.forms[2]
+        form['add_forum.shortname'] = 'héllo'
+        form['add_forum.name'] = 'Say Héllo'
+        form['add_forum.description'] = 'Say héllo here'
+        form.submit()
 
     def create_topic(self, forum, subject, text):
         r = self.app.get('/discussion/create_topic/')
@@ -235,7 +236,7 @@ class TestRootRestController(TestDiscussionApiBase):
 
     def test_private_forums(self):
         r = self.app.get('/p/test/admin/discussion/forums')
-        form = r.forms[0]
+        form = r.forms[1]
         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/da69a59e/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 351b80b..5f1339b 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1408,7 +1408,7 @@ class TestFunctionalController(TrackerTestController):
             'sort': ''})
         assert err in r
         r = self.app.get('/admin/bugs/bins/')
-        edit_form = r.form
+        edit_form = r.forms[1]
         edit_form['bins-2.summary'] = 'Original'
         edit_form['bins-2.terms'] = 'label:foo'
         r = edit_form.submit()
@@ -1432,7 +1432,7 @@ class TestFunctionalController(TrackerTestController):
 
     def test_edit_saved_search(self):
         r = self.app.get('/admin/bugs/bins/')
-        edit_form = r.form
+        edit_form = r.forms[1]
         edit_form['bins-2.summary'] = 'Original'
         edit_form['bins-2.terms'] = 'aaa'
         edit_form.submit()
@@ -1440,7 +1440,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.form
+        edit_form = r.forms[1]
         edit_form['bins-2.summary'] = 'New'
         edit_form.submit()
         r = self.app.get('/bugs/')

http://git-wip-us.apache.org/repos/asf/allura/blob/da69a59e/ForgeWiki/forgewiki/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_rest.py b/ForgeWiki/forgewiki/tests/functional/test_rest.py
index a2b58ae..9069705 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_rest.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_rest.py
@@ -42,7 +42,7 @@ class TestWikiApi(TestRestApiBase):
 
     def test_get_page(self):
         r = self.app.get('/p/test/wiki/Home/')
-        discussion_url = r.html.findAll('form')[3]['action'][:-4]
+        discussion_url = r.html.findAll('form')[4]['action'][:-4]
         content = file(__file__).read()
         self.app.post('/wiki/Home/attach',
                       upload_files=[('file_info', 'test_root.py', content)])


[7/9] allura git commit: [#7970] fix a urlopen test that was missed

Posted by he...@apache.org.
[#7970] fix a urlopen test that was missed


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

Branch: refs/heads/hs/7963
Commit: 1cb99fabb11ef13993390bd59fa5a4e886e3c336
Parents: 644a298
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Aug 18 23:43:26 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Aug 18 23:43:26 2015 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/tests/test_base.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1cb99fab/ForgeImporters/forgeimporters/tests/test_base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/test_base.py b/ForgeImporters/forgeimporters/tests/test_base.py
index 22844a0..e617edd 100644
--- a/ForgeImporters/forgeimporters/tests/test_base.py
+++ b/ForgeImporters/forgeimporters/tests/test_base.py
@@ -41,7 +41,7 @@ class TestProjectExtractor(TestCase):
         req = Request.return_value
         req.add_header.assert_called_once_with(
             'User-Agent', 'Allura Data Importer (https://allura.apache.org/)')
-        urlopen.assert_called_once_with(req, retries=3, codes=(408,))
+        urlopen.assert_called_once_with(req, retries=3, codes=(408, 500, 502, 503, 504))
         self.assertEqual(r, urlopen.return_value)