##// END OF EJS Templates
tests: Make test work with either http or pyro4 protocol.
Martin Bornhold -
r979:f47b3cec default
parent child Browse files
Show More
@@ -20,9 +20,6 b''
20
20
21 import mock
21 import mock
22 import pytest
22 import pytest
23 import rhodecode.lib.vcs.client as client
24 from rhodecode.lib.middleware.error_handling import (
25 PylonsErrorHandlingMiddleware)
26
23
27
24
28 @pytest.mark.usefixtures('autologin_user', 'app')
25 @pytest.mark.usefixtures('autologin_user', 'app')
@@ -34,13 +31,26 b' def test_vcs_available_returns_summary_p'
34
31
35
32
36 @pytest.mark.usefixtures('autologin_user', 'app')
33 @pytest.mark.usefixtures('autologin_user', 'app')
37 def test_vcs_unavailable_returns_vcs_error_page(app, backend):
34 def test_vcs_unavailable_returns_vcs_error_page(app, backend, app_settings):
35 import rhodecode
36 from rhodecode.lib.vcs.exceptions import VCSCommunicationError
37
38 # 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 # if http or pyro4 is used, it just requires the exception to be raised.
41 vcs_protocol = app_settings['vcs.server.protocol']
42 if vcs_protocol == 'http':
43 from rhodecode.lib.vcs.client_http import RemoteRepo
44 elif vcs_protocol == 'pyro4':
45 from rhodecode.lib.vcs.client import RemoteRepo
46 else:
47 pytest.fail('Unknown VCS server protocol: "{}"'.format(vcs_protocol))
48
38 url = '/{repo_name}'.format(repo_name=backend.repo.repo_name)
49 url = '/{repo_name}'.format(repo_name=backend.repo.repo_name)
39
50
40 # Path the get proxy method to raise an exception instead of making a RPC
51 # Patch remote repo to raise an exception instead of making a RPC.
41 # call to the vcsserver.
52 with mock.patch.object(RemoteRepo, '__getattr__') as remote_mock:
42 with mock.patch.object(client, '_get_proxy_method') as p:
53 remote_mock.side_effect = VCSCommunicationError()
43 p.side_effect = client.exceptions.PyroVCSCommunicationError()
44 # Patch pylons error handling middleware to not re-raise exceptions.
54 # Patch pylons error handling middleware to not re-raise exceptions.
45 with mock.patch.object(PylonsErrorHandlingMiddleware, 'reraise') as r:
55 with mock.patch.object(PylonsErrorHandlingMiddleware, 'reraise') as r:
46 r.return_value = False
56 r.return_value = False
General Comments 0
You need to be logged in to leave comments. Login now