Switch to unified view

a/Allura/allura/controllers/test.py b/Allura/allura/controllers/test.py
...
...
43
        setattr(self, 'feed.rss', self.feed)
43
        setattr(self, 'feed.rss', self.feed)
44
        setattr(self, 'feed.atom', self.feed)
44
        setattr(self, 'feed.atom', self.feed)
45
        for n in M.Neighborhood.query.find():
45
        for n in M.Neighborhood.query.find():
46
            if n.url_prefix.startswith('//'): continue
46
            if n.url_prefix.startswith('//'): continue
47
            n.bind_controller(self)
47
            n.bind_controller(self)
48
        self.p_nbhd = M.Neighborhood.query.get(name='Projects')
48
        proxy_root = RootController()
49
        proxy_root = RootController()
49
        self.dispatch = DispatchTest()
50
        self.dispatch = DispatchTest()
50
        self.security = SecurityTests()
51
        self.security = SecurityTests()
51
        for attr in ('index', 'browse', 'auth', 'nf', 'error'):
52
        for attr in ('index', 'browse', 'auth', 'nf', 'error'):
52
            setattr(self, attr, getattr(proxy_root, attr))
53
            setattr(self, attr, getattr(proxy_root, attr))
...
...
54
        self.rest = RestController()
55
        self.rest = RestController()
55
        super(TestController, self).__init__()
56
        super(TestController, self).__init__()
56
57
57
    def _setup_request(self):
58
    def _setup_request(self):
58
        # This code fixes a race condition in our tests
59
        # This code fixes a race condition in our tests
59
        c.project = M.Project.query.get(shortname='test')
60
        c.project = M.Project.query.get(shortname='test', neighborhood_id=self.p_nbhd._id)
60
        c.memoize_cache = {}
61
        c.memoize_cache = {}
61
        count = 20
62
        count = 20
62
        while c.project is None:
63
        while c.project is None:
63
            import sys, time
64
            import sys, time
64
            time.sleep(0.5)
65
            time.sleep(0.5)
65
            log.warning('Project "test" not found, retrying...')
66
            log.warning('Project "test" not found, retrying...')
66
            c.project = M.Project.query.get(shortname='test')
67
            c.project = M.Project.query.get(shortname='test', neighborhood_id=self.p_nbhd._id)
67
            count -= 1
68
            count -= 1
68
            assert count > 0, 'Timeout waiting for test project to appear'
69
            assert count > 0, 'Timeout waiting for test project to appear'
69
70
70
    def _cleanup_request(self):
71
    def _cleanup_request(self):
71
        pass
72
        pass
72
73
73
    @expose()
74
    @expose()
74
    def _lookup(self, name, *remainder):
75
    def _lookup(self, name, *remainder):
75
        if not h.re_path_portion.match(name):
76
        if not h.re_path_portion.match(name):
76
            raise exc.HTTPNotFound, name
77
            raise exc.HTTPNotFound, name
77
        subproject = M.Project.query.get(shortname=c.project.shortname + '/' + name)
78
        subproject = M.Project.query.get(shortname=c.project.shortname + '/' + name,
79
                                         neighborhood_id=self.p_nbhd._id)
78
        if subproject:
80
        if subproject:
79
            c.project = subproject
81
            c.project = subproject
80
            c.app = None
82
            c.app = None
81
            return ProjectController(), remainder
83
            return ProjectController(), remainder
82
        app = c.project.app_instance(name)
84
        app = c.project.app_instance(name)
...
...
92
        c.app = app
94
        c.app = app
93
        return app.root, remainder
95
        return app.root, remainder
94
96
95
    def __call__(self, environ, start_response):
97
    def __call__(self, environ, start_response):
96
        c.app = None
98
        c.app = None
97
        c.project = M.Project.query.get(shortname='test')
99
        c.project = M.Project.query.get(shortname='test', neighborhood_id=self.p_nbhd._id)
98
        c.user = plugin.AuthenticationProvider.get(request).by_username(
100
        c.user = plugin.AuthenticationProvider.get(request).by_username(
99
            environ.get('username', 'test-admin'))
101
            environ.get('username', 'test-admin'))
100
        return WsgiDispatchController.__call__(self, environ, start_response)
102
        return WsgiDispatchController.__call__(self, environ, start_response)
101
103
102
class DispatchTest(object):
104
class DispatchTest(object):
...
...
167
169
168
    @expose()
170
    @expose()
169
    def needs_artifact_access_ok(self):
171
    def needs_artifact_access_ok(self):
170
        require_access(self.page, 'read')
172
        require_access(self.page, 'read')
171
        return ''
173
        return ''
172