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
@@ -113,7 +113,8 @@ class Neighborhood(MappedClass): | ||
113 | 113 | |
114 | 114 | @property |
115 | 115 | 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) | |
117 | 118 | |
118 | 119 | @property |
119 | 120 | def icon(self): |
@@ -515,6 +515,11 @@ class Project(MappedClass, ActivityNode, ActivityObject): | ||
515 | 515 | 'project_id':self._id, |
516 | 516 | 'options.mount_point':mount_point}).first() |
517 | 517 | |
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 | + | |
518 | 523 | def new_subproject(self, name, install_apps=True, user=None): |
519 | 524 | if not h.re_path_portion.match(name): |
520 | 525 | raise exceptions.ToolError, 'Mount point "%s" is invalid' % name |
@@ -1,4 +1,5 @@ | ||
1 | 1 | from nose.tools import assert_raises |
2 | +from ming.orm import ThreadLocalORMSession | |
2 | 3 | |
3 | 4 | from alluratest.controller import setup_basic_test, setup_global_objects |
4 | 5 | from allura.command import script, set_neighborhood_features, \ |
@@ -20,7 +21,6 @@ def setUp(self): | ||
20 | 21 | def test_script(): |
21 | 22 | cmd = script.ScriptCommand('script') |
22 | 23 | cmd.run([test_config, 'allura/tests/tscript.py' ]) |
23 | - cmd.command() | |
24 | 24 | assert_raises(ValueError, cmd.run, [test_config, 'allura/tests/tscript_error.py' ]) |
25 | 25 | |
26 | 26 | def test_set_neighborhood_max_projects(): |
@@ -30,13 +30,11 @@ def test_set_neighborhood_max_projects(): | ||
30 | 30 | |
31 | 31 | # a valid number |
32 | 32 | cmd.run([test_config, str(n_id), 'max_projects', '50']) |
33 | - cmd.command() | |
34 | 33 | neighborhood = M.Neighborhood.query.get(_id=n_id) |
35 | 34 | assert neighborhood.features['max_projects'] == 50 |
36 | 35 | |
37 | 36 | # none is also valid |
38 | 37 | cmd.run([test_config, str(n_id), 'max_projects', 'None']) |
39 | - cmd.command() | |
40 | 38 | neighborhood = M.Neighborhood.query.get(_id=n_id) |
41 | 39 | assert neighborhood.features['max_projects'] == None |
42 | 40 |
@@ -51,13 +49,11 @@ def test_set_neighborhood_private(): | ||
51 | 49 | |
52 | 50 | # allow private projects |
53 | 51 | cmd.run([test_config, str(n_id), 'private_projects', 'True']) |
54 | - cmd.command() | |
55 | 52 | neighborhood = M.Neighborhood.query.get(_id=n_id) |
56 | 53 | assert neighborhood.features['private_projects'] |
57 | 54 | |
58 | 55 | # disallow private projects |
59 | 56 | cmd.run([test_config, str(n_id), 'private_projects', 'False']) |
60 | - cmd.command() | |
61 | 57 | neighborhood = M.Neighborhood.query.get(_id=n_id) |
62 | 58 | assert not neighborhood.features['private_projects'] |
63 | 59 |
@@ -73,13 +69,11 @@ def test_set_neighborhood_google_analytics(): | ||
73 | 69 | |
74 | 70 | # allow private projects |
75 | 71 | cmd.run([test_config, str(n_id), 'google_analytics', 'True']) |
76 | - cmd.command() | |
77 | 72 | neighborhood = M.Neighborhood.query.get(_id=n_id) |
78 | 73 | assert neighborhood.features['google_analytics'] |
79 | 74 | |
80 | 75 | # disallow private projects |
81 | 76 | cmd.run([test_config, str(n_id), 'google_analytics', 'False']) |
82 | - cmd.command() | |
83 | 77 | neighborhood = M.Neighborhood.query.get(_id=n_id) |
84 | 78 | assert not neighborhood.features['google_analytics'] |
85 | 79 |
@@ -95,19 +89,16 @@ def test_set_neighborhood_css(): | ||
95 | 89 | |
96 | 90 | # none |
97 | 91 | cmd.run([test_config, str(n_id), 'css', 'none']) |
98 | - cmd.command() | |
99 | 92 | neighborhood = M.Neighborhood.query.get(_id=n_id) |
100 | 93 | assert neighborhood.features['css'] == 'none' |
101 | 94 | |
102 | 95 | # picker |
103 | 96 | cmd.run([test_config, str(n_id), 'css', 'picker']) |
104 | - cmd.command() | |
105 | 97 | neighborhood = M.Neighborhood.query.get(_id=n_id) |
106 | 98 | assert neighborhood.features['css'] == 'picker' |
107 | 99 | |
108 | 100 | # custom |
109 | 101 | cmd.run([test_config, str(n_id), 'css', 'custom']) |
110 | - cmd.command() | |
111 | 102 | neighborhood = M.Neighborhood.query.get(_id=n_id) |
112 | 103 | assert neighborhood.features['css'] == 'custom' |
113 | 104 |
@@ -121,12 +112,12 @@ def test_set_neighborhood_css(): | ||
121 | 112 | def test_update_neighborhood(): |
122 | 113 | cmd = create_neighborhood.UpdateNeighborhoodCommand('update-neighborhood') |
123 | 114 | cmd.run([test_config, 'Projects', 'True']) |
124 | - cmd.command() | |
115 | + ThreadLocalORMSession.close_all() # make sure the app_configs get freshly queried | |
125 | 116 | nb = M.Neighborhood.query.get(name='Projects') |
126 | 117 | assert nb.has_home_tool == True |
127 | 118 | |
128 | 119 | cmd = create_neighborhood.UpdateNeighborhoodCommand('update-neighborhood') |
129 | 120 | cmd.run([test_config, 'Projects', 'False']) |
130 | - cmd.command() | |
121 | + ThreadLocalORMSession.close_all() # make sure the app_configs get freshly queried | |
131 | 122 | nb = M.Neighborhood.query.get(name='Projects') |
132 | 123 | assert nb.has_home_tool == False |