incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#7260] only create all the trove categories during non-test bootstrap and the few tests that need it
Date Mon, 10 Mar 2014 22:37:59 GMT
Repository: incubator-allura
Updated Branches:
  refs/heads/db/7260 [created] 854af0994


[#7260] only create all the trove categories during non-test bootstrap and the few tests that
need it


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

Branch: refs/heads/db/7260
Commit: 854af0994340d97510534972f7c76294b06ebc0b
Parents: e1fc875
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Mon Mar 10 22:37:42 2014 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Mar 10 22:37:42 2014 +0000

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_admin.py        |  6 +++++-
 Allura/allura/tests/functional/test_auth.py         |  2 ++
 Allura/allura/tests/functional/test_neighborhood.py |  2 ++
 Allura/allura/tests/functional/test_root.py         |  2 ++
 .../allura/tests/functional/test_trovecategory.py   |  3 +++
 Allura/allura/tests/test_globals.py                 |  2 ++
 Allura/allura/websetup/bootstrap.py                 | 14 +++++++++-----
 AlluraTest/alluratest/controller.py                 | 16 +++++++++++-----
 ForgeUserStats/forgeuserstats/tests/test_model.py   | 10 +++++++++-
 9 files changed, 45 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/854af099/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 00a8b0d..156fd66 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -33,7 +33,7 @@ import mock
 
 from allura.tests import TestController
 from allura.tests import decorators as td
-from alluratest.controller import TestRestApiBase
+from alluratest.controller import TestRestApiBase, setup_trove_categories
 from allura import model as M
 from allura.app import SitemapEntry
 from allura.lib.plugin import AdminExtension
@@ -537,6 +537,8 @@ class TestProjectAdmin(TestController):
                 config['allow_project_delete'] = old_allow_project_delete
 
     def test_add_remove_trove_cat(self):
+        setup_trove_categories()
+
         r = self.app.get('/admin/trove')
         assert 'No Database Environment categories have been selected.' in r
         assert '<span class="trove_fullpath">Database Environment :: Database API</span>'
not in r
@@ -556,6 +558,8 @@ class TestProjectAdmin(TestController):
         assert '<span class="trove_fullpath">Database Environment :: Database API ::
Python Database API</span>' not in r
 
     def test_add_remove_label(self):
+        setup_trove_categories()
+
         r = self.app.get('/admin/trove')
         form = r.forms['label_edit_form']
         form['labels'].value = 'foo,bar,baz'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/854af099/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 3c0197a..c4a4f84 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -33,6 +33,7 @@ from nose.tools import (
 from pylons import tmpl_context as c
 from allura.tests import TestController
 from allura.tests import decorators as td
+from alluratest.controller import setup_trove_categories
 from allura import model as M
 from ming.orm.ormsession import ThreadLocalORMSession, session
 from tg import config, expose
@@ -543,6 +544,7 @@ class TestPreferences(TestController):
 
     @td.with_user_project('test-admin')
     def test_skills(self):
+        setup_trove_categories()
         # Add a skill
         skill_cat = M.TroveCategory.query.get(show_as_skill=True)
         level = 'low'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/854af099/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 8eabb72..a214166 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -31,6 +31,7 @@ from allura import model as M
 from allura.tests import TestController
 from allura.tests import decorators as td
 from allura.lib import helpers as h
+from alluratest.controller import setup_trove_categories
 
 
 class TestNeighborhood(TestController):
@@ -639,6 +640,7 @@ class TestNeighborhood(TestController):
             status=403)
 
     def test_project_template(self):
+        setup_trove_categories()
         icon_url = 'file://' + \
             os.path.join(allura.__path__[0], 'nf', 'allura',
                          'images', 'neo-icon-set-454545-256x350.png')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/854af099/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 0db57df..b498cd9 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -38,6 +38,7 @@ from allura.tests import decorators as td
 from allura.tests import TestController
 from allura import model as M
 from allura.lib.helpers import push_config
+from alluratest.controller import setup_trove_categories
 
 
 class TestRootController(TestController):
@@ -103,6 +104,7 @@ class TestRootController(TestController):
             response.html.findAll('a', {'href': '/adobe/adobe-2/'})) == 0
 
     def test_neighborhood_home(self):
