You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/06/04 22:02:57 UTC

[01/16] git commit: [#6007] Add helpful text and a list of projects to the default nbhd wikis

Updated Branches:
  refs/heads/cj/6218 d43696461 -> bf6db7ffb (forced update)


[#6007] Add helpful text and a list of projects to the default nbhd wikis


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

Branch: refs/heads/cj/6218
Commit: 9436995f27d71d48b6b185fc7c5162106c1f19de
Parents: 9d78948
Author: Dave Brondsema <db...@geek.net>
Authored: Mon Mar 25 13:53:08 2013 -0700
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Jun 4 14:40:51 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/index.py                       |    2 +-
 .../allura/tests/functional/test_neighborhood.py   |    2 +-
 Allura/allura/websetup/bootstrap.py                |   35 ++++++++++++++-
 3 files changed, 36 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9436995f/Allura/allura/model/index.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/index.py b/Allura/allura/model/index.py
index 2dedf4d..f7e3538 100644
--- a/Allura/allura/model/index.py
+++ b/Allura/allura/model/index.py
@@ -199,7 +199,7 @@ class Shortlink(object):
         p_shortname = None
         p_id = None
         p_nbhd = None
-        if hasattr(c, 'project'):
+        if getattr(c, 'project', None):
             p_shortname = getattr(c.project, 'shortname', None)
             p_id = getattr(c.project, '_id', None)
             p_nbhd = c.project.neighborhood_id

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9436995f/Allura/allura/tests/functional/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index c45d50e..07c4ccb 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -51,7 +51,7 @@ class TestNeighborhood(TestController):
         r = self.app.get('/adobe/wiki/')
         assert r.location.endswith('/adobe/wiki/Home/')
         r = r.follow()
-        assert 'Welcome' in str(r), str(r)
+        assert 'This is the "Adobe" neighborhood' in str(r), str(r)
         r = self.app.get('/adobe/admin/', extra_environ=dict(username='test-user'),
                          status=403)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9436995f/Allura/allura/websetup/bootstrap.py
----------------------------------------------------------------------
diff --git a/Allura/allura/websetup/bootstrap.py b/Allura/allura/websetup/bootstrap.py
index dd98580..5e8ab1e 100644
--- a/Allura/allura/websetup/bootstrap.py
+++ b/Allura/allura/websetup/bootstrap.py
@@ -23,7 +23,7 @@ import sys
 import logging
 import shutil
 from collections import defaultdict
-from datetime import datetime
+from textwrap import dedent
 
 import tg
 from pylons import tmpl_context as c, app_globals as g
@@ -40,6 +40,8 @@ from allura.websetup import schema
 from allura.command import EnsureIndexCommand
 from allura.command import CreateTroveCategoriesCommand
 
+from forgewiki import model as WM
+
 log = logging.getLogger(__name__)
 
 def cache_test_data():
@@ -121,6 +123,37 @@ def bootstrap(command, conf, vars):
     p_projects = project_reg.register_neighborhood_project(n_projects, [root], allow_register=True)
     p_users = project_reg.register_neighborhood_project(n_users, [root])
     p_adobe = project_reg.register_neighborhood_project(n_adobe, [root])
+
+    def set_nbhd_wiki_content(nbhd_proj, content):
+        wiki = nbhd_proj.app_instance('wiki')
+        page = WM.Page.query.get(app_config_id=wiki.config._id, title=wiki.root_page_name)
+        page.text = content
+
+    set_nbhd_wiki_content(p_projects, dedent('''
+        Welcome to the "Projects" neighborhood.  It is the default neighborhood in Allura.
+        You can edit this wiki page as you see fit.  Here's a few ways to get started:
+
+        [Register a new project](/p/add_project)
+
+        [Neighborhood administration](/p/admin)
+
+        [[projects show_total=yes]]
+        '''))
+    set_nbhd_wiki_content(p_users, dedent('''
+        This is the "Users" neighborhood.  All users automatically get a user-project created for them, using their username.
+
+        [Neighborhood administration](/u/admin)
+
+        [[projects show_total=yes]]
+        '''))
+    set_nbhd_wiki_content(p_adobe, dedent('''
+        This is the "Adobe" neighborhood.  It is just an example of having projects in a different neighborhood.
+
+        [Neighborhood administration](/adobe/admin)
+
+        [[projects show_total=yes]]
+        '''))
+
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
 


[16/16] git commit: [#6218] Bump ForgeHg version

Posted by tv...@apache.org.
[#6218] Bump ForgeHg version

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/6218
Commit: bf6db7ffb7c2c2f0276f577d969cb140d29d68c1
Parents: 6e76882
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Jun 4 20:02:36 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 4 20:02:36 2013 +0000

----------------------------------------------------------------------
 requirements-sf.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bf6db7ff/requirements-sf.txt
----------------------------------------------------------------------
diff --git a/requirements-sf.txt b/requirements-sf.txt
index 8792c7f..51067a0 100644
--- a/requirements-sf.txt
+++ b/requirements-sf.txt
@@ -4,7 +4,7 @@ akismet==0.2.0
 amqplib==0.6.1
 kombu==1.0.4
 coverage==3.5a1-20110413
-ForgeHg==0.1.11
+ForgeHg==0.1.12
 ForgePastebin==0.2.6
 mechanize==0.2.4
 mercurial==1.4.3


[06/16] git commit: [#6134] Keep roles comma-separated on _members page

Posted by tv...@apache.org.
[#6134] Keep roles comma-separated on _members page

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: f9d1c45432463aef87305c3fbb1e0ef4672cc2ec
Parents: 3fe4b3c
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue Jun 4 14:54:03 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Jun 4 14:54:03 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/project.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f9d1c454/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 9436e87..e42bd2f 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -349,7 +349,7 @@ class ProjectController(FeedController):
                     display_name=user.display_name,
                     username=user.username,
                     url=user.url(),
-                    roles=' '.join(sorted(roles)))
+                    roles=', '.join(sorted(roles)))
             if 'Admin' in roles:
                 admins.append(u)
             elif 'Developer' in roles:


[03/16] git commit: [#6007] Give full names to the default projects

Posted by tv...@apache.org.
[#6007] Give full names to the default projects


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

Branch: refs/heads/cj/6218
Commit: 439a66c536db8cf76923ee88a5c05876c679e973
Parents: 9436995
Author: Dave Brondsema <db...@geek.net>
Authored: Mon Mar 25 13:56:43 2013 -0700
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Jun 4 14:40:52 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_admin.py |    6 +++---
 Allura/allura/websetup/bootstrap.py          |    8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/439a66c5/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 79f595e..9535c36 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -45,7 +45,7 @@ def audits(*messages):
         import pdb; pdb.set_trace()
     for message in messages:
         assert M.AuditLog.query.find(dict(
-            message=re.compile(message))).count()
+            message=re.compile(message))).count(), 'Could not find "%s"' % message
 
 class TestProjectAdmin(TestController):
 
@@ -53,10 +53,10 @@ class TestProjectAdmin(TestController):
         self.app.get('/admin/')
         with audits(
             'change summary to Milkshakes are for crazy monkeys',
-            'change project name to Test Project',
+            'change project name to My Test Project',
             u'change short description to (\u00bf A Test Project \?){45}'):
             self.app.post('/admin/update', params=dict(
-                    name='Test Project',
+                    name='My Test Project',
                     shortname='test',
                     summary='Milkshakes are for crazy monkeys',
                     short_description=u'\u00bf A Test Project ?'.encode('utf-8') * 45,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/439a66c5/Allura/allura/websetup/bootstrap.py
----------------------------------------------------------------------
diff --git a/Allura/allura/websetup/bootstrap.py b/Allura/allura/websetup/bootstrap.py
index 5e8ab1e..f518463 100644
--- a/Allura/allura/websetup/bootstrap.py
+++ b/Allura/allura/websetup/bootstrap.py
@@ -194,12 +194,12 @@ def bootstrap(command, conf, vars):
         p_projects.add_user(u_admin, ['Admin'])
         p_users.add_user(u_admin, ['Admin'])
 
-        p_allura = n_projects.register_project('allura', u_admin)
+        p_allura = n_projects.register_project('allura', u_admin, 'Allura')
     u1 = make_user('Test User')
-    p_adobe1 = n_adobe.register_project('adobe-1', u_admin)
+    p_adobe1 = n_adobe.register_project('adobe-1', u_admin, 'Adobe project 1')
     p_adobe.add_user(u_admin, ['Admin'])
-    p0 = n_projects.register_project('test', u_admin)
-    p1 = n_projects.register_project('test2', u_admin)
+    p0 = n_projects.register_project('test', u_admin, 'Test Project')
+    p1 = n_projects.register_project('test2', u_admin, 'Test 2')
     p0._extra_tool_status = [ 'alpha', 'beta' ]
 
     sess = session(M.Neighborhood) # all the sessions are the same


[12/16] git commit: [#6218] Fixed failing test due to added tag

Posted by tv...@apache.org.
[#6218] Fixed failing test due to added tag

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 3889e9e25d5a977968d63d08f1828afc212d8a76
Parents: 401803b
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri May 24 14:35:10 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 4 18:59:58 2013 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/tests/model/test_repository.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3889e9e2/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 4afe27f..b3b920a 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -75,7 +75,7 @@ class TestNewGit(unittest.TestCase):
         assert self.rev.tree._id == self.rev.tree_id
         assert self.rev.summary == self.rev.message.splitlines()[0]
         assert self.rev.shorthand_id() == '[1e146e]'
-        assert self.rev.symbolic_ids == (['master'], ['foo']), self.rev.symbolic_ids
+        assert self.rev.symbolic_ids == (['master', 'zz'], ['foo'])
         assert self.rev.url() == (
             '/p/test/src-git/ci/'
             '1e146e67985dcd71c74de79613719bef7bddca4a/')


[09/16] git commit: [#6218] Added docstring to get_heads/branches/tags explaining why it's not a property

Posted by tv...@apache.org.
[#6218] Added docstring to get_heads/branches/tags explaining why it's not a property

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: d0105e079624f13fb17b0abcddba701eb1c3e1c0
Parents: 7437ce5
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Mon Jun 3 19:18:39 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 4 18:53:08 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d0105e07/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 78e16e2..dfb92f1 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -331,10 +331,31 @@ class Repository(Artifact, ActivityObject):
     def is_empty(self):
         return self._impl.is_empty()
     def get_heads(self):
+        """
+        Return list of heads for the repo.
+
+        It's get_heads() instead of a heads (lazy) property because it would
+        conflict with the now deprecated heads field.  Eventually, we should
+        try to remove the deprecated fields and clean this up.
+        """
         return self._impl.heads
     def get_branches(self):
+        """
+        Return list of branches for the repo.
+
+        It's get_branches() instead of a branches (lazy) property because it
+        would conflict with the now deprecated branches field.  Eventually, we
+        should try to remove the deprecated fields and clean this up.
+        """
         return self._impl.branches
     def get_tags(self):
+        """
+        Return list of tags for the repo.
+
+        It's get_tags() instead of a tags (lazy) property because it
+        would conflict with the now deprecated tags field.  Eventually, we
+        should try to remove the deprecated fields and clean this up.
+        """
         return self._impl.tags
 
     def _log(self, rev, skip, limit):


[11/16] git commit: [#6218] Get branches and tags directly from SCM

Posted by tv...@apache.org.
[#6218] Get branches and tags directly from SCM

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 401803b6ec74aeba417edb7dbff87b2dfa8d7282
Parents: d0105e0
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu May 23 23:35:00 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 4 18:57:59 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/401803b6/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index dfb92f1..10fac8c 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -218,6 +218,7 @@ class RepositoryImplementation(object):
     def tags(self):
         raise NotImplementedError, 'tags'
 
+
 class Repository(Artifact, ActivityObject):
     BATCH_SIZE=100
     class __mongometa__:


[13/16] git commit: [#6218] Deprecated and removed references to cached heads, branches and tags

Posted by tv...@apache.org.
[#6218] Deprecated and removed references to cached heads, branches and tags

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: d7c8fc15a6b3b256d5101bf314e92b4a7968c648
Parents: 3889e9e
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue May 28 19:26:58 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 4 19:01:54 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py                |    1 -
 ForgeGit/forgegit/tests/model/test_repository.py |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d7c8fc15/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 10fac8c..dfb92f1 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -218,7 +218,6 @@ class RepositoryImplementation(object):
     def tags(self):
         raise NotImplementedError, 'tags'
 
-
 class Repository(Artifact, ActivityObject):
     BATCH_SIZE=100
     class __mongometa__:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d7c8fc15/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 b3b920a..4afe27f 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -75,7 +75,7 @@ class TestNewGit(unittest.TestCase):
         assert self.rev.tree._id == self.rev.tree_id
         assert self.rev.summary == self.rev.message.splitlines()[0]
         assert self.rev.shorthand_id() == '[1e146e]'
-        assert self.rev.symbolic_ids == (['master', 'zz'], ['foo'])
+        assert self.rev.symbolic_ids == (['master'], ['foo']), self.rev.symbolic_ids
         assert self.rev.url() == (
             '/p/test/src-git/ci/'
             '1e146e67985dcd71c74de79613719bef7bddca4a/')


[08/16] git commit: [#6218] Fixed failing test due to added tag

Posted by tv...@apache.org.
[#6218] Fixed failing test due to added tag

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 28f8651e107f8e317d1a9f35ebc7c40094dd3840
Parents: 6a3753d
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri May 24 14:35:10 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 4 18:46:06 2013 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/tests/model/test_repository.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28f8651e/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 e0026b7..bae667c 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -76,7 +76,7 @@ class TestNewGit(unittest.TestCase):
         assert self.rev.tree._id == self.rev.tree_id
         assert self.rev.summary == self.rev.message.splitlines()[0]
         assert self.rev.shorthand_id() == '[1e146e]'
-        assert self.rev.symbolic_ids == (['master', 'zz'], [])
+        assert self.rev.symbolic_ids == (['master', 'zz'], ['foo'])
         assert self.rev.url() == (
             '/p/test/src-git/ci/'
             '1e146e67985dcd71c74de79613719bef7bddca4a/')


[10/16] git commit: [#6218] Deprecated and removed references to cached heads, branches and tags

Posted by tv...@apache.org.
[#6218] Deprecated and removed references to cached heads, branches and tags

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 7437ce52a9e2339873395470937d8fc6a5bfee00
Parents: 28f8651
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue May 28 19:26:58 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 4 18:53:08 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py            |   12 ++--
 Allura/allura/lib/repository.py                    |    2 +-
 Allura/allura/model/repository.py                  |   43 ++++++-------
 ForgeGit/forgegit/model/git_repo.py                |   51 +++++----------
 .../forgegit/tests/functional/test_controllers.py  |    2 +-
 ForgeGit/forgegit/tests/model/test_repository.py   |   19 ++----
 ForgeSVN/forgesvn/model/svn.py                     |   49 +++++++--------
 ForgeSVN/forgesvn/tests/model/test_repository.py   |    9 +--
 ForgeUserStats/forgeuserstats/tests/test_model.py  |    3 +-
 ForgeUserStats/forgeuserstats/tests/test_stats.py  |    3 +-
 10 files changed, 76 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7437ce52/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index e4832aa..084e17a 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -147,11 +147,11 @@ class RepoRootController(BaseController, FeedController):
     def mr_widget(self):
         source_branches = [
             b.name
-            for b in c.app.repo.branches + c.app.repo.repo_tags]
+            for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
         with c.app.repo.push_upstream_context():
             target_branches = [
                 b.name
-                for b in c.app.repo.branches + c.app.repo.repo_tags]
+                for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
         return SCMMergeRequestWidget(
             source_branches=source_branches,
             target_branches=target_branches)
@@ -162,7 +162,7 @@ class RepoRootController(BaseController, FeedController):
         security.require(security.has_access(c.app.repo, 'admin'))
         c.form = self.mr_widget
         if branch is None:
-            source_branch=c.app.repo.branches[0].name
+            source_branch=c.app.default_branch_name
         return dict(source_branch=source_branch)
 
     @expose()
@@ -205,7 +205,7 @@ class RepoRootController(BaseController, FeedController):
     @without_trailing_slash
     @expose('json:')
     def commit_browser_data(self):
-        head_ids = [ head.object_id for head in c.app.repo.heads ]
+        head_ids = [ head.object_id for head in c.app.repo.get_heads() ]
         commit_ids = list(c.app.repo.commitlog(head_ids))
         log.info('Grab %d commit objects by ID', len(commit_ids))
         commits_by_id = dict(
@@ -394,12 +394,12 @@ class BranchBrowser(BaseController):
     @expose('jinja:allura:templates/repo/tags.html')
     @with_trailing_slash
     def tags(self, **kw):
-        return dict(tags=c.app.repo.repo_tags)
+        return dict(tags=c.app.repo.get_tags())
 
     @expose('jinja:allura:templates/repo/tags.html')
     @with_trailing_slash
     def branches(self, **kw):
-        return dict(title='Branches', tags=c.app.repo.branches)
+        return dict(title='Branches', tags=c.app.repo.get_branches())
 
     @expose()
     @with_trailing_slash

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7437ce52/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index afd5557..5798b21 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -119,7 +119,7 @@ class RepositoryApp(Application):
                     (repo_path_parts[1], repo_path_parts[-1]),
                     self.repo.upstream_repo.name)
                 ]
-            if len(c.app.repo.branches) and has_access(c.app.repo, 'admin'):
+            if not c.app.repo.is_empty() and has_access(c.app.repo, 'admin'):
                 links.append(SitemapEntry('Request Merge', c.app.url + 'request_merge',
                              ui_icon=g.icons['merge'],
                              ))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7437ce52/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 1960d59..78e16e2 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -92,10 +92,6 @@ class RepositoryImplementation(object):
         commit'''
         raise NotImplementedError, 'commit_parents'
 
-    def refresh_heads(self): # pragma no cover
-        '''Sets repository metadata such as heads, tags, and branches'''
-        raise NotImplementedError, 'refresh_heads'
-
     def refresh_commit_info(self, oid, lazy=True): # pragma no cover
         '''Refresh the data in the commit with id oid'''
         raise NotImplementedError, 'refresh_commit_info'
@@ -173,12 +169,8 @@ class RepositoryImplementation(object):
         return '[%s]' % oid[:6]
 
     def symbolics_for_commit(self, commit):
-        '''Return symbolic branch and tag names for a commit.
-        Default generic implementation is provided, subclasses
-        may override if they have more efficient means.'''
-        branches = [b.name for b in self._repo.branches if b.object_id == commit._id]
-        tags = [t.name for t in self._repo.repo_tags if t.object_id == commit._id]
-        return branches, tags
+        '''Return symbolic branch and tag names for a commit.'''
+        raise NotImplementedError, 'symbolics_for_commit'
 
     def url_for_commit(self, commit, url_type='ci'):
         'return an URL, given either a commit or object id'
@@ -214,11 +206,17 @@ class RepositoryImplementation(object):
         os.chmod(magic_file, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
         self._setup_hooks(source_path)
 
-    def get_branches(self):
-        return self.repo.branches
+    @property
+    def heads(self):
+        raise NotImplementedError, 'heads'
 
-    def get_tags(self):
-        return self.repo.tags
+    @property
+    def branches(self):
+        raise NotImplementedError, 'branches'
+
+    @property
+    def tags(self):
+        raise NotImplementedError, 'tags'
 
 class Repository(Artifact, ActivityObject):
     BATCH_SIZE=100
@@ -237,9 +235,9 @@ class Repository(Artifact, ActivityObject):
     status=FieldProperty(str)
     email_address=''
     additional_viewable_extensions=FieldProperty(str)
-    heads = FieldProperty([dict(name=str,object_id=str, count=int)])
-    branches = FieldProperty([dict(name=str,object_id=str, count=int)])
-    repo_tags = FieldProperty([dict(name=str,object_id=str, count=int)])
+    heads = FieldProperty(S.Deprecated)
+    branches = FieldProperty(S.Deprecated)
+    repo_tags = FieldProperty(S.Deprecated)
     upstream_repo = FieldProperty(dict(name=str,url=str))
 
     def __init__(self, **kw):
@@ -332,10 +330,12 @@ class Repository(Artifact, ActivityObject):
         return self._impl.last_commit_ids(commit, paths)
     def is_empty(self):
         return self._impl.is_empty()
+    def get_heads(self):
+        return self._impl.heads
     def get_branches(self):
-        return self._impl.get_branches()
+        return self._impl.branches
     def get_tags(self):
-        return self._impl.get_tags()
+        return self._impl.tags
 
     def _log(self, rev, skip, limit):
         head = self.commit(rev)
@@ -531,13 +531,8 @@ class Repository(Artifact, ActivityObject):
             log.info('... %r analyzing', self)
             self.status = 'analyzing'
             session(self).flush(self)
-            self._impl.refresh_heads()
             if asbool(tg.config.get('scm.new_refresh')):
                 refresh_repo(self, all_commits, notify, new_clone)
-            for head in self.heads + self.branches + self.repo_tags:
-                ci = self.commit(head.object_id)
-                if ci is not None:
-                    head.count = self.count_revisions(ci)
         finally:
             log.info('... %s ready', self)
             self.status = 'ready'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7437ce52/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 5683296..27b52d9 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -148,13 +148,6 @@ class GitImplementation(M.RepositoryImplementation):
 
     def commit(self, rev):
         '''Return a Commit object.  rev can be _id or a branch/tag name'''
-        # See if the rev is a named ref that we have cached, and use the sha1
-        # from the cache. This ensures that we don't return a sha1 that we
-        # don't have indexed into mongo yet.
-        for ref in self._repo.heads + self._repo.branches + self._repo.repo_tags:
-            if ref.name == rev:
-                rev = ref.object_id
-                break
         cache = getattr(c, 'model_cache', '') or M.repo.ModelCache()
         result = cache.get(M.repo.Commit, dict(_id=rev))
         if result is None:
@@ -170,8 +163,8 @@ class GitImplementation(M.RepositoryImplementation):
                 except:
                     pass
                 log.exception('Error with rev_parse(%s)%s' % (str(rev) + '^0', url))
-        if result is None: return None
-        result.set_context(self._repo)
+        if result:
+            result.set_context(self._repo)
         return result
 
     def all_commit_ids(self):
@@ -189,7 +182,7 @@ class GitImplementation(M.RepositoryImplementation):
     def new_commits(self, all_commits=False):
         graph = {}
 
-        to_visit = [ self._git.commit(rev=hd.object_id) for hd in self._repo.heads ]
+        to_visit = [ self._git.commit(rev=hd.object_id) for hd in self.heads ]
         while to_visit:
             obj = to_visit.pop()
             if obj.hexsha in graph: continue
@@ -202,21 +195,6 @@ class GitImplementation(M.RepositoryImplementation):
             to_visit += obj.parents
         return list(topological_sort(graph))
 
-    def refresh_heads(self):
-        self._repo.heads = [
-            Object(name=head.name, object_id=head.commit.hexsha)
-            for head in self._git.heads
-            if head.is_valid() ]
-        self._repo.branches = [
-            Object(name=head.name, object_id=head.commit.hexsha)
-            for head in self._git.branches
-            if head.is_valid() ]
-        self._repo.repo_tags = [
-            Object(name=tag.name, object_id=tag.commit.hexsha)
-            for tag in self._git.tags
-            if tag.is_valid() ]
-        session(self._repo).flush()
-
     def refresh_commit_info(self, oid, seen, lazy=True):
         from allura.model.repo import CommitDoc
         ci_doc = CommitDoc.m.get(_id=oid)
@@ -331,13 +309,12 @@ class GitImplementation(M.RepositoryImplementation):
         return git.Object.new_from_sha(self._git, binsha)
 
     def symbolics_for_commit(self, commit):
-        branch_heads, tags = super(self.__class__, self).symbolics_for_commit(commit)
         try:
-            containing_branches = self._git.git.branch(contains=commit._id)
+            branches = [b.name for b in self.branches if b.object_id == commit._id]
+            tags = [t.name for t in self.tags if t.object_id == commit._id]
+            return branches, tags
         except git.GitCommandError:
-            return [], tags
-        containing_branches = [br.strip(' *') for br in containing_branches.split('\n')]
-        return containing_branches, tags
+            return [], []
 
     def compute_tree_new(self, commit, tree_path='/'):
         ci = self._git.rev_parse(commit._id)
@@ -361,11 +338,17 @@ class GitImplementation(M.RepositoryImplementation):
     def is_empty(self):
         return not self._git or len(self._git.heads) == 0
 
-    def get_branches(self):
-        return [Object(name=b.name,object_id=b.commit.hexsha) for b in self._git.heads]
+    @LazyProperty
+    def heads(self):
+        return [Object(name=b.name, object_id=b.commit.hexsha) for b in self._git.heads if b.is_valid()]
+
+    @LazyProperty
+    def branches(self):
+        return [Object(name=b.name, object_id=b.commit.hexsha) for b in self._git.branches if b.is_valid()]
 
-    def get_tags(self):
-        return [Object(name=t.name, object_id=t.commit.hexsha) for t in self._git.tags]
+    @LazyProperty
+    def tags(self):
+        return [Object(name=t.name, object_id=t.commit.hexsha) for t in self._git.tags if t.is_valid()]
 
 
 class _OpenedGitBlob(object):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7437ce52/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 204f729..32ffb69 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -467,7 +467,7 @@ class TestFork(_TestCase):
         assert 'Improve documentation' in r, r.showbrowser()
         revs = r.html.findAll('tr', attrs={'class': 'rev'})
         links = revs[0].findAll('a')
-        c_id = self.forked_repo.heads[0]['object_id']
+        c_id = self.forked_repo.get_heads()[0]['object_id']
         assert_equal(links[0].get('href'), '/p/test2/code/ci/%s/' % c_id)
         assert_equal(links[0].getText(), '[%s]' % c_id[:6])
         assert_equal(links[1].get('href'), '/p/test2/code/ci/%s/tree' % c_id)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7437ce52/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 bae667c..4afe27f 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -63,8 +63,7 @@ class TestNewGit(unittest.TestCase):
         #     tool = 'git',
         #     status = 'creating')
         self.repo.refresh()
-        self.rev = M.repo.Commit.query.get(_id=self.repo.heads[0]['object_id'])
-        self.rev.repo = self.repo
+        self.rev = self.repo.commit('master')
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
 
@@ -76,7 +75,7 @@ class TestNewGit(unittest.TestCase):
         assert self.rev.tree._id == self.rev.tree_id
         assert self.rev.summary == self.rev.message.splitlines()[0]
         assert self.rev.shorthand_id() == '[1e146e]'
-        assert self.rev.symbolic_ids == (['master', 'zz'], ['foo'])
+        assert self.rev.symbolic_ids == (['master'], ['foo']), self.rev.symbolic_ids
         assert self.rev.url() == (
             '/p/test/src-git/ci/'
             '1e146e67985dcd71c74de79613719bef7bddca4a/')
@@ -234,12 +233,6 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         entry = self.repo.commit('HEAD')
         assert str(entry.authored.name) == 'Rick Copeland', entry.authored
         assert entry.message
-        # Test that sha1s for named refs are looked up in cache first, instead
-        # of from disk.
-        with mock.patch('forgegit.model.git_repo.M.repo.Commit.query') as q:
-            self.repo.heads.append(Object(name='HEAD', object_id='deadbeef'))
-            self.repo.commit('HEAD')
-            q.get.assert_called_with(_id='deadbeef')
         # test the auto-gen tree fall-through
         orig_tree = M.repo.Tree.query.get(_id=entry.tree_id)
         assert orig_tree
@@ -340,22 +333,22 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             assert repo2.is_empty()
 
 class TestGitImplementation(unittest.TestCase):
-    def test_get_branches(self):
+    def test_branches(self):
         repo_dir = pkg_resources.resource_filename(
             'forgegit', 'tests/data/testgit.git')
         repo = mock.Mock(full_fs_path=repo_dir)
         impl = GM.git_repo.GitImplementation(repo)
-        self.assertEqual(impl.get_branches(), [
+        self.assertEqual(impl.branches, [
                 Object(name='master', object_id='1e146e67985dcd71c74de79613719bef7bddca4a'),
                 Object(name='zz', object_id='5c47243c8e424136fd5cdd18cd94d34c66d1955c')
             ])
 
-    def test_get_tags(self):
+    def test_tags(self):
         repo_dir = pkg_resources.resource_filename(
             'forgegit', 'tests/data/testgit.git')
         repo = mock.Mock(full_fs_path=repo_dir)
         impl = GM.git_repo.GitImplementation(repo)
-        self.assertEqual(impl.get_tags(), [
+        self.assertEqual(impl.tags, [
                 Object(name='foo', object_id='1e146e67985dcd71c74de79613719bef7bddca4a'),
             ])
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7437ce52/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index f017f0b..23c1887 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -98,8 +98,7 @@ class Repository(M.Repository):
 
     def latest(self, branch=None):
         if self._impl is None: return None
-        if not self.heads: return None
-        return self._impl.commit(self.heads[0].object_id)
+        return self._impl.commit('HEAD')
 
     def tarball_filename(self, revision, path=None):
         fn = super(Repository, self).tarball_filename(revision, path)
@@ -299,42 +298,27 @@ class SVNImplementation(M.RepositoryImplementation):
             c.app.config.options['checkout_url'] = ""
         self._setup_special_files(source_url)
 
-    def refresh_heads(self):
-        info = self._svn.info2(
-            self._url,
-            revision=pysvn.Revision(pysvn.opt_revision_kind.head),
-            recurse=False)[0][1]
-        oid = self._oid(info.rev.number)
-        self._repo.heads = [ Object(name=None, object_id=oid) ]
-        # Branches and tags aren't really supported in subversion
-        self._repo.branches = []
-        self._repo.repo_tags = []
-        session(self._repo).flush(self._repo)
-
     def commit(self, rev):
         if rev in ('HEAD', None):
-            if not self._repo.heads: return None
-            oid = self._repo.heads[0].object_id
+            oid = self._oid(self.head)
         elif isinstance(rev, int) or rev.isdigit():
             oid = self._oid(rev)
         else:
             oid = rev
         result = M.repo.Commit.query.get(_id=oid)
-        if result is None: return None
-        result.set_context(self._repo)
+        if result:
+            result.set_context(self._repo)
         return result
 
     def all_commit_ids(self):
         """Return a list of commit ids, starting with the head (most recent
         commit) and ending with the root (first commit).
         """
-        if not self._repo.heads:
-            return []
-        head_revno = self._revno(self._repo.heads[0].object_id)
+        head_revno = self.head
         return map(self._oid, range(head_revno, 0, -1))
 
     def new_commits(self, all_commits=False):
-        head_revno = self._revno(self._repo.heads[0].object_id)
+        head_revno = self.head
         oids = [ self._oid(revno) for revno in range(1, head_revno+1) ]
         if all_commits:
             return oids
@@ -689,19 +673,32 @@ class SVNImplementation(M.RepositoryImplementation):
                 os.remove(tmpfilename)
 
     def is_empty(self):
+        return self.head == 0
+
+    def symbolics_for_commit(self, commit):
+        return [], []
+
+    @LazyProperty
+    def head(self):
         try:
-            return self._svn.revpropget('revision', url=self._url)[0].number == 0
+            return int(self._svn.revpropget('revision', url=self._url)[0].number)
         except pysvn.ClientError as e:
             if str(e).startswith("Unable to connect") or \
                     str(e).startswith("Unable to open"):
-                return True
+                return 0
             else:
                 raise
 
-    def get_branches(self):
+    @LazyProperty
+    def heads(self):
+        return [Object(name=None, object_id=self._oid(self.head))]
+
+    @LazyProperty
+    def branches(self):
         return []
 
-    def get_tags(self):
+    @LazyProperty
+    def tags(self):
         return []
 
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7437ce52/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 0bc2f86..9751b38 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -65,8 +65,7 @@ class TestNewRepo(unittest.TestCase):
             tool = 'svn',
             status = 'creating')
         self.repo.refresh()
-        self.rev = M.repo.Commit.query.get(_id=self.repo.heads[0]['object_id'])
-        self.rev.repo = self.repo
+        self.rev = self.repo.commit('HEAD')
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
 
@@ -723,10 +722,7 @@ class TestRepo(_TestWithRepo):
                         name=committer_name,
                         email=committer_email),
                     _id=oid)).m.insert()
-        def set_heads():
-            self.repo.heads = [ ming.base.Object(name='head', object_id='foo0', count=100) ]
         self.repo._impl.refresh_commit_info = refresh_commit_info
-        self.repo._impl.refresh_heads = mock.Mock(side_effect=set_heads)
         _id = lambda oid: getattr(oid, '_id', str(oid))
         self.repo.shorthand_for_commit = lambda oid: '[' + _id(oid) + ']'
         self.repo.url_for_commit = lambda oid: 'ci/' + _id(oid) + '/'
@@ -747,9 +743,6 @@ class TestRepo(_TestWithRepo):
         self.repo.count_revisions=mock.Mock(return_value=100)
         self.repo._impl.commit = mock.Mock(return_value=ci)
         self.repo._impl.new_commits = mock.Mock(return_value=['foo%d' % i for i in range(100) ])
-        def set_heads():
-            self.repo.heads = [ ming.base.Object(name='head', object_id='foo0', count=100) ]
-        self.repo._impl.refresh_heads = mock.Mock(side_effect=set_heads)
 
         # make unreadable by *anonymous, so additional notification logic executes
         self.repo.acl = []

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7437ce52/ForgeUserStats/forgeuserstats/tests/test_model.py
----------------------------------------------------------------------
diff --git a/ForgeUserStats/forgeuserstats/tests/test_model.py b/ForgeUserStats/forgeuserstats/tests/test_model.py
index cc67e27..a6526e1 100644
--- a/ForgeUserStats/forgeuserstats/tests/test_model.py
+++ b/ForgeUserStats/forgeuserstats/tests/test_model.py
@@ -337,8 +337,7 @@ class TestUserStats(unittest.TestCase):
         c.app.repo.name = 'testgit.git'
         repo = c.app.repo
         repo.refresh()
-        commit = M.repo.Commit.query.get(_id=repo.heads[0]['object_id'])
-        commit.repo = repo
+        commit = repo.commit()
 
         init_commits = self.user.stats.getCommits()
         assert init_commits['number'] == 4

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7437ce52/ForgeUserStats/forgeuserstats/tests/test_stats.py
----------------------------------------------------------------------
diff --git a/ForgeUserStats/forgeuserstats/tests/test_stats.py b/ForgeUserStats/forgeuserstats/tests/test_stats.py
index 482eda8..0e747f0 100644
--- a/ForgeUserStats/forgeuserstats/tests/test_stats.py
+++ b/ForgeUserStats/forgeuserstats/tests/test_stats.py
@@ -192,8 +192,7 @@ class TestGitCommit(TestController, unittest.TestCase):
         c.app.repo.name = 'testgit.git'
         self.repo = c.app.repo
         self.repo.refresh()
-        self.rev = M.repo.Commit.query.get(_id=self.repo.heads[0]['object_id'])
-        self.rev.repo = self.repo
+        self.rev = self.repo.commit()
 
     @td.with_user_project('test-admin')
     def test_commit(self):


[15/16] git commit: [#6218] Fix test

Posted by tv...@apache.org.
[#6218] Fix test

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/6218
Commit: 6e76882a088c7549a0612d9132b196a1d34d9955
Parents: 8bff68a
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Jun 4 19:32:47 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 4 19:32:47 2013 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/tests/model/test_repository.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6e76882a/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 4afe27f..021e2f8 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -258,7 +258,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         n = M.Notification.query.find(
             dict(subject='[test:src-git] [1e146e] - Rick Copeland: Change README')).first()
         assert n
-        assert 'master,zz: ' in n.text
+        assert 'master: ' in n.text, n.text
         send_notifications(self.repo, ['1e146e67985dcd71c74de79613719bef7bddca4a', 'df30427c488aeab84b2352bdf88a3b19223f9d7a'])
         ThreadLocalORMSession.flush_all()
         assert M.Notification.query.find(


[07/16] git commit: [#6218] Get branches and tags directly from SCM

Posted by tv...@apache.org.
[#6218] Get branches and tags directly from SCM

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 6a3753d773045b66b319941ec6a264dbd20575d0
Parents: f9d1c45
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu May 23 23:35:00 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 4 18:46:06 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/repository.py                    |   27 +++++++++------
 Allura/allura/model/repository.py                  |   10 +++++
 ForgeGit/forgegit/model/git_repo.py                |    6 +++
 .../forgegit/tests/data/testgit.git/refs/tags/foo  |    1 +
 ForgeGit/forgegit/tests/model/test_repository.py   |   20 +++++++++++
 ForgeSVN/forgesvn/model/svn.py                     |    6 +++
 6 files changed, 59 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6a3753d7/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 3a432ec..afd5557 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -130,29 +130,34 @@ class RepositoryApp(Application):
                         self.repo.upstream_repo.name + 'merge-requests/',
                         small=pending_upstream_merges))
         ref_url = self.repo.url_for_commit(self.default_branch_name, url_type='ref')
-        if self.repo.branches:
+        branches = self.repo.get_branches()
+        if branches:
             links.append(SitemapEntry('Branches'))
+            for branch in branches:
+                if branch.name == self.default_branch_name:
+                    branches.remove(branch)
+                    branches.insert(0, branch)
+                    break
             max_branches = 10
-            for b in self.repo.branches[:max_branches]:
+            for branch in branches[:max_branches]:
                 links.append(SitemapEntry(
-                        b.name,
-                        quote(self.repo.url_for_commit(b.name) + 'tree/'),
-                        small=b.count))
-            if len(self.repo.branches) > max_branches:
+                        branch.name,
+                        quote(self.repo.url_for_commit(branch.name) + 'tree/')))
+            if len(branches) > max_branches:
                 links.append(
                     SitemapEntry(
                         'More Branches',
                         ref_url + 'branches/',
                         ))
-        if self.repo.repo_tags:
+        tags = self.repo.get_tags()
+        if tags:
             links.append(SitemapEntry('Tags'))
             max_tags = 10
-            for b in self.repo.repo_tags[:max_tags]:
+            for b in tags[:max_tags]:
                 links.append(SitemapEntry(
                         b.name,
-                        quote(self.repo.url_for_commit(b.name) + 'tree/'),
-                        small=b.count))
-            if len(self.repo.repo_tags) > max_tags:
+                        quote(self.repo.url_for_commit(b.name) + 'tree/')))
+            if len(tags) > max_tags:
                 links.append(
                     SitemapEntry(
                         'More Tags',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6a3753d7/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 1b6cfc4..1960d59 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -214,6 +214,12 @@ class RepositoryImplementation(object):
         os.chmod(magic_file, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
         self._setup_hooks(source_path)
 
+    def get_branches(self):
+        return self.repo.branches
+
+    def get_tags(self):
+        return self.repo.tags
+
 class Repository(Artifact, ActivityObject):
     BATCH_SIZE=100
     class __mongometa__:
@@ -326,6 +332,10 @@ class Repository(Artifact, ActivityObject):
         return self._impl.last_commit_ids(commit, paths)
     def is_empty(self):
         return self._impl.is_empty()
+    def get_branches(self):
+        return self._impl.get_branches()
+    def get_tags(self):
+        return self._impl.get_tags()
 
     def _log(self, rev, skip, limit):
         head = self.commit(rev)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6a3753d7/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index c656dfd..5683296 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -361,6 +361,12 @@ class GitImplementation(M.RepositoryImplementation):
     def is_empty(self):
         return not self._git or len(self._git.heads) == 0
 
+    def get_branches(self):
+        return [Object(name=b.name,object_id=b.commit.hexsha) for b in self._git.heads]
+
+    def get_tags(self):
+        return [Object(name=t.name, object_id=t.commit.hexsha) for t in self._git.tags]
+
 
 class _OpenedGitBlob(object):
     CHUNK_SIZE=4096

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6a3753d7/ForgeGit/forgegit/tests/data/testgit.git/refs/tags/foo
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/testgit.git/refs/tags/foo b/ForgeGit/forgegit/tests/data/testgit.git/refs/tags/foo
new file mode 100644
index 0000000..7e970a5
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/testgit.git/refs/tags/foo
@@ -0,0 +1 @@
+1e146e67985dcd71c74de79613719bef7bddca4a

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6a3753d7/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 46be17f..e0026b7 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -339,6 +339,26 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             ThreadLocalORMSession.flush_all()
             assert repo2.is_empty()
 
+class TestGitImplementation(unittest.TestCase):
+    def test_get_branches(self):
+        repo_dir = pkg_resources.resource_filename(
+            'forgegit', 'tests/data/testgit.git')
+        repo = mock.Mock(full_fs_path=repo_dir)
+        impl = GM.git_repo.GitImplementation(repo)
+        self.assertEqual(impl.get_branches(), [
+                Object(name='master', object_id='1e146e67985dcd71c74de79613719bef7bddca4a'),
+                Object(name='zz', object_id='5c47243c8e424136fd5cdd18cd94d34c66d1955c')
+            ])
+
+    def test_get_tags(self):
+        repo_dir = pkg_resources.resource_filename(
+            'forgegit', 'tests/data/testgit.git')
+        repo = mock.Mock(full_fs_path=repo_dir)
+        impl = GM.git_repo.GitImplementation(repo)
+        self.assertEqual(impl.get_tags(), [
+                Object(name='foo', object_id='1e146e67985dcd71c74de79613719bef7bddca4a'),
+            ])
+
 
 class TestGitCommit(unittest.TestCase):
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6a3753d7/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 811380a..f017f0b 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -698,5 +698,11 @@ class SVNImplementation(M.RepositoryImplementation):
             else:
                 raise
 
+    def get_branches(self):
+        return []
+
+    def get_tags(self):
+        return []
+
 
 Mapper.compile_all()


[04/16] git commit: [#6007] fix more test failures

Posted by tv...@apache.org.
[#6007] fix more test failures


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

Branch: refs/heads/cj/6218
Commit: d07ea1e86fcc9dfffc6796d976393cb8d1d5f083
Parents: 2927da2
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri May 3 17:57:09 2013 -0400
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Jun 4 14:40:52 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py               |    3 +-
 Allura/allura/lib/app_globals.py                   |    5 ++-
 .../forgediscussion/tests/functional/test_forum.py |   20 ++++++------
 .../forgegit/tests/functional/test_controllers.py  |    6 ++--
 ForgeGit/forgegit/tests/model/test_repository.py   |   11 +++----
 ForgeSVN/forgesvn/tests/model/test_repository.py   |    6 ++--
 ForgeUserStats/forgeuserstats/tests/test_stats.py  |   24 +++++++-------
 7 files changed, 39 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d07ea1e8/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index 5f65515..fbfbaf0 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -299,7 +299,8 @@ class PostController(BaseController):
                     thread=self.post.thread,
                     reply_subject=self.post.reply_subject,
                     attachments=self.post.attachments,
-                    related_artifacts=self.post.related_artifacts
+                    related_artifacts=self.post.related_artifacts,
+                    parent_security_context=lambda: None,
                     )
             else:
                 post=self.post

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d07ea1e8/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index a94976b..26e0854 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -330,7 +330,10 @@ class Globals(object):
                 c.user.set_pref('results_per_page', int(limit))
         else:
             if c.user in (None, M.User.anonymous()):
-                limit = 'results_per_page' in session and session['results_per_page'] or default
+                try:
+                    limit = session['results_per_page']
+                except (KeyError, TypeError):  # TypeError if no session registered for thread
+                    limit = default
             else:
                 limit = c.user.get_pref('results_per_page') or default
         return limit

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d07ea1e8/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 4acf35c..c9f7196 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -139,7 +139,7 @@ class TestForumAsync(TestController):
         r = self.app.get('/admin/discussion/forums')
         assert 'Test Forum 1' in r
         h.set_context('test', 'discussion', neighborhood='Projects')
-        self.user_id = M.User.query.get(username='root')._id
+        self.user = M.User.query.get(username='root')
 
     def test_has_access(self):
         assert False == c.app.has_access(M.User.anonymous(), 'testforum')
@@ -248,15 +248,15 @@ class TestForumAsync(TestController):
 
     def _post(self, topic, subject, body, **kw):
         message_id = kw.pop('message_id', '%s@test.com' % random.random())
-        c.app.handle_message(
-            topic,
-            dict(kw,
-                 project_id=c.project._id,
-                 mount_point='discussion',
-                 headers=dict(Subject=subject),
-                 user_id=self.user_id,
-                 payload=body,
-                 message_id=message_id))
+        with h.push_config(c, user=self.user):
+            c.app.handle_message(
+                topic,
+                dict(kw,
+                     project_id=c.project._id,
+                     mount_point='discussion',
+                     headers=dict(Subject=subject),
+                     payload=body,
+                     message_id=message_id))
         M.artifact_orm_session.flush()
 
 class TestForum(TestController):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d07ea1e8/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 fd61b4a..204f729 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -238,7 +238,8 @@ class TestRootController(_TestCase):
 
     def test_refresh(self):
         notification = M.Notification.query.find(
-            dict(subject='[test:src-git] 5 new commits to test Git')).first()
+            dict(subject='[test:src-git] 5 new commits to Test Project Git')).first()
+        assert notification
         domain = '.'.join(reversed(c.app.url[1:-1].split('/'))).replace('_', '-')
         common_suffix = tg.config.get('forgemail.domain', '.sourceforge.net')
         email = 'noreply@%s%s' % (domain, common_suffix)
@@ -428,7 +429,7 @@ class TestFork(_TestCase):
     def test_fork_form(self):
         r = self.app.get('%sfork/' % c.app.repo.url())
         assert '<input type="text" name="mount_point" value="test"/>' in r
-        assert '<input type="text" name="mount_label" value="test - Git"/>' in r
+        assert '<input type="text" name="mount_label" value="Test Project - Git"/>' in r, r
 
     def test_fork_listed_in_parent(self):
         assert 'Forks' in self._upstream_page()
@@ -510,4 +511,3 @@ class TestDiff(TestController):
         r = self.app.get('/src-git/ci/d961abbbf10341ee18a668c975842c35cfc0bef2/tree/1.png?diff=2ce83a24e52c21e8d2146b1a04a20717c0bb08d7')
         assert 'alt="2ce83a2..."' in r
         assert 'alt="d961abb..."' in r
-

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d07ea1e8/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 316f202..46be17f 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -262,15 +262,14 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
     def test_notification_email(self):
         send_notifications(self.repo, ['1e146e67985dcd71c74de79613719bef7bddca4a', ])
         ThreadLocalORMSession.flush_all()
-        notifications = M.Notification.query.find().sort('pubdate')
-        n = notifications.all()[2]
-        assert_equal(n.subject, '[test:src-git] [1e146e] - Rick Copeland: Change README')
+        n = M.Notification.query.find(
+            dict(subject='[test:src-git] [1e146e] - Rick Copeland: Change README')).first()
+        assert n
         assert 'master,zz: ' in n.text
         send_notifications(self.repo, ['1e146e67985dcd71c74de79613719bef7bddca4a', 'df30427c488aeab84b2352bdf88a3b19223f9d7a'])
         ThreadLocalORMSession.flush_all()
-        notifications = M.Notification.query.find().sort('pubdate')
-        n = notifications.all()[3]
-        assert_equal(n.subject, '[test:src-git] 2 new commits to test Git')
+        assert M.Notification.query.find(
+            dict(subject='[test:src-git] 2 new commits to Test Project Git')).first()
 
     def test_tarball(self):
         tmpdir = tg.config['scm.repos.tarball.root']

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d07ea1e8/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 01ca3df..0bc2f86 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -536,9 +536,9 @@ class TestSVNRev(unittest.TestCase):
         commits = self.repo.commits()
         send_notifications(self.repo, [commits[4], ])
         ThreadLocalORMSession.flush_all()
-        notifications = M.Notification.query.find().sort('pubdate')
-        n = notifications.all()[3]
-        assert_equal(n.subject, '[test:src] [r1] - rick446: Create readme')
+        n = M.Notification.query.find(
+            dict(subject='[test:src] [r1] - rick446: Create readme')).first()
+        assert n
         assert_equal(n.text, 'Create readme http://localhost//p/test/src/1/')
 
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d07ea1e8/ForgeUserStats/forgeuserstats/tests/test_stats.py
----------------------------------------------------------------------
diff --git a/ForgeUserStats/forgeuserstats/tests/test_stats.py b/ForgeUserStats/forgeuserstats/tests/test_stats.py
index 90a467e..482eda8 100644
--- a/ForgeUserStats/forgeuserstats/tests/test_stats.py
+++ b/ForgeUserStats/forgeuserstats/tests/test_stats.py
@@ -40,7 +40,7 @@ class TestStats(TestController):
 
     def test_login(self):
         user = User.by_username('test-user')
-        init_logins = c.user.stats.tot_logins_count
+        init_logins = user.stats.tot_logins_count
         r = self.app.post('/auth/do_login', params=dict(
                 username=user.username, password='foo'))
 
@@ -52,7 +52,7 @@ class TestStats(TestController):
         initial_artifacts = c.user.stats.getArtifacts()
         initial_wiki = c.user.stats.getArtifacts(art_type="Wiki")
 
-        self.app.post('/wiki/TestPage/update', 
+        self.app.post('/wiki/TestPage/update',
             params=dict(title='TestPage', text='some text'),
             extra_environ=dict(username=str(c.user.username)))
 
@@ -64,7 +64,7 @@ class TestStats(TestController):
         assert wiki['created'] == 1 + initial_wiki['created']
         assert wiki['modified'] == initial_wiki['modified']
 
-        self.app.post('/wiki/TestPage2/update', 
+        self.app.post('/wiki/TestPage2/update',
             params=dict(title='TestPage2', text='some text'),
             extra_environ=dict(username=str(c.user.username)))
 
@@ -76,7 +76,7 @@ class TestStats(TestController):
         assert wiki['created'] == 2 + initial_wiki['created']
         assert wiki['modified'] == initial_wiki['modified']
 
-        self.app.post('/wiki/TestPage2/update', 
+        self.app.post('/wiki/TestPage2/update',
             params=dict(title='TestPage2', text='some modified text'),
             extra_environ=dict(username=str(c.user.username)))
 
@@ -93,7 +93,7 @@ class TestStats(TestController):
         initial_tickets = c.user.stats.getTickets()
         initial_tickets_artifacts = c.user.stats.getArtifacts(art_type="Ticket")
 
-        r = self.app.post('/tickets/save_ticket', 
+        r = self.app.post('/tickets/save_ticket',
             params={'ticket_form.summary':'test',
                     'ticket_form.assigned_to' : str(c.user.username)},
             extra_environ=dict(username=str(c.user.username)))
@@ -109,7 +109,7 @@ class TestStats(TestController):
         assert tickets_artifacts['created'] == initial_tickets_artifacts['created'] + 1
         assert tickets_artifacts['modified'] == initial_tickets_artifacts['modified']
 
-        r = self.app.post('/tickets/%s/update_ticket_from_widget' % ticketnum, 
+        r = self.app.post('/tickets/%s/update_ticket_from_widget' % ticketnum,
             params={'ticket_form.ticket_num' : ticketnum,
                     'ticket_form.summary':'footext3',
                     'ticket_form.status' : 'closed'},
@@ -124,12 +124,12 @@ class TestStats(TestController):
         assert tickets_artifacts['created'] == initial_tickets_artifacts['created'] + 1
         assert tickets_artifacts['modified'] == initial_tickets_artifacts['modified'] + 1
 
-        r = self.app.post('/tickets/save_ticket', 
+        r = self.app.post('/tickets/save_ticket',
             params={'ticket_form.summary':'test2'},
             extra_environ=dict(username=str(c.user.username)))
 
         ticketnum = str(TM.Ticket.query.get(summary='test2').ticket_num)
-        
+
         tickets = c.user.stats.getTickets()
         tickets_artifacts = c.user.stats.getArtifacts(art_type="Ticket")
 
@@ -139,7 +139,7 @@ class TestStats(TestController):
         assert tickets_artifacts['created'] == initial_tickets_artifacts['created'] + 2
         assert tickets_artifacts['modified'] == initial_tickets_artifacts['modified'] + 1
 
-        r = self.app.post('/tickets/%s/update_ticket_from_widget' % ticketnum, 
+        r = self.app.post('/tickets/%s/update_ticket_from_widget' % ticketnum,
             params={'ticket_form.ticket_num' : ticketnum,
                     'ticket_form.summary':'test2',
                     'ticket_form.assigned_to' : str(c.user.username)},
@@ -147,14 +147,14 @@ class TestStats(TestController):
 
         tickets = c.user.stats.getTickets()
         tickets_artifacts = c.user.stats.getArtifacts(art_type="Ticket")
-        
+
         assert tickets['assigned'] == initial_tickets['assigned'] + 2
         assert tickets['solved'] == initial_tickets['solved'] + 1
         assert tickets['revoked'] == initial_tickets['revoked']
         assert tickets_artifacts['created'] == initial_tickets_artifacts['created'] + 2
         assert tickets_artifacts['modified'] == initial_tickets_artifacts['modified'] + 2
 
-        r = self.app.post('/tickets/%s/update_ticket_from_widget' % ticketnum, 
+        r = self.app.post('/tickets/%s/update_ticket_from_widget' % ticketnum,
             params={'ticket_form.ticket_num' : ticketnum,
                     'ticket_form.summary':'test2',
                     'ticket_form.assigned_to' : 'test-user'},
@@ -162,7 +162,7 @@ class TestStats(TestController):
 
         tickets = c.user.stats.getTickets()
         tickets_artifacts = c.user.stats.getArtifacts(art_type="Ticket")
-        
+
         assert tickets['assigned'] == initial_tickets['assigned'] + 2
         assert tickets['solved'] == initial_tickets['solved'] + 1
         assert tickets['revoked'] == initial_tickets['revoked'] + 1


[14/16] git commit: [#6218] Fix tests

Posted by tv...@apache.org.
[#6218] Fix tests

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/6218
Commit: 8bff68a7fd2848a4cbb37f971497c769f645c730
Parents: d7c8fc1
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Jun 4 18:45:16 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jun 4 19:01:54 2013 +0000

----------------------------------------------------------------------
 ForgeUserStats/forgeuserstats/tests/test_model.py |   60 ++++++++--------
 ForgeUserStats/forgeuserstats/tests/test_stats.py |    2 +-
 2 files changed, 31 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8bff68a7/ForgeUserStats/forgeuserstats/tests/test_model.py
----------------------------------------------------------------------
diff --git a/ForgeUserStats/forgeuserstats/tests/test_model.py b/ForgeUserStats/forgeuserstats/tests/test_model.py
index a6526e1..2203469 100644
--- a/ForgeUserStats/forgeuserstats/tests/test_model.py
+++ b/ForgeUserStats/forgeuserstats/tests/test_model.py
@@ -99,7 +99,7 @@ class TestUserStats(unittest.TestCase):
         assert art_by_type['Wiki']['modified'] == init_art_by_type['Wiki']['modified']
         assert lm_art_by_type['Wiki']['created'] == init_lm_art_by_type['Wiki']['created'] + 1
         assert lm_art_by_type['Wiki']['modified'] == init_lm_art_by_type['Wiki']['modified']
-        
+
         #In that case, last month stats should not be changed
         new_date = datetime.utcnow() + timedelta(-32)
         self.user.stats.addNewArtifact('Wiki', new_date, p)
@@ -119,7 +119,7 @@ class TestUserStats(unittest.TestCase):
         assert art_by_type['Wiki']['modified'] == init_art_by_type['Wiki']['modified']
         assert lm_art_by_type['Wiki']['created'] == init_lm_art_by_type['Wiki']['created'] + 1
         assert lm_art_by_type['Wiki']['modified'] == init_lm_art_by_type['Wiki']['modified']
-        
+
         p.trove_topic = [topic._id]
 
         self.user.stats.addNewArtifact('Wiki', datetime.utcnow(), p)
@@ -176,7 +176,7 @@ class TestUserStats(unittest.TestCase):
         assert art_by_type['Wiki']['modified'] == init_art_by_type['Wiki']['modified'] + 1
         assert lm_art_by_type['Wiki']['created'] == init_lm_art_by_type['Wiki']['created']
         assert lm_art_by_type['Wiki']['modified'] == init_lm_art_by_type['Wiki']['modified'] + 1
-        
+
         #In that case, last month stats should not be changed
         new_date = datetime.utcnow() + timedelta(-32)
         self.user.stats.addModifiedArtifact('Wiki', new_date, p)
@@ -186,9 +186,9 @@ class TestUserStats(unittest.TestCase):
         art_by_type = self.user.stats.getArtifactsByType()
         lm_art_by_type = self.user.stats.getLastMonthArtifactsByType()
 
-        assert lm_art['created'] == init_lm_art['created'] 
+        assert lm_art['created'] == init_lm_art['created']
         assert lm_art['modified'] == init_lm_art['modified'] + 1
-        assert artifacts['created'] == init_art['created'] 
+        assert artifacts['created'] == init_art['created']
         assert artifacts['modified'] == init_art['modified'] + 2
         assert art_wiki['created'] == init_art_wiki['created']
         assert art_wiki['modified'] == init_art_wiki['modified'] + 2
@@ -196,7 +196,7 @@ class TestUserStats(unittest.TestCase):
         assert art_by_type['Wiki']['modified'] == init_art_by_type['Wiki']['modified'] + 2
         assert lm_art_by_type['Wiki']['created'] == init_lm_art_by_type['Wiki']['created']
         assert lm_art_by_type['Wiki']['modified'] == init_lm_art_by_type['Wiki']['modified'] + 1
-        
+
         p.trove_topic = [topic._id]
 
         self.user.stats.addModifiedArtifact('Wiki', datetime.utcnow(), p)
@@ -208,13 +208,13 @@ class TestUserStats(unittest.TestCase):
         art_sci = self.user.stats.getArtifacts(category=topic._id)
         art_by_cat = self.user.stats.getArtifactsByCategory(detailed=True)
 
-        assert lm_art['created'] == init_lm_art['created'] 
+        assert lm_art['created'] == init_lm_art['created']
         assert lm_art['modified'] == init_lm_art['modified'] + 2
         assert artifacts['created'] == init_art['created']
         assert artifacts['modified'] == init_art['modified'] + 3
         assert art_wiki['created'] == init_art_wiki['created']
         assert art_wiki['modified'] == init_art_wiki['modified'] + 3
-        assert art_by_type['Wiki']['created'] == init_art_by_type['Wiki']['created'] 
+        assert art_by_type['Wiki']['created'] == init_art_by_type['Wiki']['created']
         assert art_by_type['Wiki']['modified'] == init_art_by_type['Wiki']['modified'] + 3
         assert lm_art_by_type['Wiki']['created'] == init_lm_art_by_type['Wiki']['created']
         assert lm_art_by_type['Wiki']['modified'] == init_lm_art_by_type['Wiki']['modified'] +2
@@ -247,39 +247,39 @@ class TestUserStats(unittest.TestCase):
         assert tickets_art['modified'] == init_tickets_art['modified']
         assert tickets_sci_art['created'] == tickets_sci_art['created']
         assert tickets_sci_art['modified'] == tickets_sci_art['modified']
-        
+
         p.trove_topic = [topic._id]
 
         self.user.stats.addAssignedTicket(create_time, p)
         tickets = self.user.stats.getTickets()
         lm_tickets = self.user.stats.getLastMonthTickets()
 
-        assert tickets['assigned'] == init_tickets['assigned'] + 1 
+        assert tickets['assigned'] == init_tickets['assigned'] + 1
         assert tickets['revoked'] == init_tickets['revoked']
-        assert tickets['solved'] == init_tickets['solved'] 
-        assert tickets['averagesolvingtime'] is None 
-        assert lm_tickets['assigned'] == init_lm_tickets['assigned'] + 1 
+        assert tickets['solved'] == init_tickets['solved']
+        assert tickets['averagesolvingtime'] is None
+        assert lm_tickets['assigned'] == init_lm_tickets['assigned'] + 1
         assert lm_tickets['revoked'] == init_lm_tickets['revoked']
-        assert lm_tickets['solved'] == init_lm_tickets['solved'] 
-        assert lm_tickets['averagesolvingtime'] is None 
+        assert lm_tickets['solved'] == init_lm_tickets['solved']
+        assert lm_tickets['averagesolvingtime'] is None
 
         self.user.stats.addRevokedTicket(create_time + timedelta(-32), p)
         tickets = self.user.stats.getTickets()
 
-        assert tickets['assigned'] == init_tickets['assigned'] + 1 
+        assert tickets['assigned'] == init_tickets['assigned'] + 1
         assert tickets['revoked'] == init_tickets['revoked'] + 1
-        assert tickets['solved'] == init_tickets['solved'] 
-        assert tickets['averagesolvingtime'] is None 
-        assert lm_tickets['assigned'] == init_lm_tickets['assigned'] + 1 
+        assert tickets['solved'] == init_tickets['solved']
+        assert tickets['averagesolvingtime'] is None
+        assert lm_tickets['assigned'] == init_lm_tickets['assigned'] + 1
         assert lm_tickets['revoked'] == init_lm_tickets['revoked']
-        assert lm_tickets['solved'] == init_lm_tickets['solved'] 
-        assert lm_tickets['averagesolvingtime'] is None 
+        assert lm_tickets['solved'] == init_lm_tickets['solved']
+        assert lm_tickets['averagesolvingtime'] is None
 
         self.user.stats.addClosedTicket(create_time, create_time + timedelta(1), p)
         tickets = self.user.stats.getTickets()
         lm_tickets = self.user.stats.getLastMonthTickets()
 
-        assert tickets['assigned'] == init_tickets['assigned'] + 1 
+        assert tickets['assigned'] == init_tickets['assigned'] + 1
         assert tickets['revoked'] == init_tickets['revoked'] + 1
         assert tickets['solved'] == init_tickets['solved'] + 1
 
@@ -297,7 +297,7 @@ class TestUserStats(unittest.TestCase):
 
         solving_time = dict(seconds=0,minutes=0,days=2,hours=0)
 
-        assert tickets['assigned'] == init_tickets['assigned'] + 1 
+        assert tickets['assigned'] == init_tickets['assigned'] + 1
         assert tickets['revoked'] == init_tickets['revoked'] + 1
         assert tickets['solved'] == init_tickets['solved'] + 2
         assert tickets['averagesolvingtime'] == solving_time
@@ -310,7 +310,7 @@ class TestUserStats(unittest.TestCase):
         lm_by_cat = self.user.stats.getLastMonthTicketsByCategory()
         solving_time=dict(days=1,hours=0,minutes=0,seconds=0)
 
-        assert by_cat[topic]['assigned'] == 1 
+        assert by_cat[topic]['assigned'] == 1
         assert by_cat[topic]['revoked'] == 1
         assert by_cat[topic]['solved'] == 1
         assert by_cat[topic]['averagesolvingtime'] == solving_time
@@ -329,7 +329,7 @@ class TestUserStats(unittest.TestCase):
         self.user.set_password('testpassword')
         addr = M.EmailAddress.upsert('rcopeland@geek.net')
         self.user.claim_address('rcopeland@geek.net')
-        
+
         repo_dir = pkg_resources.resource_filename(
             'forgeuserstats', 'tests/data')
 
@@ -337,7 +337,7 @@ class TestUserStats(unittest.TestCase):
         c.app.repo.name = 'testgit.git'
         repo = c.app.repo
         repo.refresh()
-        commit = repo.commit()
+        commit = repo.commit('HEAD')
 
         init_commits = self.user.stats.getCommits()
         assert init_commits['number'] == 4
@@ -377,20 +377,20 @@ class TestUserStats(unittest.TestCase):
     def test_login_stats(self):
         init_logins = self.user.stats.tot_logins_count
         init_lm_logins = self.user.stats.getLastMonthLogins()
-        
+
         login_datetime = datetime.utcnow()
         self.user.stats.addLogin(login_datetime)
         logins = self.user.stats.tot_logins_count
         lm_logins = self.user.stats.getLastMonthLogins()
-        assert logins == init_logins + 1 
-        assert lm_logins == init_lm_logins + 1 
+        assert logins == init_logins + 1
+        assert lm_logins == init_lm_logins + 1
         assert abs(self.user.stats.last_login - login_datetime) < timedelta(seconds=1)
 
         self.user.stats.addLogin(datetime.utcnow() + timedelta(-32))
         logins = self.user.stats.tot_logins_count
         lm_logins = self.user.stats.getLastMonthLogins()
         assert logins == init_logins + 2
-        assert lm_logins == init_lm_logins + 1 
+        assert lm_logins == init_lm_logins + 1
         assert abs(self.user.stats.last_login - login_datetime) < timedelta(seconds=1)
 
     def test_start_date(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8bff68a7/ForgeUserStats/forgeuserstats/tests/test_stats.py
----------------------------------------------------------------------
diff --git a/ForgeUserStats/forgeuserstats/tests/test_stats.py b/ForgeUserStats/forgeuserstats/tests/test_stats.py
index 0e747f0..b2b20ce 100644
--- a/ForgeUserStats/forgeuserstats/tests/test_stats.py
+++ b/ForgeUserStats/forgeuserstats/tests/test_stats.py
@@ -192,7 +192,7 @@ class TestGitCommit(TestController, unittest.TestCase):
         c.app.repo.name = 'testgit.git'
         self.repo = c.app.repo
         self.repo.refresh()
-        self.rev = self.repo.commit()
+        self.rev = self.repo.commit('HEAD')
 
     @td.with_user_project('test-admin')
     def test_commit(self):


[02/16] git commit: [#6007] Better installation of subproject in bootstrap. Don't leave a c.user/project

Posted by tv...@apache.org.
[#6007] Better installation of subproject in bootstrap.  Don't leave a c.user/project

Default subproject is now named, not first tool in test project,
and with a wiki instead of no tools.

This also stops leaving a c.user and c.project around.  So many tests
are updated to explicitly set up a c.user or c.project if they were
relying on that.


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

Branch: refs/heads/cj/6218
Commit: 2927da20f3434775705a190f3ba54a6d92814808
Parents: 439a66c
Author: Dave Brondsema <db...@geek.net>
Authored: Mon Mar 25 14:39:49 2013 -0700
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Jun 4 14:40:52 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py                   |    4 +-
 Allura/allura/lib/plugin.py                        |    9 +-
 Allura/allura/model/discuss.py                     |    2 +-
 Allura/allura/model/project.py                     |    4 +-
 Allura/allura/tests/functional/test_discuss.py     |    3 +-
 Allura/allura/tests/functional/test_home.py        |    5 +-
 .../allura/tests/functional/test_neighborhood.py   |    4 +-
 Allura/allura/tests/functional/test_root.py        |   10 +-
 Allura/allura/tests/model/test_project.py          |   45 +++--
 Allura/allura/tests/test_globals.py                |  152 ++++++++-------
 Allura/allura/tests/test_mail_util.py              |    2 +-
 Allura/allura/tests/unit/test_post_model.py        |    8 +-
 Allura/allura/websetup/bootstrap.py                |   25 ++-
 13 files changed, 156 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 43493ae..a94976b 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -28,6 +28,7 @@ import datetime
 from urllib import urlencode
 from subprocess import Popen, PIPE
 import os
+import traceback
 
 import activitystream
 import pkg_resources
@@ -72,7 +73,8 @@ class ForgeMarkdown(markdown.Markdown):
         try:
             return markdown.Markdown.convert(self, source)
         except Exception:
-            log.info('Invalid markdown: %s', source, exc_info=True)
+            log.info('Invalid markdown: %s  Upwards trace is %s', source,
+                     ''.join(traceback.format_stack()), exc_info=True)
             escaped = h.really_unicode(source)
             escaped = cgi.escape(escaped)
             return h.html.literal(u"""<p><strong>ERROR!</strong> The markdown supplied could not be parsed correctly.

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 3bb1655..4bbf557 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -584,18 +584,21 @@ class ProjectRegistrationProvider(object):
             g.post_event('project_created')
         return p
 
-    def register_subproject(self, project, name, user, install_apps):
+    def register_subproject(self, project, name, user, install_apps, project_name=None):
         from allura import model as M
         assert h.re_project_name.match(name), 'Invalid subproject shortname'
         shortname = project.shortname + '/' + name
+        ordinal = int(project.ordered_mounts(include_hidden=True)[-1]['ordinal']) + 1
         sp = M.Project(
             parent_id=project._id,
             neighborhood_id=project.neighborhood_id,
             shortname=shortname,
-            name=name,
+            name=project_name or name,
             database_uri=project.database_uri,
             last_updated = datetime.utcnow(),
-            is_root=False)
+            is_root=False,
+            ordinal=ordinal,
+        )
         with h.push_config(c, project=sp):
             M.AppConfig.query.remove(dict(project_id=c.project._id))
             if install_apps:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index f04ba47..9c4e573 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -616,7 +616,7 @@ class Post(Message, VersionedArtifact, ActivityObject):
         self.status = 'ok'
         author = self.author()
         security.simple_grant(
-            self.acl, author.project_role()._id, 'moderate')
+            self.acl, author.project_role(self.project)._id, 'moderate')
         self.commit()
         if (c.app.config.options.get('PostingPolicy') == 'ApproveOnceModerated'
             and author._id != None):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index c11c148..6988ffc 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -636,11 +636,11 @@ class Project(MappedClass, ActivityNode, ActivityObject):
             if ac.tool_name == tool_type:
                 return ac
 
-    def new_subproject(self, name, install_apps=True, user=None):
+    def new_subproject(self, name, install_apps=True, user=None, project_name=None):
         if not h.re_project_name.match(name):
             raise exceptions.ToolError, 'Mount point "%s" is invalid' % name
         provider = plugin.ProjectRegistrationProvider.get()
-        return provider.register_subproject(self, name, user or c.user, install_apps)
+        return provider.register_subproject(self, name, user or c.user, install_apps, project_name=project_name)
 
     def ordered_mounts(self, include_hidden=False):
         '''Returns an array of a projects mounts (tools and sub-projects) in

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index 8a51ac4..6ad4f21 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -127,7 +127,8 @@ class TestDiscuss(TestController):
         # set wiki page private
         from forgewiki.model import Page
         page = Page.query.get(_id=thread.ref.artifact._id)  # need to look up the page directly, so ming is aware of our change
-        role_admin = M.ProjectRole.by_name('Admin')._id
+        project = M.Project.query.get(shortname='test')
+        role_admin = M.ProjectRole.by_name('Admin', project)._id
         page.acl = [
             M.ACE.allow(role_admin, M.ALL_PERMISSIONS),
             M.DENY_ALL,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/tests/functional/test_home.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_home.py b/Allura/allura/tests/functional/test_home.py
index 5e9ec2e..73ff80c 100644
--- a/Allura/allura/tests/functional/test_home.py
+++ b/Allura/allura/tests/functional/test_home.py
@@ -64,8 +64,8 @@ class TestProjectHome(TestController):
                 c.app = p.install_app('wiki', tool_name, tool_name, i)
         response = self.app.get('/p/test/_nav.json')
         menu = response.json['menu']
-        assert_equal(len(menu[1]['children']), 11)
-        assert {u'url': u'/p/test/_list/wiki', u'name': u'More...', u'icon': u'tool-wiki', 'tool_name': 'wiki'} in menu[1]['children']
+        assert_equal(len(menu[0]['children']), 11)
+        assert {u'url': u'/p/test/_list/wiki', u'name': u'More...', u'icon': u'tool-wiki', 'tool_name': 'wiki'} in menu[0]['children']
 
     @td.with_wiki
     def test_neighborhood_home(self):
@@ -115,4 +115,3 @@ class TestProjectHome(TestController):
         assert '<td>Test Admin</td>' in r
         assert '<td><a href="/u/test-admin/">test-admin</a></td>' in r
         assert '<td>Admin</td>' in r
-

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/tests/functional/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index 07c4ccb..fd6c3e4 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -800,10 +800,12 @@ class TestNeighborhood(TestController):
                           extra_environ=dict(username='root'))
 
     def test_add_a_project_link(self):
+        from pylons import tmpl_context as c
         # Install Home tool for all neighborhoods
         for nb in M.Neighborhood.query.find().all():
             p = nb.neighborhood_project
-            p.install_app('home', 'home', 'Home', ordinal=0)
+            with h.push_config(c, user=M.User.query.get()):
+                p.install_app('home', 'home', 'Home', ordinal=0)
         r = self.app.get('/p/')
         assert 'Add a Project' in r
         r = self.app.get('/u/', extra_environ=dict(username='test-user'))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_root.py b/Allura/allura/tests/functional/test_root.py
index 707fb12..aa77873 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -29,6 +29,7 @@ Please read http://pythonpaste.org/webtest/ for more information.
 
 """
 from tg import config
+from pylons import tmpl_context as c
 from nose.tools import assert_equal
 from ming.orm.ormsession import ThreadLocalORMSession
 import mock
@@ -82,7 +83,7 @@ class TestRootController(TestController):
     def test_project_browse(self):
         com_cat = M.ProjectCategory.query.find(dict(label='Communications')).first()
         fax_cat = M.ProjectCategory.query.find(dict(label='Fax')).first()
-        M.Project.query.find(dict(name='adobe-1')).first().category_id = com_cat._id
+        M.Project.query.find(dict(shortname='adobe-1')).first().category_id = com_cat._id
         response = self.app.get('/browse')
         assert len(response.html.findAll('a',{'href':'/adobe/adobe-1/'})) == 1
         assert len(response.html.findAll('a',{'href':'/adobe/adobe-2/'})) == 1
@@ -114,7 +115,8 @@ class TestRootController(TestController):
         # Install home app
         nb = M.Neighborhood.query.get(name='Adobe')
         p = nb.neighborhood_project
-        p.install_app('home', 'home', 'Home', ordinal=0)
+        with push_config(c, user=M.User.query.get(username='test-admin')):
+            p.install_app('home', 'home', 'Home', ordinal=0)
 
         response = self.app.get('/adobe/')
         projects = response.html.findAll('div',{'class':'border card'})
@@ -127,8 +129,8 @@ class TestRootController(TestController):
     def test_neighborhood_project_browse(self):
         com_cat = M.ProjectCategory.query.find(dict(label='Communications')).first()
         fax_cat = M.ProjectCategory.query.find(dict(label='Fax')).first()
-        M.Project.query.find(dict(name='adobe-1')).first().category_id = com_cat._id
-        M.Project.query.find(dict(name='adobe-2')).first().category_id = fax_cat._id
+        M.Project.query.find(dict(shortname='adobe-1')).first().category_id = com_cat._id
+        M.Project.query.find(dict(shortname='adobe-2')).first().category_id = fax_cat._id
         response = self.app.get('/adobe/browse')
         assert len(response.html.findAll('a',{'href':'/adobe/adobe-1/'})) == 1
         assert len(response.html.findAll('a',{'href':'/adobe/adobe-2/'})) == 1

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/tests/model/test_project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_project.py b/Allura/allura/tests/model/test_project.py
index 16f5a97..d88fbdd 100644
--- a/Allura/allura/tests/model/test_project.py
+++ b/Allura/allura/tests/model/test_project.py
@@ -20,7 +20,7 @@
 """
 Model tests for project
 """
-from nose.tools import with_setup, assert_equal
+from nose.tools import with_setup, assert_equals, assert_in
 from pylons import tmpl_context as c
 from ming.orm.ormsession import ThreadLocalORMSession
 
@@ -40,29 +40,28 @@ def setUp():
 def setup_with_tools():
     setup_global_objects()
 
-@with_setup(setUp)
 def test_project():
-    assert type(c.project.sidebar_menu()) == list
-    assert c.project.script_name in c.project.url()
+    assert_equals(type(c.project.sidebar_menu()), list)
+    assert_in(c.project.script_name, c.project.url())
     old_proj = c.project
     h.set_context('test/sub1', neighborhood='Projects')
-    assert type(c.project.sidebar_menu()) == list
-    assert type(c.project.sitemap()) == list
-    assert c.project.sitemap()[0].label == 'Admin'
-    assert old_proj in list(c.project.parent_iter())
+    assert_equals(type(c.project.sidebar_menu()), list)
+    assert_equals(type(c.project.sitemap()), list)
+    assert_equals(c.project.sitemap()[1].label, 'Admin')
+    assert_in(old_proj, list(c.project.parent_iter()))
     h.set_context('test', 'wiki', neighborhood='Projects')
     adobe_nbhd = M.Neighborhood.query.get(name='Adobe')
     p = M.Project.query.get(shortname='adobe-1', neighborhood_id=adobe_nbhd._id)
     # assert 'http' in p.url() # We moved adobe into /adobe/, not http://adobe....
-    assert p.script_name in p.url()
-    assert c.project.shortname == 'test'
-    assert '<p>' in c.project.description_html
+    assert_in(p.script_name, p.url())
+    assert_equals(c.project.shortname, 'test')
+    assert_in('<p>', c.project.description_html)
     c.project.uninstall_app('hello-test-mount-point')
     ThreadLocalORMSession.flush_all()
 
     c.project.install_app('Wiki', 'hello-test-mount-point')
     c.project.support_page = 'hello-test-mount-point'
-    assert_equal(c.project.app_config('wiki').tool_name, 'wiki')
+    assert_equals(c.project.app_config('wiki').tool_name, 'wiki')
     ThreadLocalORMSession.flush_all()
     with td.raises(ToolError):
         # already installed
@@ -92,10 +91,11 @@ def test_project():
     c.app.config.breadcrumbs()
 
 def test_subproject():
+    project = M.Project.query.get(shortname='test')
     with td.raises(ToolError):
         # name exceeds 15 chars
-        sp = c.project.new_subproject('test-project-nose')
-    sp = c.project.new_subproject('test-proj-nose')
+        sp = project.new_subproject('test-project-nose')
+    sp = project.new_subproject('test-proj-nose')
     spp = sp.new_subproject('spp')
     ThreadLocalORMSession.flush_all()
     sp.delete()
@@ -105,18 +105,21 @@ def test_subproject():
 def test_anchored_tools():
     c.project.neighborhood.anchored_tools = 'wiki:Wiki, tickets:Ticket'
     c.project.install_app = MagicMock()
-    assert c.project.sitemap()[0].label == 'Wiki'
-    assert c.project.install_app.call_args[0][0] == 'tickets'
-    assert c.project.ordered_mounts()[0]['ac'].tool_name == 'wiki'
+    assert_equals(c.project.sitemap()[0].label, 'Wiki')
+    assert_equals(c.project.install_app.call_args[0][0], 'tickets')
+    assert_equals(c.project.ordered_mounts()[0]['ac'].tool_name, 'wiki')
 
 
 def test_set_ordinal_to_admin_tool():
-    assert c.project.sitemap()
-    assert c.project.app_config('admin').options.ordinal == 100
+    with h.push_config(c,
+                       user=M.User.anonymous(),
+                       project=M.Project.query.get(shortname='test')):
+        assert c.project.sitemap()
+        assert c.project.app_config('admin').options.ordinal == 100
 
 def test_users_and_roles():
-    p = c.project
-    sub = c.project.direct_subprojects.next()
+    p = M.Project.query.get(shortname='test')
+    sub = p.direct_subprojects.next()
     u = M.User.by_username('test-admin')
     assert p.users_with_role('Admin') == [u]
     assert p.users_with_role('Admin') == sub.users_with_role('Admin')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index b4df060..429ca27 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -59,10 +59,9 @@ def test_app_globals():
 
 
 @with_setup(teardown=setUp) # reset everything we changed
-def test_macros():
+def test_macro_projects():
     file_name = 'neo-icon-set-454545-256x350.png'
     file_path = os.path.join(allura.__path__[0],'nf','allura','images',file_name)
-    curr_project = c.project
 
     p_nbhd = M.Neighborhood.query.get(name='Projects')
     p_test = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
@@ -98,74 +97,87 @@ def test_macros():
 
     ThreadLocalORMSession.flush_all()
 
-    with h.push_context(p_nbhd.neighborhood_project._id):
+    with h.push_config(c,
+                       project=p_nbhd.neighborhood_project,
+                       user=M.User.by_username('test-admin')):
         r = g.markdown_wiki.convert('[[projects]]')
-        assert '<img alt="test Logo"' in r, r
-        assert '<img alt="sub1 Logo"' in r, r
+        assert '<img alt="Test Project Logo"' in r, r
+        assert '<img alt="A Subproject Logo"' in r, r
         r = g.markdown_wiki.convert('[[projects labels=root]]')
-        assert '<img alt="test Logo"' in r, r
-        assert '<img alt="sub1 Logo"' not in r, r
+        assert '<img alt="Test Project Logo"' in r, r
+        assert '<img alt="A Subproject Logo"' not in r, r
         r = g.markdown_wiki.convert('[[projects labels=sub1]]')
-        assert '<img alt="test Logo"' not in r, r
-        assert '<img alt="sub1 Logo"' in r, r
+        assert '<img alt="Test Project Logo"' not in r, r
+        assert '<img alt="A Subproject Logo"' in r, r
         r = g.markdown_wiki.convert('[[projects labels=test]]')
-        assert '<img alt="test Logo"' in r, r
-        assert '<img alt="sub1 Logo"' in r, r
+        assert '<img alt="Test Project Logo"' in r, r
+        assert '<img alt="A Subproject Logo"' in r, r
         r = g.markdown_wiki.convert('[[projects labels=test,root]]')
-        assert '<img alt="test Logo"' in r, r
-        assert '<img alt="sub1 Logo"' not in r, r
+        assert '<img alt="Test Project Logo"' in r, r
+        assert '<img alt="A Subproject Logo"' not in r, r
         r = g.markdown_wiki.convert('[[projects labels=test,sub1]]')
-        assert '<img alt="test Logo"' not in r, r
-        assert '<img alt="sub1 Logo"' in r, r
+        assert '<img alt="Test Project Logo"' not in r, r
+        assert '<img alt="A Subproject Logo"' in r, r
         r = g.markdown_wiki.convert('[[projects labels=root|sub1]]')
-        assert '<img alt="test Logo"' in r, r
-        assert '<img alt="sub1 Logo"' in r, r
+        assert '<img alt="Test Project Logo"' in r, r
+        assert '<img alt="A Subproject Logo"' in r, r
         r = g.markdown_wiki.convert('[[projects labels=test,root|root,sub1]]')
-        assert '<img alt="test Logo"' in r, r
-        assert '<img alt="sub1 Logo"' not in r, r
+        assert '<img alt="Test Project Logo"' in r, r
+        assert '<img alt="A Subproject Logo"' not in r, r
         r = g.markdown_wiki.convert('[[projects labels=test,root|test,sub1]]')
-        assert '<img alt="test Logo"' in r, r
-        assert '<img alt="sub1 Logo"' in r, r
+        assert '<img alt="Test Project Logo"' in r, r
+        assert '<img alt="A Subproject Logo"' in r, r
         r = g.markdown_wiki.convert('[[projects show_total=True sort=random]]')
         assert '<p class="macro_projects_total">3 Projects</p>' in r, r
         r = g.markdown_wiki.convert('[[projects show_total=True private=True sort=random]]')
         assert '<p class="macro_projects_total">1 Projects</p>' in r, r
-        assert '<img alt="test2 Logo"' in r, r
-        assert '<img alt="test Logo"' not in r, r
-        assert '<img alt="sub1 Logo"' not in r, r
+        assert '<img alt="Test 2 Logo"' in r, r
+        assert '<img alt="Test Project Logo"' not in r, r
+        assert '<img alt="A Subproject Logo"' not in r, r
 
         r = g.markdown_wiki.convert('[[projects show_proj_icon=True]]')
-        assert '<img alt="test Logo"' in r
+        assert '<img alt="Test Project Logo"' in r
         r = g.markdown_wiki.convert('[[projects show_proj_icon=False]]')
-        assert '<img alt="test Logo"' not in r
+        assert '<img alt="Test Project Logo"' not in r
+
 
-    c.project = curr_project
-    r = g.markdown_wiki.convert('[[download_button]]')
+def test_macro_download_button():
+    p_nbhd = M.Neighborhood.query.get(name='Projects')
+    p_test = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
+    with h.push_config(c, project=p_test):
+        r = g.markdown_wiki.convert('[[download_button]]')
     assert_equal(r, '<div class="markdown_content"><p><span class="download-button-%s" style="margin-bottom: 1em; display: block;"></span></p>\n</div>' % p_test._id)
-    h.set_context('--init--', 'wiki', neighborhood='Projects')
-    r = g.markdown_wiki.convert('[[neighborhood_feeds tool_name=wiki]]')
-    assert 'Home modified by' in r, r
-    orig_len = len(r)
-    # Make project private & verify we don't see its new feed items
-    proj = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
-    c.user = M.User.anonymous()
-    proj.acl.insert(0, M.ACE.deny(
-            c.user.project_role(proj)._id, 'read'))
-    ThreadLocalORMSession.flush_all()
-    pg = WM.Page.query.get(title='Home', app_config_id=c.app.config._id)
-    pg.text = 'Change'
-    pg.commit()
-    r = g.markdown_wiki.convert('[[neighborhood_feeds tool_name=wiki]]')
-    new_len = len(r)
-    assert new_len == orig_len
-    p = BM.BlogPost(title='test me', neighborhood_id=p_test.neighborhood_id)
-    p.text = 'test content'
-    p.state = 'published'
-    p.make_slug()
-    p.commit()
-    ThreadLocalORMSession.flush_all()
-    r = g.markdown_wiki.convert('[[neighborhood_blog_posts]]')
-    assert 'test content' in r
+
+
+def test_macro_neighborhood_feeds():
+    p_nbhd = M.Neighborhood.query.get(name='Projects')
+    p_test = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
+    with h.push_context('--init--', 'wiki', neighborhood='Projects'):
+        r = g.markdown_wiki.convert('[[neighborhood_feeds tool_name=wiki]]')
+        assert 'Home modified by' in r, r
+        orig_len = len(r)
+        # Make project private & verify we don't see its new feed items
+        anon = M.User.anonymous()
+        p_test.acl.insert(0, M.ACE.deny(
+                anon.project_role(p_test)._id, 'read'))
+        ThreadLocalORMSession.flush_all()
+        pg = WM.Page.query.get(title='Home', app_config_id=c.app.config._id)
+        pg.text = 'Change'
+        with h.push_config(c, user=M.User.by_username('test-admin')):
+            pg.commit()
+        r = g.markdown_wiki.convert('[[neighborhood_feeds tool_name=wiki]]')
+        new_len = len(r)
+        assert new_len == orig_len
+        p = BM.BlogPost(title='test me', neighborhood_id=p_test.neighborhood_id)
+        p.text = 'test content'
+        p.state = 'published'
+        p.make_slug()
+        with h.push_config(c, user=M.User.by_username('test-admin')):
+            p.commit()
+        ThreadLocalORMSession.flush_all()
+        with h.push_config(c, user=anon):
+            r = g.markdown_wiki.convert('[[neighborhood_blog_posts]]')
+        assert 'test content' in r
 
 @with_setup(teardown=setUp) # reset everything we changed
 def test_macro_members():
@@ -196,7 +208,8 @@ def test_macro_members_escaping():
 def test_macro_project_admins():
     user = M.User.by_username('test-admin')
     user.display_name = u'Test Ã…dmin <script>'
-    r = g.markdown_wiki.convert('[[project_admins]]')
+    with h.push_context('test', neighborhood='Projects'):
+        r = g.markdown_wiki.convert('[[project_admins]]')
     assert_equal(r, u'<div class="markdown_content"><h6>Project Admins:</h6>\n<ul class="md-users-list">\n<li><a href="/u/test-admin/">Test \xc5dmin &lt;script&gt;</a></li>\n</ul>\n</div>')
 
 @with_setup(teardown=setUp) # reset everything we changed
@@ -205,7 +218,8 @@ def test_macro_project_admins_one_br():
     p_test = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
     p_test.add_user(M.User.by_username('test-user'), ['Admin'])
     ThreadLocalORMSession.flush_all()
-    r = g.markdown_wiki.convert('[[project_admins]]\n[[download_button]]')
+    with h.push_config(c, project=p_test):
+        r = g.markdown_wiki.convert('[[project_admins]]\n[[download_button]]')
 
     assert not '</a><br /><br /><a href=' in r, r
     assert '</a></li><li><a href=' in r, r
@@ -243,7 +257,8 @@ def test_macro_include_extra_br():
 
 
 def test_markdown_toc():
-    r = g.markdown_wiki.convert("""[TOC]
+    with h.push_context('test', neighborhood='Projects'):
+        r = g.markdown_wiki.convert("""[TOC]
 
 # Header 1
 
@@ -279,12 +294,14 @@ def test_markdown_links():
     assert_in('href="http://foobar.sf.net/">http://foobar.sf.net/</a> about', text)
 
 def test_markdown_and_html():
-    r = g.markdown_wiki.convert('<div style="float:left">blah</div>')
+    with h.push_context('test', neighborhood='Projects'):
+        r = g.markdown_wiki.convert('<div style="float:left">blah</div>')
     assert '<div style="float: left;">blah</div>' in r, r
 
 
 def test_markdown_within_html():
-    r = g.markdown_wiki.convert('<div style="float:left" markdown>**blah**</div>')
+    with h.push_context('test', neighborhood='Projects'):
+        r = g.markdown_wiki.convert('<div style="float:left" markdown>**blah**</div>')
     assert '''<div style="float: left;">
 <p><strong>blah</strong></p>
 </div>''' in r, r
@@ -355,13 +372,6 @@ def test_markdown_autolink_with_escape():
     assert 'href="http://www.phpmyadmin.net/home_page/security/#target"' in r, r
 
 
-def test_macro_projects():
-    r = g.markdown.convert('[[projects]]')
-    assert '[[projects]]' in r, r
-    with h.push_context(M.Neighborhood.query.get(name='Projects').neighborhood_project._id):
-        r = g.markdown_wiki.convert('[[projects]]')
-        assert '<div class="border card">' in r, r
-
 @td.with_wiki
 def test_macro_include():
     r = g.markdown.convert('[[include ref=Home id=foo]]')
@@ -410,23 +420,27 @@ def test_filtering():
     # set up for test
     from random import choice
     random_trove = choice(M.TroveCategory.query.find().all())
-    test_project = M.Project.query.get(name='test')
+    test_project = M.Project.query.get(shortname='test')
     test_project_troves = getattr(test_project, 'trove_' + random_trove.type)
     test_project_troves.append(random_trove._id)
     ThreadLocalORMSession.flush_all()
 
     p_nbhd = M.Neighborhood.query.get(name='Projects')
-    with h.push_context(p_nbhd.neighborhood_project._id):
+    with h.push_config(c,
+                       project=p_nbhd.neighborhood_project,
+                       user=M.User.by_username('test-admin')):
         r = g.markdown_wiki.convert('[[projects category="%s"]]' % random_trove.fullpath)
         project_names = get_project_names(r)
-        assert [test_project.name, ] == project_names
+        assert_equal([test_project.name], project_names)
 
 
 def test_projects_macro():
     two_column_style = 'width: 330px;'
 
     p_nbhd = M.Neighborhood.query.get(name='Projects')
-    with h.push_context(p_nbhd.neighborhood_project._id):
+    with h.push_config(c,
+                       project=p_nbhd.neighborhood_project,
+                       user=M.User.anonymous()):
         # test columns
         r = g.markdown_wiki.convert('[[projects display_mode=list columns=2]]')
         assert two_column_style in r
@@ -483,7 +497,7 @@ def test_hideawards_macro():
     award.full = u'Award full'
     award.created_by_neighborhood_id = p_nbhd._id
 
-    project = M.Project.query.get(neighborhood_id=p_nbhd._id, name=u'test')
+    project = M.Project.query.get(neighborhood_id=p_nbhd._id, shortname=u'test')
 
     award_grant = M.AwardGrant(award=award,
                                granted_by_neighborhood=p_nbhd,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/tests/test_mail_util.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_mail_util.py b/Allura/allura/tests/test_mail_util.py
index a80155e..bb22ac6 100644
--- a/Allura/allura/tests/test_mail_util.py
+++ b/Allura/allura/tests/test_mail_util.py
@@ -64,7 +64,7 @@ class TestReactor(unittest.TestCase):
     def test_parse_address_good(self):
         topic, project, app = parse_address('foo@wiki.test.p' + config.common_suffix)
         assert_equal(topic, 'foo')
-        assert_equal(project.name, 'test')
+        assert_equal(project.shortname, 'test')
         assert_equal(app.__class__.__name__, 'ForgeWikiApp')
 
     def test_unicode_simple_message(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/tests/unit/test_post_model.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_post_model.py b/Allura/allura/tests/unit/test_post_model.py
index bb1cbe0..9ac2256 100644
--- a/Allura/allura/tests/unit/test_post_model.py
+++ b/Allura/allura/tests/unit/test_post_model.py
@@ -15,6 +15,10 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+from pylons import tmpl_context as c
+
+from allura.lib import helpers as h
+from allura import model as M
 from allura.tests.unit import WithDatabase
 from allura.tests.unit import patches
 from allura.tests.unit.factories import create_post
@@ -32,6 +36,6 @@ class TestPostModel(WithDatabase):
         assert self.post.status == 'pending'
 
     def test_that_it_can_be_approved(self):
-        self.post.approve()
+        with h.push_config(c, user=M.User()):
+            self.post.approve()
         assert self.post.status == 'ok'
-

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2927da20/Allura/allura/websetup/bootstrap.py
----------------------------------------------------------------------
diff --git a/Allura/allura/websetup/bootstrap.py b/Allura/allura/websetup/bootstrap.py
index f518463..9d09927 100644
--- a/Allura/allura/websetup/bootstrap.py
+++ b/Allura/allura/websetup/bootstrap.py
@@ -35,6 +35,7 @@ from ming.orm.ormsession import ThreadLocalORMSession
 
 import allura
 from allura.lib import plugin
+from allura.lib import helpers as h
 from allura import model as M
 from allura.websetup import schema
 from allura.command import EnsureIndexCommand
@@ -87,7 +88,6 @@ def bootstrap(command, conf, vars):
         log.error('Error clearing solr index')
     if asbool(conf.get('cache_test_data')):
         if restore_test_data():
-            from allura.lib import helpers as h
             h.set_context('test', neighborhood='Projects')
             return
     log.info('Initializing search')
@@ -209,10 +209,8 @@ def bootstrap(command, conf, vars):
         # TODO: Hope that Ming can be improved to at least avoid stuff below
         sess.flush(x)
 
-    c.project = p0
-    c.user = u_admin
-    p1 = p0.new_subproject('sub1')
     ThreadLocalORMSession.flush_all()
+
     if asbool(conf.get('load_test_data')):
         if asbool(conf.get('cache_test_data')):
             cache_test_data()
@@ -220,10 +218,21 @@ def bootstrap(command, conf, vars):
         # regular first-time setup
         p0.add_user(u_admin, ['Admin'])
         log.info('Registering initial apps')
-        for ep_name, app in g.entry_points['tool'].iteritems():
-            if not app.installable:
-                continue
-            p0.install_app(ep_name)
+        with h.push_config(c, user=u_admin):
+            for ep_name, app in g.entry_points['tool'].iteritems():
+                if not app.installable:
+                    continue
+                p0.install_app(ep_name)
+
+    # reload our p0 project so that p0.app_configs is accurate with all the newly installed apps
+    ThreadLocalORMSession.flush_all()
+    ThreadLocalORMSession.close_all()
+    p0 = M.Project.query.get(_id=p0._id)
+    sub = p0.new_subproject('sub1', project_name='A Subproject')
+    with h.push_config(c, user=u_admin):
+        sub.install_app('wiki')
+
+
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
 


[05/16] git commit: [#6134] ticket:365 Sort the _members page

Posted by tv...@apache.org.
[#6134] ticket:365 Sort the _members page


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

Branch: refs/heads/cj/6218
Commit: 3fe4b3c1db2a41720f24da96ce5f8b78acaee799
Parents: d07ea1e
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Wed May 29 11:41:08 2013 +0400
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Jun 4 14:48:16 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/project.py        |   25 +++++++++++++++------
 Allura/allura/templates/members.html        |    2 +-
 Allura/allura/tests/functional/test_home.py |   22 +++++++++++++++++++
 3 files changed, 41 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3fe4b3c1/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index da39e5d..9436e87 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -340,16 +340,27 @@ class ProjectController(FeedController):
     @with_trailing_slash
     def _members(self, **kw):
         users = []
+        admins = []
+        developers = []
         for user in c.project.users():
             roles = M.ProjectRole.query.find({'_id': {'$in': user.project_role().roles}})
             roles = set([r.name for r in roles])
-            users.append(dict(
-                display_name=user.display_name,
-                username=user.username,
-                url=user.url(),
-                roles=roles,
-                ))
-        return dict(users=users)
+            u = dict(
+                    display_name=user.display_name,
+                    username=user.username,
+                    url=user.url(),
+                    roles=' '.join(sorted(roles)))
+            if 'Admin' in roles:
+                admins.append(u)
+            elif 'Developer' in roles:
+                developers.append(u)
+            else:
+                users.append(u)
+        get_username = lambda user: user['username']
+        admins = sorted(admins, key=get_username)
+        developers = sorted(developers, key=get_username)
+        users = sorted(users, key=get_username)
+        return dict(users=admins + developers + users)
 
     def _check_security(self):
         require_access(c.project, 'read')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3fe4b3c1/Allura/allura/templates/members.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/members.html b/Allura/allura/templates/members.html
index 2eac1d0..d455a93 100644
--- a/Allura/allura/templates/members.html
+++ b/Allura/allura/templates/members.html
@@ -35,7 +35,7 @@
     <tr>
         <td>{{ user.display_name }}</td>
         <td><a href="{{ user.url }}">{{ user.username }}</a></td>
-        <td>{{user.roles|join(', ')}}</td>
+        <td>{{user.roles}}</td>
     </tr>
     {%endfor%}
 </table>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3fe4b3c1/Allura/allura/tests/functional/test_home.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_home.py b/Allura/allura/tests/functional/test_home.py
index 73ff80c..aa9a684 100644
--- a/Allura/allura/tests/functional/test_home.py
+++ b/Allura/allura/tests/functional/test_home.py
@@ -23,6 +23,7 @@ from pylons import tmpl_context as c
 from allura.tests import TestController
 from allura.tests import decorators as td
 from allura import model as M
+from ming.orm import ThreadLocalORMSession
 
 from nose.tools import assert_equal, assert_not_in
 
@@ -105,10 +106,31 @@ class TestProjectHome(TestController):
         assert_equal(j['options'], expected)
 
     def test_members(self):
+        nbhd = M.Neighborhood.query.get(name='Projects')
+        self.app.post('/admin/groups/create', params={'name': 'B_role'})
+        test_project = M.Project.query.get(shortname='test', neighborhood_id=nbhd._id)
+        test_project.add_user(M.User.by_username('test-user-1'), ['B_role'])
+        test_project.add_user(M.User.by_username('test-user'), ['Developer'])
+        test_project.add_user(M.User.by_username('test-user-0'), ['Member'])
+        test_project.add_user(M.User.by_username('test-user-2'), ['Member'])
+        test_project.add_user(M.User.by_username('test-user-3'), ['Member'])
+        test_project.add_user(M.User.by_username('test-user-3'), ['Developer'])
+        test_project.add_user(M.User.by_username('test-user-4'), ['Admin'])
+        ThreadLocalORMSession.flush_all()
         r = self.app.get('/p/test/_members/')
+
         assert '<td>Test Admin</td>' in r
         assert '<td><a href="/u/test-admin/">test-admin</a></td>' in r
         assert '<td>Admin</td>' in r
+        tr = r.html.findAll('tr')
+        assert "<td>Test Admin</td>" in str(tr[1])
+        assert "<td>Test User 4</td>" in str(tr[2])
+        assert "<td>Test User</td>" in str(tr[3])
+        assert "<td>Test User 3</td>" in str(tr[4])
+        assert "<td>Test User 0</td>" in str(tr[5])
+        assert "<td>Test User 1</td>" in str(tr[6])
+        assert "<td>Test User 2</td>" in str(tr[7])
+
 
     def test_members_anonymous(self):
         r = self.app.get('/p/test/_members/', extra_environ=dict(username='*anonymous'))