##// END OF EJS Templates
tests: Fix error introduced by rebasing.
Martin Bornhold -
r982:65d80657 default
parent child Browse files
Show More
@@ -1,60 +1,61 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2010-2016 RhodeCode GmbH
3 # Copyright (C) 2010-2016 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import mock
21 import mock
22 import pytest
22 import pytest
23
23
24
24
25 @pytest.mark.usefixtures('autologin_user', 'app')
25 @pytest.mark.usefixtures('autologin_user', 'app')
26 def test_vcs_available_returns_summary_page(app, backend):
26 def test_vcs_available_returns_summary_page(app, backend):
27 url = '/{repo_name}'.format(repo_name=backend.repo.repo_name)
27 url = '/{repo_name}'.format(repo_name=backend.repo.repo_name)
28 response = app.get(url)
28 response = app.get(url)
29 assert response.status_code == 200
29 assert response.status_code == 200
30 assert 'Summary' in response.body
30 assert 'Summary' in response.body
31
31
32
32
33 @pytest.mark.usefixtures('autologin_user', 'app')
33 @pytest.mark.usefixtures('autologin_user', 'app')
34 def test_vcs_unavailable_returns_vcs_error_page(app, backend, app_settings):
34 def test_vcs_unavailable_returns_vcs_error_page(app, backend, app_settings):
35 import rhodecode
36 from rhodecode.lib.vcs.exceptions import VCSCommunicationError
35 from rhodecode.lib.vcs.exceptions import VCSCommunicationError
36 from rhodecode.lib.middleware.error_handling import (
37 PylonsErrorHandlingMiddleware)
37
38
38 # Depending on the used VCSServer protocol we have to patch a different
39 # Depending on the used VCSServer protocol we have to patch a different
39 # RemoteRepo class to raise an exception. For the test it doesn't matter
40 # RemoteRepo class to raise an exception. For the test it doesn't matter
40 # if http or pyro4 is used, it just requires the exception to be raised.
41 # if http or pyro4 is used, it just requires the exception to be raised.
41 vcs_protocol = app_settings['vcs.server.protocol']
42 vcs_protocol = app_settings['vcs.server.protocol']
42 if vcs_protocol == 'http':
43 if vcs_protocol == 'http':
43 from rhodecode.lib.vcs.client_http import RemoteRepo
44 from rhodecode.lib.vcs.client_http import RemoteRepo
44 elif vcs_protocol == 'pyro4':
45 elif vcs_protocol == 'pyro4':
45 from rhodecode.lib.vcs.client import RemoteRepo
46 from rhodecode.lib.vcs.client import RemoteRepo
46 else:
47 else:
47 pytest.fail('Unknown VCS server protocol: "{}"'.format(vcs_protocol))
48 pytest.fail('Unknown VCS server protocol: "{}"'.format(vcs_protocol))
48
49
49 url = '/{repo_name}'.format(repo_name=backend.repo.repo_name)
50 url = '/{repo_name}'.format(repo_name=backend.repo.repo_name)
50
51
51 # Patch remote repo to raise an exception instead of making a RPC.
52 # Patch remote repo to raise an exception instead of making a RPC.
52 with mock.patch.object(RemoteRepo, '__getattr__') as remote_mock:
53 with mock.patch.object(RemoteRepo, '__getattr__') as remote_mock:
53 remote_mock.side_effect = VCSCommunicationError()
54 remote_mock.side_effect = VCSCommunicationError()
54 # Patch pylons error handling middleware to not re-raise exceptions.
55 # Patch pylons error handling middleware to not re-raise exceptions.
55 with mock.patch.object(PylonsErrorHandlingMiddleware, 'reraise') as r:
56 with mock.patch.object(PylonsErrorHandlingMiddleware, 'reraise') as r:
56 r.return_value = False
57 r.return_value = False
57 response = app.get(url, expect_errors=True)
58 response = app.get(url, expect_errors=True)
58
59
59 assert response.status_code == 502
60 assert response.status_code == 502
60 assert 'Could not connect to VCS Server' in response.body
61 assert 'Could not connect to VCS Server' in response.body
General Comments 0
You need to be logged in to leave comments. Login now