incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [49/50] git commit: [#6007] Better installation of subproject in bootstrap. Don't leave a c.user/project
Date Fri, 24 May 2013 18:18:25 GMT
[#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/6cd81112
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/6cd81112
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/6cd81112

Branch: refs/heads/db/6007
Commit: 6cd8111275908fc88b4607dc01787425f5371b52
Parents: 76884ad
Author: Dave Brondsema <dbrondsema@geek.net>
Authored: Mon Mar 25 14:39:49 2013 -0700
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri May 24 13:26:15 2013 -0400

----------------------------------------------------------------------
 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/6cd81112/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/6cd81112/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/6cd81112/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/6cd81112/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index da36ada..c1f5242 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -618,11 +618,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/6cd81112/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/6cd81112/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 3e11437..03e6860 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'}
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'}
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/6cd81112/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 1d7db26..8a53896 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/6cd81112/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/6cd81112/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/6cd81112/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/6cd81112/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/6cd81112/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/6cd81112/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()
 


Mime
View raw message