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