allura
Révision | e5b93e1069d751591ce1dbd19b42cc6b1938a5f0 (tree) |
---|---|
l'heure | 2012-01-07 04:23:40 |
Auteur | Tim Van Steenburgh <tvansteenburgh@geek...> |
Commiter | Tim Van Steenburgh |
[#3417] Only install tools needed for tests.
Signed-off-by: Tim Van Steenburgh <tvansteenburgh@geek.net>
@@ -0,0 +1,47 @@ | ||
1 | +from functools import wraps | |
2 | + | |
3 | +from allura import model as M | |
4 | + | |
5 | +from ming.orm.ormsession import ThreadLocalORMSession | |
6 | + | |
7 | +from pylons import c | |
8 | + | |
9 | + | |
10 | +def with_tool(project_shortname, ep_name, mount_point=None, mount_label=None, | |
11 | + ordinal=None, post_install_hook=None, **override_options): | |
12 | + def _with_tool(func): | |
13 | + @wraps(func) | |
14 | + def wrapped(*args, **kw): | |
15 | + c.user = M.User.by_username('test-admin') | |
16 | + p = M.Project.query.get(shortname=project_shortname) | |
17 | + c.project = p | |
18 | + if mount_point and not p.app_instance(mount_point): | |
19 | + c.app = p.install_app(ep_name, mount_point, mount_label, ordinal, **override_options) | |
20 | + if post_install_hook: | |
21 | + post_install_hook(c.app) | |
22 | + while M.MonQTask.run_ready('setup'): | |
23 | + pass | |
24 | + ThreadLocalORMSession.flush_all() | |
25 | + ThreadLocalORMSession.close_all() | |
26 | + elif mount_point: | |
27 | + c.app = p.app_instance(mount_point) | |
28 | + return func(*args, **kw) | |
29 | + return wrapped | |
30 | + return _with_tool | |
31 | + | |
32 | +with_discussion = with_tool('test', 'Discussion', 'discussion') | |
33 | +with_link = with_tool('test', 'Link', 'link') | |
34 | +with_tracker = with_tool('test', 'Tickets', 'bugs') | |
35 | +with_wiki = with_tool('test', 'Wiki', 'wiki') | |
36 | +with_git = with_tool('test', 'Git', 'src-git', 'Git', type='git') | |
37 | +with_hg = with_tool('test', 'Hg', 'src-hg', 'Mercurial', type='hg') | |
38 | +with_svn = with_tool('test', 'SVN', 'src', 'SVN') | |
39 | + | |
40 | +def with_repos(func): | |
41 | + @wraps(func) | |
42 | + @with_git | |
43 | + @with_hg | |
44 | + @with_svn | |
45 | + def wrapped(*args, **kw): | |
46 | + return func(*args, **kw) | |
47 | + return wrapped |
@@ -2,9 +2,7 @@ import os, allura | ||
2 | 2 | import pkg_resources |
3 | 3 | import Image, StringIO |
4 | 4 | |
5 | -from nose.tools import assert_equals, assert_true | |
6 | -from pylons import g, c | |
7 | - | |
5 | +from nose.tools import assert_equals | |
8 | 6 | from ming.orm.ormsession import ThreadLocalORMSession |
9 | 7 | |
10 | 8 | try: |
@@ -13,9 +11,8 @@ except ImportError: | ||
13 | 11 | sfx = None |
14 | 12 | |
15 | 13 | from allura.tests import TestController |
14 | +from allura.tests import decorators as td | |
16 | 15 | from allura import model as M |
17 | -from allura.lib import helpers as h | |
18 | - | |
19 | 16 | |
20 | 17 | class TestProjectAdmin(TestController): |
21 | 18 |
@@ -443,6 +440,7 @@ class TestProjectAdmin(TestController): | ||
443 | 440 | r = self.app.get('/admin/groups/') |
444 | 441 | assert 'test-user' not in str(r), r.showbrowser() |
445 | 442 | |
443 | + @td.with_wiki | |
446 | 444 | def test_new_group(self): |
447 | 445 | r = self.app.get('/admin/groups/new', validate_chunk=True) |
448 | 446 | r = self.app.post('/admin/groups/create', params={'name': 'Developer'}) |
@@ -3,8 +3,8 @@ import json | ||
3 | 3 | from datadiff.tools import assert_equal |
4 | 4 | |
5 | 5 | from allura.tests import TestController |
6 | +from allura.tests import decorators as td | |
6 | 7 | from allura import model as M |
7 | -from allura.lib import helpers as h | |
8 | 8 | from ming.orm.ormsession import ThreadLocalORMSession |
9 | 9 | |
10 | 10 |
@@ -157,6 +157,7 @@ class TestAuth(TestController): | ||
157 | 157 | # Make sure that default _lookup() throws 404 |
158 | 158 | self.app.get('/auth/foobar', status=404) |
159 | 159 | |
160 | + @td.with_svn | |
160 | 161 | def test_refresh_repo(self): |
161 | 162 | r = self.app.get('/auth/refresh_repo') |
162 | 163 | assert_equal(r.body, 'No repo specified') |
@@ -185,22 +186,26 @@ class TestUserPermissions(TestController): | ||
185 | 186 | r = self._check_repo('/git/test/bar') |
186 | 187 | assert r == self.disallow, r |
187 | 188 | |
189 | + @td.with_svn | |
188 | 190 | def test_repo_write(self): |
189 | 191 | r = self._check_repo('/git/test/src.git') |
190 | 192 | assert r == self.allow, r |
191 | 193 | r = self._check_repo('/git/test/src') |
192 | 194 | assert r == self.allow, r |
193 | 195 | |
196 | + @td.with_svn | |
194 | 197 | def test_subdir(self): |
195 | 198 | r = self._check_repo('/git/test/src.git/foo') |
196 | 199 | assert r == self.allow, r |
197 | 200 | r = self._check_repo('/git/test/src/foo') |
198 | 201 | assert r == self.allow, r |
199 | 202 | |
203 | + @td.with_svn | |
200 | 204 | def test_neighborhood(self): |
201 | 205 | r = self._check_repo('/git/test.p/src.git') |
202 | 206 | assert r == self.allow, r |
203 | 207 | |
208 | + @td.with_svn | |
204 | 209 | def test_repo_read(self): |
205 | 210 | r = self._check_repo( |
206 | 211 | '/git/test.p/src.git', |
@@ -223,6 +228,7 @@ class TestUserPermissions(TestController): | ||
223 | 228 | except: |
224 | 229 | return r |
225 | 230 | |
231 | + @td.with_repos | |
226 | 232 | def test_list_repos(self): |
227 | 233 | r = self.app.get('/auth/repo_permissions', params=dict(username='test-admin'), status=200) |
228 | 234 | assert_equal(json.loads(r.body), {"allow_write": [ |
@@ -1,15 +1,16 @@ | ||
1 | -from pylons import g | |
2 | 1 | from formencode.variabledecode import variable_encode |
3 | 2 | |
4 | -from ming.orm.ormsession import ThreadLocalORMSession | |
5 | - | |
6 | 3 | from allura.tests import TestController |
7 | -from allura import model as M | |
4 | +from allura.tests import decorators as td | |
8 | 5 | |
9 | 6 | class TestFeeds(TestController): |
10 | - | |
11 | 7 | def setUp(self): |
12 | 8 | TestController.setUp(self) |
9 | + self._setUp() | |
10 | + | |
11 | + @td.with_wiki | |
12 | + @td.with_tracker | |
13 | + def _setUp(self): | |
13 | 14 | self.app.get('/wiki/') |
14 | 15 | self.app.get('/bugs/') |
15 | 16 | self.app.post( |
@@ -39,10 +40,12 @@ class TestFeeds(TestController): | ||
39 | 40 | self.app.get('/feed.rss') |
40 | 41 | self.app.get('/feed.atom') |
41 | 42 | |
43 | + @td.with_wiki | |
42 | 44 | def test_wiki_feed(self): |
43 | 45 | self.app.get('/wiki/feed.rss') |
44 | 46 | self.app.get('/wiki/feed.atom') |
45 | 47 | |
48 | + @td.with_wiki | |
46 | 49 | def test_wiki_page_feed(self): |
47 | 50 | self.app.post('/wiki/Root/update', params={ |
48 | 51 | 'title':'Root', |
@@ -53,10 +56,12 @@ class TestFeeds(TestController): | ||
53 | 56 | self.app.get('/wiki/Root/feed.rss') |
54 | 57 | self.app.get('/wiki/Root/feed.atom') |
55 | 58 | |
59 | + @td.with_tracker | |
56 | 60 | def test_ticket_list_feed(self): |
57 | 61 | self.app.get('/bugs/feed.rss') |
58 | 62 | self.app.get('/bugs/feed.atom') |
59 | 63 | |
64 | + @td.with_tracker | |
60 | 65 | def test_ticket_feed(self): |
61 | 66 | self.app.get('/bugs/1/feed.rss') |
62 | 67 | r = self.app.get('/bugs/1/feed.atom') |
@@ -1,15 +1,13 @@ | ||
1 | 1 | import json |
2 | -from pylons import g | |
3 | -from formencode.variabledecode import variable_encode | |
4 | - | |
5 | -from ming.orm.ormsession import ThreadLocalORMSession | |
6 | 2 | |
7 | 3 | from allura.tests import TestController |
4 | +from allura.tests import decorators as td | |
8 | 5 | from allura import model as M |
9 | 6 | |
10 | 7 | |
11 | 8 | class TestProjectHome(TestController): |
12 | 9 | |
10 | + @td.with_wiki | |
13 | 11 | def test_project_nav(self): |
14 | 12 | response = self.app.get('/p/test/_nav.json') |
15 | 13 | root = self.app.get('/p/test/wiki/').follow() |
@@ -18,6 +16,7 @@ class TestProjectHome(TestController): | ||
18 | 16 | for nl, entry in zip(nav_links, response.json['menu']): |
19 | 17 | assert nl['href'] == entry['url'] |
20 | 18 | |
19 | + @td.with_wiki | |
21 | 20 | def test_neighborhood_home(self): |
22 | 21 | self.app.get('/p/test/wiki/', status=302) |
23 | 22 | self.app.get('/adobe/test/wiki/', status=404) |
@@ -4,14 +4,11 @@ from cStringIO import StringIO | ||
4 | 4 | |
5 | 5 | import Image |
6 | 6 | from tg import config |
7 | -from pylons import g, c | |
8 | - | |
9 | -from ming.orm.ormsession import ThreadLocalORMSession | |
10 | 7 | |
11 | 8 | import allura |
12 | 9 | from allura import model as M |
13 | 10 | from allura.tests import TestController |
14 | - | |
11 | +from allura.tests import decorators as td | |
15 | 12 | |
16 | 13 | class TestNeighborhood(TestController): |
17 | 14 |
@@ -330,6 +327,7 @@ class TestNeighborhood(TestController): | ||
330 | 327 | r = self.app.get('/p/check_name?project_name=test') |
331 | 328 | assert r.json['message'] == 'This project name is taken.' |
332 | 329 | |
330 | + @td.with_tool('test/sub1', 'Wiki', 'wiki') | |
333 | 331 | def test_neighborhood_project(self): |
334 | 332 | self.app.get('/adobe/adobe-1/admin/', status=200) |
335 | 333 | self.app.get('/p/test/sub1/wiki/') |
@@ -1,14 +1,7 @@ | ||
1 | -from pprint import pprint | |
2 | 1 | from datetime import datetime, timedelta |
3 | -import json | |
4 | - | |
5 | -from pylons import c | |
6 | -from ming.orm import session | |
7 | - | |
8 | -from allura import model as M | |
9 | -from allura.lib import helpers as h | |
10 | -from alluratest.controller import TestController, TestRestApiBase | |
11 | 2 | |
3 | +from allura.tests import decorators as td | |
4 | +from alluratest.controller import TestRestApiBase | |
12 | 5 | |
13 | 6 | class TestRestHome(TestRestApiBase): |
14 | 7 |
@@ -36,11 +29,13 @@ class TestRestHome(TestRestApiBase): | ||
36 | 29 | r = self.api_post('/rest/p/test/admin/') |
37 | 30 | assert r.status_int == 404 |
38 | 31 | |
32 | + @td.with_wiki | |
39 | 33 | def test_project_ping(self): |
40 | 34 | r = self.api_get('/rest/p/test/wiki/Home/') |
41 | 35 | assert r.status_int == 200 |
42 | 36 | assert r.json['title'] == 'Home', r.json |
43 | 37 | |
38 | + @td.with_tool('test/sub1', 'Wiki', 'wiki') | |
44 | 39 | def test_subproject_ping(self): |
45 | 40 | r = self.api_get('/rest/p/test/sub1/wiki/Home/') |
46 | 41 | assert r.status_int == 200 |
@@ -1,13 +1,10 @@ | ||
1 | -from pprint import pprint | |
2 | 1 | from datetime import datetime, timedelta |
3 | -import json | |
4 | 2 | |
5 | -from pylons import c | |
6 | 3 | from ming.orm import session |
7 | 4 | |
8 | 5 | from allura import model as M |
9 | -from allura.lib import helpers as h | |
10 | -from alluratest.controller import TestController, TestRestApiBase | |
6 | +from allura.tests import decorators as td | |
7 | +from alluratest.controller import TestRestApiBase | |
11 | 8 | |
12 | 9 | |
13 | 10 | class TestApiTicket(TestRestApiBase): |
@@ -49,6 +46,7 @@ class TestApiTicket(TestRestApiBase): | ||
49 | 46 | r = self.api_post('/rest/p/test/admin/') |
50 | 47 | assert r.status_int == 404 |
51 | 48 | |
49 | + @td.with_wiki | |
52 | 50 | def test_project_ping(self): |
53 | 51 | self.set_api_ticket() |
54 | 52 | r = self.api_get('/rest/p/test/wiki/Home/') |
@@ -60,6 +58,7 @@ class TestApiTicket(TestRestApiBase): | ||
60 | 58 | r = self.api_post('/rest/p/test/wiki/') |
61 | 59 | assert r.status_int == 403 |
62 | 60 | |
61 | + @td.with_tool('test/sub1', 'Wiki', 'wiki') | |
63 | 62 | def test_subproject_ping(self): |
64 | 63 | self.set_api_ticket() |
65 | 64 | r = self.api_get('/rest/p/test/sub1/wiki/Home/') |
@@ -12,12 +12,11 @@ Please read http://pythonpaste.org/webtest/ for more information. | ||
12 | 12 | """ |
13 | 13 | from urllib import quote |
14 | 14 | |
15 | -from nose.tools import assert_true, assert_equal | |
15 | +from nose.tools import assert_equal | |
16 | 16 | |
17 | +from allura.tests import decorators as td | |
17 | 18 | from allura.tests import TestController |
18 | 19 | from allura import model as M |
19 | -from ming.orm import session | |
20 | - | |
21 | 20 | |
22 | 21 | class TestRootController(TestController): |
23 | 22 |
@@ -89,6 +88,7 @@ class TestRootController(TestController): | ||
89 | 88 | assert len(response.html.findAll('img',{'alt':'adobe-1 Logo'})) == 0 |
90 | 89 | assert len(response.html.findAll('img',{'alt':'adobe-2 Logo'})) == 1 |
91 | 90 | |
91 | + @td.with_wiki | |
92 | 92 | def test_markdown_to_html(self): |
93 | 93 | n = M.Neighborhood.query.get(name='Projects') |
94 | 94 | r = self.app.get('/nf/markdown_to_html?markdown=*aaa*bb[wiki:Home]&project=test&app=bugs&neighborhood=%s' % n._id, validate_chunk=True) |
@@ -1,8 +1,8 @@ | ||
1 | 1 | from formencode.variabledecode import variable_encode |
2 | 2 | |
3 | +from allura.tests import decorators as td | |
3 | 4 | from allura.tests import TestController |
4 | 5 | |
5 | - | |
6 | 6 | class TestUserProfile(TestController): |
7 | 7 | |
8 | 8 | def test_profile(self): |
@@ -28,6 +28,7 @@ class TestUserProfile(TestController): | ||
28 | 28 | response = self.app.get('/u/test-user/profile/') |
29 | 29 | assert 'Email Addresses' not in response |
30 | 30 | |
31 | + @td.with_wiki | |
31 | 32 | def test_feed(self): |
32 | 33 | response = self.app.get('/u/test-admin/profile/feed') |
33 | 34 | assert 'Recent posts by Test Admin' in response |
@@ -16,6 +16,7 @@ import allura | ||
16 | 16 | from allura import model as M |
17 | 17 | from allura.lib import helpers as h |
18 | 18 | from allura.lib import security |
19 | +from allura.tests import decorators as td | |
19 | 20 | from allura.websetup.schema import REGISTRY |
20 | 21 | from alluratest.controller import setup_basic_test, setup_unit_test |
21 | 22 | from forgewiki import model as WM |
@@ -34,6 +35,10 @@ Mapper.compile_all() | ||
34 | 35 | def setUp(): |
35 | 36 | setup_basic_test() |
36 | 37 | setup_unit_test() |
38 | + setup_with_tools() | |
39 | + | |
40 | +@td.with_wiki | |
41 | +def setup_with_tools(): | |
37 | 42 | h.set_context('test', 'wiki', neighborhood='Projects') |
38 | 43 | Checkmessage.query.remove({}) |
39 | 44 | WM.Page.query.remove({}) |
@@ -8,12 +8,17 @@ from ming.orm import ThreadLocalORMSession | ||
8 | 8 | from alluratest.controller import setup_basic_test, setup_global_objects, REGISTRY |
9 | 9 | from allura import model as M |
10 | 10 | from allura.lib import helpers as h |
11 | +from allura.tests import decorators as td | |
11 | 12 | from forgewiki import model as WM |
12 | 13 | |
13 | 14 | class TestNotification(unittest.TestCase): |
14 | 15 | |
15 | 16 | def setUp(self): |
16 | 17 | setup_basic_test() |
18 | + self.setup_with_tools() | |
19 | + | |
20 | + @td.with_wiki | |
21 | + def setup_with_tools(self): | |
17 | 22 | setup_global_objects() |
18 | 23 | _clear_subscriptions() |
19 | 24 | _clear_notifications() |
@@ -46,6 +51,10 @@ class TestPostNotifications(unittest.TestCase): | ||
46 | 51 | |
47 | 52 | def setUp(self): |
48 | 53 | setup_basic_test() |
54 | + self.setup_with_tools() | |
55 | + | |
56 | + @td.with_wiki | |
57 | + def setup_with_tools(self): | |
49 | 58 | setup_global_objects() |
50 | 59 | g.set_app('wiki') |
51 | 60 | _clear_subscriptions() |
@@ -147,6 +156,10 @@ class TestSubscriptionTypes(unittest.TestCase): | ||
147 | 156 | |
148 | 157 | def setUp(self): |
149 | 158 | setup_basic_test() |
159 | + self.setup_with_tools() | |
160 | + | |
161 | + @td.with_wiki | |
162 | + def setup_with_tools(self): | |
150 | 163 | setup_global_objects() |
151 | 164 | g.set_app('wiki') |
152 | 165 | _clear_subscriptions() |
@@ -2,22 +2,22 @@ | ||
2 | 2 | """ |
3 | 3 | Model tests for project |
4 | 4 | """ |
5 | -from datetime import datetime | |
6 | - | |
7 | -import mock | |
8 | 5 | from nose.tools import with_setup |
9 | -from pylons import c, g, request | |
10 | -from webob import Request | |
6 | +from pylons import c | |
11 | 7 | from ming.orm.ormsession import ThreadLocalORMSession |
12 | 8 | |
13 | 9 | from allura import model as M |
14 | -from allura.lib.app_globals import Globals | |
15 | 10 | from allura.lib import helpers as h |
11 | +from allura.tests import decorators as td | |
16 | 12 | from alluratest.controller import setup_basic_test, setup_global_objects |
17 | 13 | |
18 | 14 | |
19 | 15 | def setUp(): |
20 | 16 | setup_basic_test() |
17 | + setup_with_tools() | |
18 | + | |
19 | +@td.with_wiki | |
20 | +def setup_with_tools(): | |
21 | 21 | setup_global_objects() |
22 | 22 | |
23 | 23 | @with_setup(setUp) |
@@ -3,11 +3,12 @@ from urllib import quote | ||
3 | 3 | from nose.tools import with_setup, assert_equal |
4 | 4 | from pylons import g, c |
5 | 5 | |
6 | -from ming.orm import session, ThreadLocalORMSession | |
6 | +from ming.orm import ThreadLocalORMSession | |
7 | 7 | from alluratest.controller import setup_basic_test, setup_global_objects |
8 | 8 | |
9 | 9 | from allura import model as M |
10 | 10 | from allura.lib import helpers as h |
11 | +from allura.tests import decorators as td | |
11 | 12 | |
12 | 13 | from forgewiki import model as WM |
13 | 14 | from forgeblog import model as BM |
@@ -16,8 +17,13 @@ from forgeblog import model as BM | ||
16 | 17 | def setUp(): |
17 | 18 | """Method called by nose before running each test""" |
18 | 19 | setup_basic_test() |
20 | + setup_with_tools() | |
21 | + | |
22 | +@td.with_wiki | |
23 | +def setup_with_tools(): | |
19 | 24 | setup_global_objects() |
20 | 25 | |
26 | +@td.with_wiki | |
21 | 27 | def test_app_globals(): |
22 | 28 | g.oid_session() |
23 | 29 | g.oid_session() |
@@ -1,14 +1,11 @@ | ||
1 | -from os import path, environ | |
1 | +from os import path | |
2 | 2 | |
3 | -from tg import config | |
4 | -from pylons import c, g | |
5 | -from paste.deploy import loadapp | |
6 | -from paste.script.appinstall import SetupCommand | |
3 | +from pylons import c | |
7 | 4 | from nose.tools import eq_, assert_equals |
8 | 5 | |
9 | 6 | from allura import model as M |
10 | 7 | from allura.lib import helpers as h |
11 | - | |
8 | +from allura.tests import decorators as td | |
12 | 9 | from alluratest.controller import setup_basic_test |
13 | 10 | |
14 | 11 |
@@ -51,6 +48,7 @@ def test_make_roles(): | ||
51 | 48 | pr = u.project_role() |
52 | 49 | assert h.make_roles([pr._id]).next() == pr |
53 | 50 | |
51 | +@td.with_wiki | |
54 | 52 | def test_context_setters(): |
55 | 53 | h.set_context('test', 'wiki', neighborhood='Projects') |
56 | 54 | assert c.project is not None |
@@ -2,10 +2,7 @@ | ||
2 | 2 | import unittest |
3 | 3 | from email.MIMEMultipart import MIMEMultipart |
4 | 4 | from email.MIMEText import MIMEText |
5 | -from email import header | |
6 | -from email.parser import Parser | |
7 | 5 | |
8 | -import tg | |
9 | 6 | from nose.tools import raises, assert_equal |
10 | 7 | from ming.orm import ThreadLocalORMSession |
11 | 8 |
@@ -14,7 +11,7 @@ from allura.lib.utils import ConfigProxy | ||
14 | 11 | |
15 | 12 | from allura.lib.mail_util import parse_address, parse_message |
16 | 13 | from allura.lib.exceptions import AddressException |
17 | -from allura.tasks.mail_tasks import route_email | |
14 | +from allura.tests import decorators as td | |
18 | 15 | |
19 | 16 | config = ConfigProxy( |
20 | 17 | common_suffix='forgemail.domain', |
@@ -44,6 +41,7 @@ class TestReactor(unittest.TestCase): | ||
44 | 41 | def test_parse_address_bad_tool(self): |
45 | 42 | parse_address('foo@hammer.test.p' + config.common_suffix) |
46 | 43 | |
44 | + @td.with_wiki | |
47 | 45 | def test_parse_address_good(self): |
48 | 46 | topic, project, app = parse_address('foo@wiki.test.p' + config.common_suffix) |
49 | 47 | assert_equal(topic, 'foo') |
@@ -1,21 +1,18 @@ | ||
1 | -from unittest import TestCase | |
2 | -from allura import model as M | |
3 | -from allura.lib import plugin | |
4 | - | |
1 | +from allura.tests import decorators as td | |
5 | 2 | from allura.tests import TestController |
6 | 3 | |
7 | -from alluratest.controller import setup_basic_test, setup_unit_test | |
8 | - | |
9 | 4 | class TestSecurity(TestController): |
10 | 5 | |
11 | 6 | validate_skip = True |
12 | 7 | |
8 | + @td.with_wiki | |
13 | 9 | def test_anon(self): |
14 | 10 | self.app.get('/security/*anonymous/forbidden', status=302) |
15 | 11 | self.app.get('/security/*anonymous/needs_auth', status=302) |
16 | 12 | self.app.get('/security/*anonymous/needs_project_access_fail', status=302) |
17 | 13 | self.app.get('/security/*anonymous/needs_artifact_access_fail', status=302) |
18 | 14 | |
15 | + @td.with_wiki | |
19 | 16 | def test_auth(self): |
20 | 17 | self.app.get('/security/test-admin/forbidden', status=403) |
21 | 18 | self.app.get('/security/test-admin/needs_auth', status=200) |
@@ -17,6 +17,7 @@ from allura.tasks import index_tasks | ||
17 | 17 | from allura.tasks import mail_tasks |
18 | 18 | from allura.tasks import notification_tasks |
19 | 19 | from allura.tasks import repo_tasks |
20 | +from allura.tests import decorators as td | |
20 | 21 | from allura.lib.decorators import event_handler, task |
21 | 22 | |
22 | 23 | class TestEventTasks(unittest.TestCase): |
@@ -45,6 +46,7 @@ class TestIndexTasks(unittest.TestCase): | ||
45 | 46 | setup_basic_test() |
46 | 47 | setup_global_objects() |
47 | 48 | |
49 | + @td.with_wiki | |
48 | 50 | def test_add_artifacts(self): |
49 | 51 | old_shortlinks = M.Shortlink.query.find().count() |
50 | 52 | old_solr_size = len(g.solr.db) |
@@ -65,6 +67,7 @@ class TestIndexTasks(unittest.TestCase): | ||
65 | 67 | a = _TestArtifact.query.get(_shorthand_id='t3') |
66 | 68 | assert len(a.backrefs) == 5, a.backrefs |
67 | 69 | |
70 | + @td.with_wiki | |
68 | 71 | def test_del_artifacts(self): |
69 | 72 | old_shortlinks = M.Shortlink.query.find().count() |
70 | 73 | old_solr_size = len(g.solr.db) |
@@ -114,6 +117,7 @@ class TestMailTasks(unittest.TestCase): | ||
114 | 117 | assert args[5] == None |
115 | 118 | assert 'This is a test' in str(args[6]), str(args[6]) |
116 | 119 | |
120 | + @td.with_wiki | |
117 | 121 | def test_receive_email_ok(self): |
118 | 122 | c.user = M.User.by_username('test-admin') |
119 | 123 | import forgewiki |
@@ -143,7 +147,10 @@ class TestRepoTasks(unittest.TestCase): | ||
143 | 147 | |
144 | 148 | def setUp(self): |
145 | 149 | setup_basic_test() |
146 | - setup_global_objects() | |
150 | + self.setup_with_tools() | |
151 | + | |
152 | + @td.with_svn | |
153 | + def setup_with_tools(self): | |
147 | 154 | h.set_context('test', 'src', neighborhood='Projects') |
148 | 155 | |
149 | 156 | def test_init(self): |
@@ -138,42 +138,23 @@ def bootstrap(command, conf, vars): | ||
138 | 138 | # TODO: Hope that Ming can be improved to at least avoid stuff below |
139 | 139 | sess.flush(x) |
140 | 140 | |
141 | - | |
142 | - log.info('Registering initial apps') | |
143 | - | |
144 | 141 | c.project = p0 |
145 | 142 | c.user = u_admin |
146 | 143 | p1 = p0.new_subproject('sub1') |
147 | 144 | ThreadLocalORMSession.flush_all() |
148 | 145 | if asbool(conf.get('load_test_data')): |
149 | - u_proj = M.Project.query.get(shortname='u/test-admin', neighborhood_id=n_users._id) | |
150 | - app = p0.install_app('SVN', 'src', 'SVN') | |
151 | - app = p0.install_app('Git', 'src-git', 'Git') | |
152 | - app.config.options['type'] = 'git' | |
153 | - app = p0.install_app('Hg', 'src-hg', 'Mercurial') | |
154 | - app.config.options['type'] = 'hg' | |
155 | - p0.install_app('Wiki', 'wiki') | |
156 | - p1.install_app('Wiki', 'wiki') | |
157 | - p0.install_app('Tickets', 'bugs') | |
158 | - app = p0.install_app('Tickets', 'doc-bugs') | |
159 | - role_anon = M.ProjectRole.by_name('*anonymous')._id | |
160 | - app.config.acl.append(M.ACE.allow(role_anon, 'post')) | |
161 | - app.config.acl.append(M.ACE.allow(role_anon, 'write')) | |
162 | - p0.install_app('Discussion', 'discussion') | |
163 | - p0.install_app('Link', 'link') | |
164 | - ThreadLocalORMSession.flush_all() | |
165 | - ThreadLocalORMSession.close_all() | |
166 | 146 | if asbool(conf.get('cache_test_data')): |
167 | 147 | cache_test_data() |
168 | 148 | else: # pragma no cover |
169 | 149 | # regular first-time setup |
170 | 150 | p0.add_user(u_admin, ['Admin']) |
151 | + log.info('Registering initial apps') | |
171 | 152 | for ep_name, app in g.entry_points['tool'].iteritems(): |
172 | 153 | if not app.installable: |
173 | 154 | continue |
174 | 155 | p0.install_app(ep_name) |
175 | - ThreadLocalORMSession.flush_all() | |
176 | - ThreadLocalORMSession.close_all() | |
156 | + ThreadLocalORMSession.flush_all() | |
157 | + ThreadLocalORMSession.close_all() | |
177 | 158 | |
178 | 159 | def wipe_database(): |
179 | 160 | conn = M.main_doc_session.bind.conn |
@@ -1,14 +1,15 @@ | ||
1 | -from pylons import c, g | |
1 | +from pylons import c | |
2 | 2 | |
3 | 3 | from alluratest.controller import setup_basic_test, setup_global_objects |
4 | 4 | from allura import model as M |
5 | 5 | from allura.lib import security |
6 | +from allura.tests import decorators as td | |
6 | 7 | |
7 | 8 | def setUp(): |
8 | 9 | setup_basic_test() |
9 | 10 | setup_global_objects() |
10 | - g.set_app('discussion') | |
11 | 11 | |
12 | +@td.with_discussion | |
12 | 13 | def test_role_assignments(): |
13 | 14 | admin = M.User.by_username('test-admin') |
14 | 15 | user = M.User.by_username('test-user') |
@@ -1,7 +1,8 @@ | ||
1 | 1 | from alluratest.controller import TestController |
2 | - | |
2 | +from allura.tests import decorators as td | |
3 | 3 | |
4 | 4 | class TestRootController(TestController): |
5 | + @td.with_wiki | |
5 | 6 | def test_root(self): |
6 | 7 | response = self.app.get('/downloads/nav.json') |
7 | 8 | root = self.app.get('/p/test/wiki/').follow() |
@@ -11,12 +11,17 @@ from datadiff.tools import assert_equal | ||
11 | 11 | |
12 | 12 | from allura import model as M |
13 | 13 | from allura.lib import helpers as h |
14 | +from allura.tests import decorators as td | |
14 | 15 | from alluratest.controller import TestController |
15 | 16 | |
16 | 17 | class TestRootController(TestController): |
17 | 18 | |
18 | 19 | def setUp(self): |
19 | 20 | TestController.setUp(self) |
21 | + self.setup_with_tools() | |
22 | + | |
23 | + @td.with_git | |
24 | + def setup_with_tools(self): | |
20 | 25 | h.set_context('test', 'src-git', neighborhood='Projects') |
21 | 26 | repo_dir = pkg_resources.resource_filename( |
22 | 27 | 'forgegit', 'tests/data') |
@@ -11,6 +11,7 @@ from ming.orm import ThreadLocalORMSession | ||
11 | 11 | |
12 | 12 | from alluratest.controller import setup_basic_test, setup_global_objects |
13 | 13 | from allura.lib import helpers as h |
14 | +from allura.tests import decorators as td | |
14 | 15 | from allura import model as M |
15 | 16 | from forgegit import model as GM |
16 | 17 | from forgewiki import model as WM |
@@ -19,6 +20,11 @@ class TestNewGit(unittest.TestCase): | ||
19 | 20 | |
20 | 21 | def setUp(self): |
21 | 22 | setup_basic_test() |
23 | + self.setup_with_tools() | |
24 | + | |
25 | + @td.with_git | |
26 | + @td.with_wiki | |
27 | + def setup_with_tools(self): | |
22 | 28 | setup_global_objects() |
23 | 29 | h.set_context('test', 'src-git', neighborhood='Projects') |
24 | 30 | repo_dir = pkg_resources.resource_filename( |
@@ -26,7 +32,7 @@ class TestNewGit(unittest.TestCase): | ||
26 | 32 | c.app.repo.fs_path = repo_dir |
27 | 33 | c.app.repo.name = 'testgit.git' |
28 | 34 | self.repo = c.app.repo |
29 | - # self.repo = GM.Repository( | |
35 | + #self.repo = GM.Repository( | |
30 | 36 | # name='testgit.git', |
31 | 37 | # fs_path=repo_dir, |
32 | 38 | # url_path = '/test/', |
@@ -88,6 +94,10 @@ class TestGitRepo(unittest.TestCase): | ||
88 | 94 | |
89 | 95 | def setUp(self): |
90 | 96 | setup_basic_test() |
97 | + self.setup_with_tools() | |
98 | + | |
99 | + @td.with_git | |
100 | + def setup_with_tools(self): | |
91 | 101 | setup_global_objects() |
92 | 102 | h.set_context('test', 'src-git', neighborhood='Projects') |
93 | 103 | repo_dir = pkg_resources.resource_filename( |
@@ -150,8 +160,12 @@ class TestGitCommit(unittest.TestCase): | ||
150 | 160 | |
151 | 161 | def setUp(self): |
152 | 162 | setup_basic_test() |
163 | + self.setup_with_tools() | |
164 | + | |
165 | + @td.with_git | |
166 | + def setup_with_tools(self): | |
153 | 167 | setup_global_objects() |
154 | - h.set_context('test', 'src', neighborhood='Projects') | |
168 | + h.set_context('test', 'src-git', neighborhood='Projects') | |
155 | 169 | repo_dir = pkg_resources.resource_filename( |
156 | 170 | 'forgegit', 'tests/data') |
157 | 171 | self.repo = GM.Repository( |
@@ -1,17 +1,21 @@ | ||
1 | 1 | import unittest |
2 | 2 | from nose.tools import assert_equals |
3 | 3 | |
4 | -from pylons import c, g | |
4 | +from pylons import c | |
5 | 5 | from ming.orm import ThreadLocalORMSession |
6 | 6 | |
7 | 7 | from alluratest.controller import setup_basic_test, setup_global_objects |
8 | 8 | from allura.lib import helpers as h |
9 | - | |
9 | +from allura.tests import decorators as td | |
10 | 10 | |
11 | 11 | class TestGitApp(unittest.TestCase): |
12 | 12 | |
13 | 13 | def setUp(self): |
14 | 14 | setup_basic_test() |
15 | + self.setup_with_tools() | |
16 | + | |
17 | + @td.with_git | |
18 | + def setup_with_tools(self): | |
15 | 19 | setup_global_objects() |
16 | 20 | h.set_context('test', 'src-git', neighborhood='Projects') |
17 | 21 | ThreadLocalORMSession.flush_all() |
@@ -21,8 +25,9 @@ class TestGitApp(unittest.TestCase): | ||
21 | 25 | assert_equals(len(c.app.admin_menu()), 4) |
22 | 26 | |
23 | 27 | def test_uninstall(self): |
24 | - c.app.uninstall(c.project) | |
25 | 28 | from allura import model as M |
29 | + M.MonQTask.run_ready() | |
30 | + c.app.uninstall(c.project) | |
26 | 31 | M.main_orm_session.flush() |
27 | 32 | task = M.MonQTask.get() |
28 | 33 | assert task.task_name == 'allura.tasks.repo_tasks.uninstall', task.task_name |
@@ -5,11 +5,16 @@ from ming.orm import ThreadLocalORMSession | ||
5 | 5 | from alluratest.controller import setup_basic_test, setup_global_objects |
6 | 6 | from allura.lib import helpers as h |
7 | 7 | from allura.tasks import repo_tasks |
8 | +from allura.tests import decorators as td | |
8 | 9 | |
9 | 10 | class TestGitTasks(unittest.TestCase): |
10 | 11 | |
11 | 12 | def setUp(self): |
12 | 13 | setup_basic_test() |
14 | + self.setup_with_tools() | |
15 | + | |
16 | + @td.with_git | |
17 | + def setup_with_tools(self): | |
13 | 18 | setup_global_objects() |
14 | 19 | h.set_context('test', 'src-git', neighborhood='Projects') |
15 | 20 | ThreadLocalORMSession.flush_all() |
@@ -1,4 +1,3 @@ | ||
1 | -import os | |
2 | 1 | import json |
3 | 2 | |
4 | 3 | import pkg_resources |
@@ -7,6 +6,7 @@ from ming.orm import ThreadLocalORMSession | ||
7 | 6 | from datadiff.tools import assert_equal |
8 | 7 | |
9 | 8 | from allura.lib import helpers as h |
9 | +from allura.tests import decorators as td | |
10 | 10 | from allura import model as M |
11 | 11 | from alluratest.controller import TestController |
12 | 12 |
@@ -15,6 +15,10 @@ class TestRootController(TestController): | ||
15 | 15 | |
16 | 16 | def setUp(self): |
17 | 17 | TestController.setUp(self) |
18 | + self.setup_with_tools() | |
19 | + | |
20 | + @td.with_hg | |
21 | + def setup_with_tools(self): | |
18 | 22 | h.set_context('test', 'src-hg', neighborhood='Projects') |
19 | 23 | repo_dir = pkg_resources.resource_filename( |
20 | 24 | 'forgehg', 'tests/data') |
@@ -7,6 +7,7 @@ from ming.orm import ThreadLocalORMSession | ||
7 | 7 | |
8 | 8 | from alluratest.controller import setup_basic_test, setup_global_objects |
9 | 9 | from allura.lib import helpers as h |
10 | +from allura.tests import decorators as td | |
10 | 11 | from allura import model as M |
11 | 12 | from forgehg import model as HM |
12 | 13 |
@@ -14,8 +15,12 @@ class TestNewRepo(unittest.TestCase): | ||
14 | 15 | |
15 | 16 | def setUp(self): |
16 | 17 | setup_basic_test() |
18 | + self.setup_with_tools() | |
19 | + | |
20 | + @td.with_hg | |
21 | + def setup_with_tools(self): | |
17 | 22 | setup_global_objects() |
18 | - h.set_context('test', 'src', neighborhood='Projects') | |
23 | + h.set_context('test', 'src-hg', neighborhood='Projects') | |
19 | 24 | repo_dir = pkg_resources.resource_filename( |
20 | 25 | 'forgehg', 'tests/data') |
21 | 26 | self.repo = HM.Repository( |
@@ -50,7 +55,7 @@ class TestNewRepo(unittest.TestCase): | ||
50 | 55 | assert self.rev.shorthand_id() == '[1c7eb5]' |
51 | 56 | assert self.rev.symbolic_ids == (['default'], ['tip']) |
52 | 57 | assert self.rev.url() == ( |
53 | - '/p/test/src/ci/' | |
58 | + '/p/test/src-hg/ci/' | |
54 | 59 | '1c7eb55bbd66ff45906b4a25d4b403899e0ffff1/') |
55 | 60 | all_cis = self.rev.log(0, 1000) |
56 | 61 | assert len(all_cis) == 5 |
@@ -65,7 +70,7 @@ class TestNewRepo(unittest.TestCase): | ||
65 | 70 | 'README', '<pre>This is readme\nAnother line\n</pre>') |
66 | 71 | assert self.rev.tree.path() == '/' |
67 | 72 | assert self.rev.tree.url() == ( |
68 | - '/p/test/src/ci/' | |
73 | + '/p/test/src-hg/ci/' | |
69 | 74 | '1c7eb55bbd66ff45906b4a25d4b403899e0ffff1/' |
70 | 75 | 'tree/') |
71 | 76 | self.rev.tree.by_name['README'] |
@@ -75,6 +80,10 @@ class TestHgRepo(unittest.TestCase): | ||
75 | 80 | |
76 | 81 | def setUp(self): |
77 | 82 | setup_basic_test() |
83 | + self.setup_with_tools() | |
84 | + | |
85 | + @td.with_hg | |
86 | + def setup_with_tools(self): | |
78 | 87 | setup_global_objects() |
79 | 88 | h.set_context('test', 'src-hg', neighborhood='Projects') |
80 | 89 | repo_dir = pkg_resources.resource_filename( |
@@ -138,6 +147,10 @@ class TestHgCommit(unittest.TestCase): | ||
138 | 147 | |
139 | 148 | def setUp(self): |
140 | 149 | setup_basic_test() |
150 | + self.setup_with_tools() | |
151 | + | |
152 | + @td.with_hg | |
153 | + def setup_with_tools(self): | |
141 | 154 | setup_global_objects() |
142 | 155 | h.set_context('test', 'src-hg', neighborhood='Projects') |
143 | 156 | repo_dir = pkg_resources.resource_filename( |
@@ -6,12 +6,16 @@ from ming.orm import ThreadLocalORMSession | ||
6 | 6 | |
7 | 7 | from alluratest.controller import setup_basic_test, setup_global_objects |
8 | 8 | from allura.lib import helpers as h |
9 | - | |
9 | +from allura.tests import decorators as td | |
10 | 10 | |
11 | 11 | class TestHgApp(unittest.TestCase): |
12 | 12 | |
13 | 13 | def setUp(self): |
14 | 14 | setup_basic_test() |
15 | + self.setup_with_tools() | |
16 | + | |
17 | + @td.with_hg | |
18 | + def setup_with_tools(self): | |
15 | 19 | setup_global_objects() |
16 | 20 | h.set_context('test', 'src-hg', neighborhood='Projects') |
17 | 21 | ThreadLocalORMSession.flush_all() |
@@ -21,8 +25,9 @@ class TestHgApp(unittest.TestCase): | ||
21 | 25 | assert_equals(len(c.app.admin_menu()), 4) |
22 | 26 | |
23 | 27 | def test_uninstall(self): |
24 | - c.app.uninstall(c.project) | |
25 | 28 | from allura import model as M |
29 | + M.MonQTask.run_ready() | |
30 | + c.app.uninstall(c.project) | |
26 | 31 | M.main_orm_session.flush() |
27 | 32 | task = M.MonQTask.get() |
28 | 33 | assert task.task_name == 'allura.tasks.repo_tasks.uninstall', task.task_name |
@@ -1,17 +1,20 @@ | ||
1 | 1 | import unittest |
2 | 2 | |
3 | -from pylons import c, g | |
4 | - | |
5 | 3 | from ming.orm import ThreadLocalORMSession |
6 | 4 | |
7 | 5 | from alluratest.controller import setup_basic_test, setup_global_objects |
8 | 6 | from allura.lib import helpers as h |
9 | 7 | from allura.tasks import repo_tasks |
8 | +from allura.tests import decorators as td | |
10 | 9 | |
11 | 10 | class TestHgReactors(unittest.TestCase): |
12 | 11 | |
13 | 12 | def setUp(self): |
14 | 13 | setup_basic_test() |
14 | + self.setup_with_tools() | |
15 | + | |
16 | + @td.with_hg | |
17 | + def setup_with_tools(self): | |
15 | 18 | setup_global_objects() |
16 | 19 | h.set_context('test', 'src-hg', neighborhood='Projects') |
17 | 20 | ThreadLocalORMSession.flush_all() |
@@ -1,9 +1,5 @@ | ||
1 | -import allura | |
2 | - | |
1 | +from allura.tests import decorators as td | |
3 | 2 | from alluratest.controller import TestController |
4 | -from allura.lib import helpers as h | |
5 | -from allura.ext.search import search_main | |
6 | -from ming.orm.ormsession import ThreadLocalORMSession | |
7 | 3 | |
8 | 4 | |
9 | 5 | class TestRootController(TestController): |
@@ -11,6 +7,7 @@ class TestRootController(TestController): | ||
11 | 7 | response = self.app.get('/link/index') |
12 | 8 | assert 'Link is not configured' in response |
13 | 9 | |
10 | + @td.with_link | |
14 | 11 | def test_root_index_with_url(self): |
15 | 12 | response = self.app.get('/admin/link/options', validate_chunk=True) |
16 | 13 | response.form['url'] = 'http://www.google.com/' |
@@ -1,4 +1,3 @@ | ||
1 | -import os | |
2 | 1 | import json |
3 | 2 | |
4 | 3 | import pkg_resources |
@@ -7,9 +6,9 @@ pylons.c = pylons.tmpl_context | ||
7 | 6 | pylons.g = pylons.app_globals |
8 | 7 | from pylons import c |
9 | 8 | from ming.orm import ThreadLocalORMSession |
10 | -from datadiff.tools import assert_equal | |
11 | 9 | |
12 | 10 | from allura.lib import helpers as h |
11 | +from allura.tests import decorators as td | |
13 | 12 | from alluratest.controller import TestController |
14 | 13 | |
15 | 14 |
@@ -17,6 +16,10 @@ class TestRootController(TestController): | ||
17 | 16 | |
18 | 17 | def setUp(self): |
19 | 18 | TestController.setUp(self) |
19 | + self.setup_with_tools() | |
20 | + | |
21 | + @td.with_svn | |
22 | + def setup_with_tools(self): | |
20 | 23 | h.set_context('test', 'src', neighborhood='Projects') |
21 | 24 | repo_dir = pkg_resources.resource_filename( |
22 | 25 | 'forgesvn', 'tests/data/') |
@@ -7,6 +7,7 @@ from ming.orm import ThreadLocalORMSession | ||
7 | 7 | |
8 | 8 | from alluratest.controller import setup_basic_test, setup_global_objects |
9 | 9 | from allura.lib import helpers as h |
10 | +from allura.tests import decorators as td | |
10 | 11 | from allura import model as M |
11 | 12 | from forgesvn import model as SM |
12 | 13 |
@@ -14,6 +15,10 @@ class TestNewRepo(unittest.TestCase): | ||
14 | 15 | |
15 | 16 | def setUp(self): |
16 | 17 | setup_basic_test() |
18 | + self.setup_with_tools() | |
19 | + | |
20 | + @td.with_svn | |
21 | + def setup_with_tools(self): | |
17 | 22 | setup_global_objects() |
18 | 23 | h.set_context('test', 'src', neighborhood='Projects') |
19 | 24 | repo_dir = pkg_resources.resource_filename( |
@@ -64,7 +69,12 @@ class TestSVNRepo(unittest.TestCase): | ||
64 | 69 | |
65 | 70 | def setUp(self): |
66 | 71 | setup_basic_test() |
72 | + self.setup_with_tools() | |
73 | + | |
74 | + @td.with_svn | |
75 | + def setup_with_tools(self): | |
67 | 76 | setup_global_objects() |
77 | + h.set_context('test', 'src', neighborhood='Projects') | |
68 | 78 | repo_dir = pkg_resources.resource_filename( |
69 | 79 | 'forgesvn', 'tests/data/') |
70 | 80 | self.repo = SM.Repository( |
@@ -128,6 +138,10 @@ class TestSVNRev(unittest.TestCase): | ||
128 | 138 | |
129 | 139 | def setUp(self): |
130 | 140 | setup_basic_test() |
141 | + self.setup_with_tools() | |
142 | + | |
143 | + @td.with_svn | |
144 | + def setup_with_tools(self): | |
131 | 145 | setup_global_objects() |
132 | 146 | h.set_context('test', 'src', neighborhood='Projects') |
133 | 147 | repo_dir = pkg_resources.resource_filename( |
@@ -159,5 +173,3 @@ class TestSVNRev(unittest.TestCase): | ||
159 | 173 | +self.rev.diffs.copied) |
160 | 174 | for d in diffs: |
161 | 175 | print d |
162 | - | |
163 | - |
@@ -1,21 +1,21 @@ | ||
1 | -import os | |
2 | -import shutil | |
3 | 1 | import unittest |
4 | -import pkg_resources | |
5 | 2 | from nose.tools import assert_equals |
6 | 3 | |
7 | -from pylons import c, g | |
4 | +from pylons import c | |
8 | 5 | from ming.orm import ThreadLocalORMSession |
9 | 6 | |
10 | 7 | from alluratest.controller import setup_basic_test, setup_global_objects |
11 | 8 | from allura.lib import helpers as h |
12 | -from forgesvn import model as SM | |
13 | - | |
9 | +from allura.tests import decorators as td | |
14 | 10 | |
15 | 11 | class TestSVNApp(unittest.TestCase): |
16 | 12 | |
17 | 13 | def setUp(self): |
18 | 14 | setup_basic_test() |
15 | + self.setup_with_tools() | |
16 | + | |
17 | + @td.with_svn | |
18 | + def setup_with_tools(self): | |
19 | 19 | setup_global_objects() |
20 | 20 | h.set_context('test', 'src', neighborhood='Projects') |
21 | 21 | ThreadLocalORMSession.flush_all() |
@@ -26,8 +26,9 @@ class TestSVNApp(unittest.TestCase): | ||
26 | 26 | assert_equals(c.app.admin_menu()[0].label, 'Checkout URL') |
27 | 27 | |
28 | 28 | def test_uninstall(self): |
29 | - c.app.uninstall(c.project) | |
30 | 29 | from allura import model as M |
30 | + M.MonQTask.run_ready() | |
31 | + c.app.uninstall(c.project) | |
31 | 32 | M.main_orm_session.flush() |
32 | 33 | task = M.MonQTask.get() |
33 | 34 | assert task.task_name == 'allura.tasks.repo_tasks.uninstall', task.task_name |
@@ -7,13 +7,13 @@ import ming | ||
7 | 7 | import pylons |
8 | 8 | pylons.c = pylons.tmpl_context |
9 | 9 | pylons.g = pylons.app_globals |
10 | -from pylons import c, g | |
10 | +from pylons import g | |
11 | 11 | |
12 | 12 | from allura import model as M |
13 | -from alluratest.controller import TestController, TestRestApiBase | |
13 | +from alluratest.controller import TestRestApiBase | |
14 | +from allura.tests import decorators as td | |
14 | 15 | |
15 | - | |
16 | -class TestImportController(TestRestApiBase):#TestController): | |
16 | +class TestImportController(TestRestApiBase): | |
17 | 17 | |
18 | 18 | def new_ticket(self, mount_point='/bugs/', **kw): |
19 | 19 | response = self.app.get(mount_point + 'new/') |
@@ -32,7 +32,7 @@ class TestImportController(TestRestApiBase):#TestController): | ||
32 | 32 | ming.orm.session(api_ticket).flush() |
33 | 33 | self.set_api_token(api_ticket) |
34 | 34 | |
35 | - | |
35 | + @td.with_tracker | |
36 | 36 | def test_no_capability(self): |
37 | 37 | here_dir = os.path.dirname(__file__) |
38 | 38 |
@@ -66,6 +66,7 @@ class TestImportController(TestRestApiBase):#TestController): | ||
66 | 66 | assert_equal(from_api['custom_fields']['_cc'], org['cc']) |
67 | 67 | assert_equal(from_api['custom_fields']['_private'], org['private']) |
68 | 68 | |
69 | + @td.with_tracker | |
69 | 70 | def test_validate_import(self): |
70 | 71 | here_dir = os.path.dirname(__file__) |
71 | 72 | doc_text = open(here_dir + '/data/sf.json').read() |
@@ -73,6 +74,7 @@ class TestImportController(TestRestApiBase):#TestController): | ||
73 | 74 | doc=doc_text, options='{}') |
74 | 75 | assert not r.json['errors'] |
75 | 76 | |
77 | + @td.with_tracker | |
76 | 78 | def test_import(self): |
77 | 79 | here_dir = os.path.dirname(__file__) |
78 | 80 | api_ticket = M.ApiTicket(user_id=self.user._id, capabilities={'import': ['Projects','test']}, |
@@ -2,18 +2,20 @@ import pylons | ||
2 | 2 | pylons.c = pylons.tmpl_context |
3 | 3 | pylons.g = pylons.app_globals |
4 | 4 | from pylons import c |
5 | -from ming.orm import session | |
6 | 5 | |
7 | -from allura import model as M | |
8 | 6 | from allura.lib import helpers as h |
9 | -from alluratest.controller import TestController, TestRestApiBase | |
10 | -from forgetracker import model as TM | |
7 | +from allura.tests import decorators as td | |
8 | +from alluratest.controller import TestRestApiBase | |
11 | 9 | |
12 | 10 | |
13 | 11 | class TestTrackerApiBase(TestRestApiBase): |
14 | 12 | |
15 | 13 | def setUp(self): |
16 | 14 | super(TestTrackerApiBase, self).setUp() |
15 | + self.setup_with_tools() | |
16 | + | |
17 | + @td.with_tracker | |
18 | + def setup_with_tools(self): | |
17 | 19 | h.set_context('test', 'bugs', neighborhood='Projects') |
18 | 20 | self.tracker_globals = c.app.globals |
19 | 21 |
@@ -108,6 +110,3 @@ class TestRestDiscussion(TestTrackerApiBase): | ||
108 | 110 | assert reply.json['post']['text'] == 'This is a reply', reply.json |
109 | 111 | thread = self.api_post('/rest/p/test/bugs/_discuss/thread/%s/' % discussion['threads'][0]['_id']) |
110 | 112 | assert len(thread.json['thread']['posts']) == 2, thread.json |
111 | - | |
112 | - | |
113 | - |
@@ -4,18 +4,27 @@ import Image, StringIO | ||
4 | 4 | import allura |
5 | 5 | |
6 | 6 | from mock import patch |
7 | -from nose.tools import assert_true, assert_false, eq_, assert_equal | |
7 | +from nose.tools import assert_true, assert_false, assert_equal | |
8 | 8 | from formencode.variabledecode import variable_encode |
9 | 9 | |
10 | -from alluratest.controller import TestController, REGISTRY | |
10 | +from alluratest.controller import TestController | |
11 | 11 | from allura import model as M |
12 | 12 | from forgewiki import model as wm |
13 | 13 | from forgetracker import model as tm |
14 | 14 | |
15 | 15 | from allura.lib import helpers as h |
16 | +from allura.tests import decorators as td | |
16 | 17 | from ming.orm.ormsession import ThreadLocalORMSession |
17 | 18 | |
18 | 19 | class TrackerTestController(TestController): |
20 | + def setUp(self): | |
21 | + super(TrackerTestController, self).setUp() | |
22 | + self.setup_with_tools() | |
23 | + | |
24 | + @td.with_tracker | |
25 | + def setup_with_tools(self): | |
26 | + pass | |
27 | + | |
19 | 28 | def new_ticket(self, mount_point='/bugs/', **kw): |
20 | 29 | response = self.app.get(mount_point + 'new/') |
21 | 30 | form = response.forms[1] |
@@ -118,6 +127,7 @@ class TestFunctionalController(TrackerTestController): | ||
118 | 127 | r = self.app.get('/p/test/bugs/feed.atom') |
119 | 128 | assert 'Private Ticket' not in r |
120 | 129 | |
130 | + @td.with_tool('test', 'Tickets', 'doc-bugs') | |
121 | 131 | def test_two_trackers(self): |
122 | 132 | summary = 'test two trackers' |
123 | 133 | ticket_view = self.new_ticket('/doc-bugs/', summary=summary, _milestone='1.0').follow() |
@@ -766,6 +776,11 @@ class TestMilestoneAdmin(TrackerTestController): | ||
766 | 776 | assert tm.Ticket.query.find({ |
767 | 777 | 'custom_fields._releases': '1.1'}).count() == 1 |
768 | 778 | |
779 | +def post_install_hook(app): | |
780 | + role_anon = M.ProjectRole.by_name('*anonymous')._id | |
781 | + app.config.acl.append(M.ACE.allow(role_anon, 'post')) | |
782 | + app.config.acl.append(M.ACE.allow(role_anon, 'write')) | |
783 | + | |
769 | 784 | class TestEmailMonitoring(TrackerTestController): |
770 | 785 | def __init__(self): |
771 | 786 | super(TestEmailMonitoring, self).__init__() |
@@ -786,6 +801,7 @@ class TestEmailMonitoring(TrackerTestController): | ||
786 | 801 | assert email[0]['value'] == self.test_email |
787 | 802 | assert mtype[0]['selected'] == 'selected' |
788 | 803 | |
804 | + @td.with_tool('test', 'Tickets', 'doc-bugs', post_install_hook=post_install_hook) | |
789 | 805 | @patch('forgetracker.model.ticket.Notification.send_direct') |
790 | 806 | def test_notifications_moderators(self, send_direct): |
791 | 807 | self.new_ticket(summary='test moderation', mount_point='/doc-bugs/') |
@@ -1,9 +1,11 @@ | ||
1 | 1 | from nose.tools import assert_true |
2 | 2 | |
3 | +from allura.tests import decorators as td | |
3 | 4 | from alluratest.controller import TestController |
4 | 5 | |
5 | 6 | |
6 | 7 | class TestRootController(TestController): |
8 | + @td.with_tracker | |
7 | 9 | def test_index(self): |
8 | 10 | response = self.app.get('/bugs/') |
9 | 11 | assert_true('bugs' in response) |
@@ -3,9 +3,14 @@ from pylons import c, g | ||
3 | 3 | from alluratest.controller import setup_basic_test, setup_global_objects |
4 | 4 | from allura import model as M |
5 | 5 | from allura.lib import security |
6 | +from allura.tests import decorators as td | |
6 | 7 | |
7 | 8 | def setUp(): |
8 | 9 | setup_basic_test() |
10 | + setup_with_tools() | |
11 | + | |
12 | +@td.with_tracker | |
13 | +def setup_with_tools(): | |
9 | 14 | setup_global_objects() |
10 | 15 | g.set_app('bugs') |
11 | 16 |
@@ -9,6 +9,7 @@ from ming.orm.ormsession import ThreadLocalORMSession | ||
9 | 9 | |
10 | 10 | from allura import model as M |
11 | 11 | from allura.lib import helpers as h |
12 | +from allura.tests import decorators as td | |
12 | 13 | from alluratest.controller import TestController |
13 | 14 | |
14 | 15 | from forgewiki import model |
@@ -22,6 +23,14 @@ from forgewiki import model | ||
22 | 23 | # reply, delete |
23 | 24 | |
24 | 25 | class TestRootController(TestController): |
26 | + def setUp(self): | |
27 | + super(TestRootController, self).setUp() | |
28 | + self.setup_with_tools() | |
29 | + | |
30 | + @td.with_wiki | |
31 | + def setup_with_tools(self): | |
32 | + pass | |
33 | + | |
25 | 34 | def test_root_index(self): |
26 | 35 | r = self.app.get('/wiki/tést/').follow() |
27 | 36 | assert 'tést' in r |
@@ -5,9 +5,14 @@ from nose.tools import assert_equal | ||
5 | 5 | from alluratest.controller import setup_basic_test, setup_global_objects |
6 | 6 | from allura import model as M |
7 | 7 | from allura.lib import security |
8 | +from allura.tests import decorators as td | |
8 | 9 | |
9 | 10 | def setUp(): |
10 | 11 | setup_basic_test() |
12 | + setup_with_tools() | |
13 | + | |
14 | +@td.with_wiki | |
15 | +def setup_with_tools(): | |
11 | 16 | setup_global_objects() |
12 | 17 | g.set_app('wiki') |
13 | 18 |