Switch to unified view

a/ForgeSVN/forgesvn/tests/functional/test_controllers.py b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
...
...
36
class SVNTestController(TestController):
36
class SVNTestController(TestController):
37
    def setUp(self):
37
    def setUp(self):
38
        TestController.setUp(self)
38
        TestController.setUp(self)
39
        self.setup_with_tools()
39
        self.setup_with_tools()
40
40
41
    @with_svn
41
    def _make_app(self, mount_point, name):
42
    @with_tool('test', 'SVN', 'svn-tags', 'SVN with tags')
43
    def setup_with_tools(self):
44
        h.set_context('test', 'src', neighborhood='Projects')
42
        h.set_context('test', mount_point, neighborhood='Projects')
45
        repo_dir = pkg_resources.resource_filename(
43
        repo_dir = pkg_resources.resource_filename(
46
            'forgesvn', 'tests/data/')
44
            'forgesvn', 'tests/data/')
47
        c.app.repo.fs_path = repo_dir
45
        c.app.repo.fs_path = repo_dir
48
        c.app.repo.status = 'ready'
46
        c.app.repo.status = 'ready'
49
        c.app.repo.name = 'testsvn'
47
        c.app.repo.name = name
48
        c.app.repo.refresh()
49
        if os.path.isdir(c.app.repo.tarball_path):
50
            shutil.rmtree(c.app.repo.tarball_path)
50
        ThreadLocalORMSession.flush_all()
51
        ThreadLocalORMSession.flush_all()
51
        ThreadLocalORMSession.close_all()
52
        ThreadLocalORMSession.close_all()
52
        h.set_context('test', 'src', neighborhood='Projects')
53
53
        c.app.repo.refresh()
54
    @with_svn
54
        ThreadLocalORMSession.flush_all()
55
    @with_tool('test', 'SVN', 'svn-tags', 'SVN with tags')
55
        ThreadLocalORMSession.close_all()
56
    def setup_with_tools(self):
56
        h.set_context('test', 'svn-tags', neighborhood='Projects')
57
        self._make_app('svn-tags', 'testsvn-trunk-tags-branches')
57
        c.app.repo.fs_path = repo_dir
58
        self._make_app('src', 'testsvn')
58
        c.app.repo.status = 'ready'
59
        c.app.repo.name = 'testsvn-trunk-tags-branches'
60
        c.app.repo.refresh()
61
        ThreadLocalORMSession.flush_all()
62
        ThreadLocalORMSession.close_all()
63
        h.set_context('test', 'src', neighborhood='Projects')
64
59
65
60
66
class TestRootController(SVNTestController):
61
class TestRootController(SVNTestController):
67
    def test_status(self):
62
    def test_status(self):
68
        resp = self.app.get('/src/status')
63
        resp = self.app.get('/src/status')
...
...
192
187
193
    @onlyif(os.path.exists(tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')), 'zip binary is missing')
188
    @onlyif(os.path.exists(tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')), 'zip binary is missing')
194
    def test_tarball(self):
189
    def test_tarball(self):
195
        r = self.app.get('/src/3/tree/')
190
        r = self.app.get('/src/3/tree/')
196
        assert 'Download Snapshot' in r
191
        assert 'Download Snapshot' in r
192
        r = self.app.post('/src/3/tarball').follow()
193
        assert 'Checking snapshot status...' in r
197
        r = self.app.post('/src/3/tarball')
194
        r = self.app.get('/src/3/tarball')
198
        assert 'Generating snapshot...' in r
195
        assert 'Checking snapshot status...' in r
199
        M.MonQTask.run_ready()
196
        M.MonQTask.run_ready()
200
        ThreadLocalORMSession.flush_all()
197
        ThreadLocalORMSession.flush_all()
201
        r = self.app.get('/src/3/tarball_status')
198
        r = self.app.get('/src/3/tarball_status')
202
        assert '{"status": "ready"}' in r
199
        assert '{"status": "ready"}' in r
200
        r = self.app.get('/src/3/tarball')
201
        assert 'Your download will begin shortly' in r
203
202
204
    @onlyif(os.path.exists(tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')), 'zip binary is missing')
203
    @onlyif(os.path.exists(tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')), 'zip binary is missing')
205
    def test_tarball_tags_aware(self):
204
    def test_tarball_tags_aware(self):
206
        h.set_context('test', 'svn-tags', neighborhood='Projects')
205
        h.set_context('test', 'svn-tags', neighborhood='Projects')
207
        shutil.rmtree(c.app.repo.tarball_path, ignore_errors=True)
206
        shutil.rmtree(c.app.repo.tarball_path, ignore_errors=True)
...
...
215
        assert_equal(form.button.text, 'Download Snapshot')
214
        assert_equal(form.button.text, 'Download Snapshot')
216
        assert_equal(form.get('action'), '/p/test/svn-tags/19/tarball')
215
        assert_equal(form.get('action'), '/p/test/svn-tags/19/tarball')
217
        assert_equal(form.find('input', attrs=dict(name='path')).get('value'), '/tags/tag-1.0')
216
        assert_equal(form.find('input', attrs=dict(name='path')).get('value'), '/tags/tag-1.0')
218
217
219
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/tags/tag-1.0')
218
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/tags/tag-1.0')
220
        assert_equal(r.json['status'], None)
219
        assert_equal(r.json['status'], 'na')
221
        r = self.app.post('/p/test/svn-tags/19/tarball', dict(path='/tags/tag-1.0'))
220
        r = self.app.post('/p/test/svn-tags/19/tarball', dict(path='/tags/tag-1.0')).follow()
222
        assert 'Generating snapshot...' in r
221
        assert 'Checking snapshot status...' in r
223
        M.MonQTask.run_ready()
222
        M.MonQTask.run_ready()
224
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/tags/tag-1.0')
223
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/tags/tag-1.0')
225
        assert_equal(r.json['status'], 'ready')
224
        assert_equal(r.json['status'], 'ready')
226
225
227
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/trunk')
226
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/trunk')
228
        assert_equal(r.json['status'], None)
227
        assert_equal(r.json['status'], 'na')
229
        r = self.app.post('/p/test/svn-tags/19/tarball', dict(path='/trunk/'))
228
        r = self.app.post('/p/test/svn-tags/19/tarball', dict(path='/trunk/')).follow()
230
        assert 'Generating snapshot...' in r
229
        assert 'Checking snapshot status...' in r
231
        M.MonQTask.run_ready()
230
        M.MonQTask.run_ready()
232
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/trunk')
231
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/trunk')
233
        assert_equal(r.json['status'], 'ready')
232
        assert_equal(r.json['status'], 'ready')
234
233
235
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/branches/aaa/')
234
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/branches/aaa/')
236
        assert_equal(r.json['status'], None)
235
        assert_equal(r.json['status'], 'na')
237
236
238
        # All of the following also should be ready because...
237
        # All of the following also should be ready because...
239
        # ...this is essentially the same as trunk snapshot
238
        # ...this is essentially the same as trunk snapshot
240
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/trunk/some/path/')
239
        r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/trunk/some/path/')
241
        assert_equal(r.json['status'], 'ready')
240
        assert_equal(r.json['status'], 'ready')