• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


コミットメタ情報

リビジョン58e0e26cb0e09981fbc4cab89526332afe978679 (tree)
日時2012-07-10 02:48:56
作者Dave Brondsema <dbrondsema@geek...>
コミッターDave Brondsema

ログメッセージ

[#4457] update has_home_tool to check existing list. Remove extra cmd runs from tests

変更サマリ

差分

--- a/Allura/allura/model/neighborhood.py
+++ b/Allura/allura/model/neighborhood.py
@@ -113,7 +113,8 @@ class Neighborhood(MappedClass):
113113
114114 @property
115115 def has_home_tool(self):
116- return self.neighborhood_project.app_config('home') is not None
116+ return (self.neighborhood_project
117+ .app_config_by_tool_type('home') is not None)
117118
118119 @property
119120 def icon(self):
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -515,6 +515,11 @@ class Project(MappedClass, ActivityNode, ActivityObject):
515515 'project_id':self._id,
516516 'options.mount_point':mount_point}).first()
517517
518+ def app_config_by_tool_type(self, tool_type):
519+ for ac in self.app_configs:
520+ if ac.tool_name == tool_type:
521+ return ac
522+
518523 def new_subproject(self, name, install_apps=True, user=None):
519524 if not h.re_path_portion.match(name):
520525 raise exceptions.ToolError, 'Mount point "%s" is invalid' % name
--- a/Allura/allura/tests/test_commands.py
+++ b/Allura/allura/tests/test_commands.py
@@ -1,4 +1,5 @@
11 from nose.tools import assert_raises
2+from ming.orm import ThreadLocalORMSession
23
34 from alluratest.controller import setup_basic_test, setup_global_objects
45 from allura.command import script, set_neighborhood_features, \
@@ -20,7 +21,6 @@ def setUp(self):
2021 def test_script():
2122 cmd = script.ScriptCommand('script')
2223 cmd.run([test_config, 'allura/tests/tscript.py' ])
23- cmd.command()
2424 assert_raises(ValueError, cmd.run, [test_config, 'allura/tests/tscript_error.py' ])
2525
2626 def test_set_neighborhood_max_projects():
@@ -30,13 +30,11 @@ def test_set_neighborhood_max_projects():
3030
3131 # a valid number
3232 cmd.run([test_config, str(n_id), 'max_projects', '50'])
33- cmd.command()
3433 neighborhood = M.Neighborhood.query.get(_id=n_id)
3534 assert neighborhood.features['max_projects'] == 50
3635
3736 # none is also valid
3837 cmd.run([test_config, str(n_id), 'max_projects', 'None'])
39- cmd.command()
4038 neighborhood = M.Neighborhood.query.get(_id=n_id)
4139 assert neighborhood.features['max_projects'] == None
4240
@@ -51,13 +49,11 @@ def test_set_neighborhood_private():
5149
5250 # allow private projects
5351 cmd.run([test_config, str(n_id), 'private_projects', 'True'])
54- cmd.command()
5552 neighborhood = M.Neighborhood.query.get(_id=n_id)
5653 assert neighborhood.features['private_projects']
5754
5855 # disallow private projects
5956 cmd.run([test_config, str(n_id), 'private_projects', 'False'])
60- cmd.command()
6157 neighborhood = M.Neighborhood.query.get(_id=n_id)
6258 assert not neighborhood.features['private_projects']
6359
@@ -73,13 +69,11 @@ def test_set_neighborhood_google_analytics():
7369
7470 # allow private projects
7571 cmd.run([test_config, str(n_id), 'google_analytics', 'True'])
76- cmd.command()
7772 neighborhood = M.Neighborhood.query.get(_id=n_id)
7873 assert neighborhood.features['google_analytics']
7974
8075 # disallow private projects
8176 cmd.run([test_config, str(n_id), 'google_analytics', 'False'])
82- cmd.command()
8377 neighborhood = M.Neighborhood.query.get(_id=n_id)
8478 assert not neighborhood.features['google_analytics']
8579
@@ -95,19 +89,16 @@ def test_set_neighborhood_css():
9589
9690 # none
9791 cmd.run([test_config, str(n_id), 'css', 'none'])
98- cmd.command()
9992 neighborhood = M.Neighborhood.query.get(_id=n_id)
10093 assert neighborhood.features['css'] == 'none'
10194
10295 # picker
10396 cmd.run([test_config, str(n_id), 'css', 'picker'])
104- cmd.command()
10597 neighborhood = M.Neighborhood.query.get(_id=n_id)
10698 assert neighborhood.features['css'] == 'picker'
10799
108100 # custom
109101 cmd.run([test_config, str(n_id), 'css', 'custom'])
110- cmd.command()
111102 neighborhood = M.Neighborhood.query.get(_id=n_id)
112103 assert neighborhood.features['css'] == 'custom'
113104
@@ -121,12 +112,12 @@ def test_set_neighborhood_css():
121112 def test_update_neighborhood():
122113 cmd = create_neighborhood.UpdateNeighborhoodCommand('update-neighborhood')
123114 cmd.run([test_config, 'Projects', 'True'])
124- cmd.command()
115+ ThreadLocalORMSession.close_all() # make sure the app_configs get freshly queried
125116 nb = M.Neighborhood.query.get(name='Projects')
126117 assert nb.has_home_tool == True
127118
128119 cmd = create_neighborhood.UpdateNeighborhoodCommand('update-neighborhood')
129120 cmd.run([test_config, 'Projects', 'False'])
130- cmd.command()
121+ ThreadLocalORMSession.close_all() # make sure the app_configs get freshly queried
131122 nb = M.Neighborhood.query.get(name='Projects')
132123 assert nb.has_home_tool == False