+        setup_trove_categories()
         # Install home app
         nb = M.Neighborhood.query.get(name='Adobe')
         p = nb.neighborhood_project

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/854af099/Allura/allura/tests/functional/test_trovecategory.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_trovecategory.py b/Allura/allura/tests/functional/test_trovecategory.py
index b30b63a..3d68134 100644
--- a/Allura/allura/tests/functional/test_trovecategory.py
+++ b/Allura/allura/tests/functional/test_trovecategory.py
@@ -25,12 +25,15 @@ from bson.objectid import ObjectId
 from allura import model as M
 from allura.lib import helpers as h
 from allura.tests import TestController
+from alluratest.controller import setup_trove_categories
 
 
 class TestTroveCategory(TestController):
 
     @mock.patch('allura.model.project.g.post_event')
     def test_events(self, post_event):
+        setup_trove_categories()
+
         # Create event
         cfg = {'trovecategories.enableediting': 'true'}
         with h.push_config(config, **cfg):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/854af099/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index d8f6b52..7c4457e 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -36,6 +36,7 @@ from alluratest.controller import (
     setup_global_objects,
     setup_unit_test,
     setup_functional_test,
+    setup_trove_categories,
 )
 
 from allura import model as M
@@ -470,6 +471,7 @@ def test_sort_updated():
 def test_filtering():
     # set up for test
     from random import choice
+    setup_trove_categories()
     random_trove = choice(M.TroveCategory.query.find().all())
     test_project = M.Project.query.get(shortname='test')
     test_project_troves = getattr(test_project, 'trove_' + random_trove.type)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/854af099/Allura/allura/websetup/bootstrap.py
----------------------------------------------------------------------
diff --git a/Allura/allura/websetup/bootstrap.py b/Allura/allura/websetup/bootstrap.py
index 91c4fd9..91916df 100644
--- a/Allura/allura/websetup/bootstrap.py
+++ b/Allura/allura/websetup/bootstrap.py
@@ -91,6 +91,11 @@ def bootstrap(command, conf, vars):
     except:  # pragma no cover
         log.error('SOLR server is %s', g.solr_server)
         log.error('Error clearing solr index')
+
+    # set up mongo indexes
+    index = EnsureIndexCommand('ensure_index')
+    index.run([''])
+
     if asbool(conf.get('cache_test_data')):
         if restore_test_data():
             h.set_context('test', neighborhood='Projects')
@@ -231,6 +236,10 @@ def bootstrap(command, conf, vars):
             cache_test_data()
     else:  # pragma no cover
         # regular first-time setup
+
+        create_trove_categories = CreateTroveCategoriesCommand('create_trove_categories')
+        create_trove_categories.run([''])
+
         p0.add_user(u_admin, ['Admin'])
         log.info('Registering initial apps')
         with h.push_config(c, user=u_admin):
@@ -254,9 +263,6 @@ def bootstrap(command, conf, vars):
 
 def wipe_database():
     conn = M.main_doc_session.bind.conn
-    create_trove_categories = CreateTroveCategoriesCommand(
-        'create_trove_categories')
-    index = EnsureIndexCommand('ensure_index')
     if isinstance(conn, mim.Connection):
         clear_all_database_tables()
         for db in conn.database_names():
@@ -275,8 +281,6 @@ def wipe_database():
                     db.drop_collection(coll)
                 except:
                     pass
-    create_trove_categories.run([''])
-    index.run([''])
 
 
 def clear_all_database_tables():

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/854af099/AlluraTest/alluratest/controller.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/controller.py b/AlluraTest/alluratest/controller.py
index 7c772ed..0c9f1f3 100644
--- a/AlluraTest/alluratest/controller.py
+++ b/AlluraTest/alluratest/controller.py
@@ -36,6 +36,7 @@ import ming.orm
 import pkg_resources
 
 from allura import model as M
