allura
修訂 | a5b04ff06c696c7f9943bb192e512748f0c98620 (tree) |
---|---|
時間 | 2012-05-31 04:11:55 |
作者 | bolkimen <bolkimen@yaho...> |
Commiter | Yaroslav Luzin |
[#4208] ticket:65 fix test case
@@ -47,7 +47,7 @@ class UpdateNeighborhoodCommand(base.Command): | ||
47 | 47 | else: |
48 | 48 | home_tool_active = False |
49 | 49 | |
50 | - if home_tool_active == nb.have_home_project(): | |
50 | + if home_tool_active == nb.have_home_project: | |
51 | 51 | return |
52 | 52 | |
53 | 53 | p = nb.neighborhood_project |
@@ -90,7 +90,7 @@ class NeighborhoodController(object): | ||
90 | 90 | c.project = self.neighborhood.neighborhood_project |
91 | 91 | if self.neighborhood.redirect: |
92 | 92 | redirect(self.neighborhood.redirect) |
93 | - if not self.neighborhood.have_home_project(): | |
93 | + if not self.neighborhood.have_home_project: | |
94 | 94 | redirect(c.project.script_name + 'wiki/') |
95 | 95 | c.project_summary = W.project_summary |
96 | 96 | c.page_list = W.page_list |
@@ -108,6 +108,7 @@ class Neighborhood(MappedClass): | ||
108 | 108 | return self.css |
109 | 109 | return "" |
110 | 110 | |
111 | + @property | |
111 | 112 | def have_home_project(self): |
112 | 113 | if self.neighborhood_project.app_config('home') is not None: |
113 | 114 | return True |
@@ -5,12 +5,12 @@ | ||
5 | 5 | <div class="grid-14">{{widget.display_field(widget.fields.name)}}</div> |
6 | 6 | <label class="grid-4">Redirect</label> |
7 | 7 | <div class="grid-14">{{widget.display_field(widget.fields.redirect)}}</div> |
8 | - {% if value.have_home_project() %} | |
8 | + {% if value.have_home_project %} | |
9 | 9 | <label class="grid-4">Home Content (HTML)</label> |
10 | 10 | <div class="grid-14">{{widget.display_field(widget.fields.homepage)}}</div> |
11 | - {% endif %} | |
12 | 11 | <label class="grid-4">Allow Browsing</label> |
13 | 12 | <div class="grid-14">{{widget.display_field(widget.fields.allow_browse)}}</div> |
13 | + {% endif %} | |
14 | 14 | <label class="grid-4">Show Title</label> |
15 | 15 | <div class="grid-14">{{widget.display_field(widget.fields.show_title)}}</div> |
16 | 16 | {% if value.allow_custom_css %} |
@@ -8,6 +8,7 @@ import Image | ||
8 | 8 | from tg import config |
9 | 9 | from nose.tools import assert_equal |
10 | 10 | from ming.orm.ormsession import ThreadLocalORMSession |
11 | +from paste.httpexceptions import HTTPFound | |
11 | 12 | |
12 | 13 | import allura |
13 | 14 | from allura import model as M |
@@ -183,6 +184,8 @@ class TestNeighborhood(TestController): | ||
183 | 184 | neighborhood = M.Neighborhood.query.get(name='Adobe') |
184 | 185 | neighborhood.features['css'] = 'picker' |
185 | 186 | r = self.app.get('/adobe/') |
187 | + while isinstance(r.response, HTTPFound): | |
188 | + r = r.follow() | |
186 | 189 | assert test_css in r |
187 | 190 | r = self.app.get('/adobe/_admin/overview', extra_environ=dict(username='root')) |
188 | 191 | assert custom_css in r |
@@ -190,6 +193,8 @@ class TestNeighborhood(TestController): | ||
190 | 193 | neighborhood = M.Neighborhood.query.get(name='Adobe') |
191 | 194 | neighborhood.features['css'] = 'custom' |
192 | 195 | r = self.app.get('/adobe/') |
196 | + while isinstance(r.response, HTTPFound): | |
197 | + r = r.follow() | |
193 | 198 | assert test_css in r |
194 | 199 | r = self.app.get('/adobe/_admin/overview', extra_environ=dict(username='root')) |
195 | 200 | assert custom_css in r |
@@ -242,7 +247,8 @@ class TestNeighborhood(TestController): | ||
242 | 247 | params=dict(project_unixname='maxproject2', project_name='Max project2', project_description='', neighborhood='Projects'), |
243 | 248 | antispam=True, |
244 | 249 | extra_environ=dict(username='root')) |
245 | - r = r.follow() | |
250 | + while isinstance(r.response, HTTPFound): | |
251 | + r = r.follow() | |
246 | 252 | assert 'You have exceeded the maximum number of projects' in r |
247 | 253 | |
248 | 254 | def test_invite(self): |
@@ -619,6 +625,10 @@ class TestNeighborhood(TestController): | ||
619 | 625 | extra_environ=dict(username='root')) |
620 | 626 | |
621 | 627 | def test_add_a_project_link(self): |
628 | + # Install Home tool for all neighborhoods | |
629 | + for nb in M.Neighborhood.query.find().all(): | |
630 | + p = nb.neighborhood_project | |
631 | + p.install_app('home', 'home', 'Home', ordinal=0) | |
622 | 632 | r = self.app.get('/p/') |
623 | 633 | assert 'Add a Project' in r |
624 | 634 | r = self.app.get('/u/', extra_environ=dict(username='test-user')) |
@@ -60,7 +60,12 @@ class TestRootController(TestController): | ||
60 | 60 | assert len(response.html.findAll('a',{'href':'/adobe/adobe-1/'})) == 0 |
61 | 61 | assert len(response.html.findAll('a',{'href':'/adobe/adobe-2/'})) == 0 |
62 | 62 | |
63 | - def test_neighborhood_index(self): | |
63 | + def test_neighborhood_home(self): | |
64 | + # Install home app | |
65 | + nb = M.Neighborhood.query.get(name='Adobe') | |
66 | + p = nb.neighborhood_project | |
67 | + p.install_app('home', 'home', 'Home', ordinal=0) | |
68 | + | |
64 | 69 | response = self.app.get('/adobe/') |
65 | 70 | projects = response.html.findAll('div',{'class':'border card'}) |
66 | 71 | assert len(projects) == 2 |
@@ -92,4 +97,4 @@ class TestRootController(TestController): | ||
92 | 97 | |
93 | 98 | def test_slash_redirect(self): |
94 | 99 | r = self.app.get('/p',status=301) |
95 | - r = self.app.get('/p/',status=200) | |
100 | + r = self.app.get('/p/',status=302) |
@@ -143,10 +143,10 @@ def test_update_neighborhood(): | ||
143 | 143 | cmd.run([test_config, 'Projects', 'True']) |
144 | 144 | cmd.command() |
145 | 145 | nb = M.Neighborhood.query.get(name='Projects') |
146 | - assert nb.have_home_project() == True | |
146 | + assert nb.have_home_project == True | |
147 | 147 | |
148 | 148 | cmd = create_neighborhood.UpdateNeighborhoodCommand('update-neighborhood') |
149 | 149 | cmd.run([test_config, 'Projects', 'False']) |
150 | 150 | cmd.command() |
151 | 151 | nb = M.Neighborhood.query.get(name='Projects') |
152 | - assert nb.have_home_project() == False | |
152 | + assert nb.have_home_project == False |