+from allura.command import CreateTroveCategoriesCommand
 import allura.lib.security
 from allura.lib.app_globals import Globals
 from allura.lib import helpers as h
@@ -89,11 +90,8 @@ def setup_basic_test(config=None, app_name=DFL_APP_NAME):
         conf_dir = os.getcwd()
     ew.TemplateEngine.initialize({})
     test_file = os.path.join(conf_dir, get_config_file(config))
-    with mock.patch.object(M.project.TroveCategoryMapperExtension, 'after_insert'),\
-         mock.patch.object(M.project.TroveCategoryMapperExtension, 'after_update'),\
-         mock.patch.object(M.project.TroveCategoryMapperExtension, 'after_delete'):
-        cmd = SetupCommand('setup-app')
-        cmd.run([test_file])
+    cmd = SetupCommand('setup-app')
+    cmd.run([test_file])
 
     # run all tasks, e.g. indexing from bootstrap operations
     while M.MonQTask.run_ready('setup'):
@@ -142,6 +140,14 @@ def setup_global_objects():
     c.user = M.User.query.get(username='test-admin')
 
 
+def setup_trove_categories():
+    create_trove_categories = CreateTroveCategoriesCommand('create_trove_categories')
+    with mock.patch.object(M.project.TroveCategoryMapperExtension, 'after_insert'),\
+         mock.patch.object(M.project.TroveCategoryMapperExtension, 'after_update'),\
+         mock.patch.object(M.project.TroveCategoryMapperExtension, 'after_delete'):
+        create_trove_categories.run([''])
+
+
 class TestController(object):
 
     application_under_test = 'main'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/854af099/ForgeUserStats/forgeuserstats/tests/test_model.py
----------------------------------------------------------------------
diff --git a/ForgeUserStats/forgeuserstats/tests/test_model.py b/ForgeUserStats/forgeuserstats/tests/test_model.py
index 08a38d0..fbda0f3 100644
--- a/ForgeUserStats/forgeuserstats/tests/test_model.py
+++ b/ForgeUserStats/forgeuserstats/tests/test_model.py
@@ -23,7 +23,7 @@ from pylons import tmpl_context as c
 from tg import config
 import mock
 
-from alluratest.controller import setup_basic_test, setup_global_objects
+from alluratest.controller import setup_basic_test, setup_global_objects, setup_trove_categories
 from allura.tests import decorators as td
 from allura.model import User, Project, TroveCategory
 from allura.lib import helpers as h
@@ -75,6 +75,8 @@ class TestUserStats(unittest.TestCase):
 
     @td.with_user_project('test-user-2')
     def test_create_artifact_stats(self):
+        setup_trove_categories()
+
         p = Project.query.get(shortname='u/test-user-2')
         topic = TroveCategory.query.get(shortname='scientific')
 
@@ -166,6 +168,8 @@ class TestUserStats(unittest.TestCase):
 
     @td.with_user_project('test-user-2')
     def test_modify_artifact_stats(self):
+        setup_trove_categories()
+        
         p = Project.query.get(shortname='u/test-user-2')
         topic = TroveCategory.query.get(shortname='scientific')
 
@@ -257,6 +261,8 @@ class TestUserStats(unittest.TestCase):
 
     @td.with_user_project('test-user-2')
     def test_ticket_stats(self):
+        setup_trove_categories()
+
         p = Project.query.get(shortname='u/test-user-2')
         topic = TroveCategory.query.get(shortname='scientific')
         create_time = datetime.utcnow() + timedelta(-5)
@@ -357,6 +363,8 @@ class TestUserStats(unittest.TestCase):
     @with_git
     @td.with_user_project('test-user-2')
     def test_commit_stats(self):
+        setup_trove_categories()
+
         p = Project.query.get(shortname='u/test-user-2')
         topic = TroveCategory.query.get(shortname='scientific')
         commit_time = datetime.utcnow() + timedelta(-1)


Mime
View raw message