tests: Fix tests that depend on the default value of 'pyro4' as backend.

This commit is contained in:
Martin Bornhold 2016-10-04 14:37:09 +02:00
parent d3fd4efbe1
commit 8279f376a9
2 changed files with 24 additions and 7 deletions

View file

@ -318,18 +318,18 @@ class TestHttpHooksCallbackDaemon(object):
class TestPrepareHooksDaemon(object):
def test_returns_dummy_hooks_callback_daemon_when_using_direct_calls(self):
@pytest.mark.parametrize('protocol', ('http', 'pyro4'))
def test_returns_dummy_hooks_callback_daemon_when_using_direct_calls(
self, protocol):
expected_extras = {'extra1': 'value1'}
callback, extras = hooks_daemon.prepare_callback_daemon(
expected_extras.copy(), use_direct_calls=True)
expected_extras.copy(), protocol=protocol, use_direct_calls=True)
assert isinstance(callback, hooks_daemon.DummyHooksCallbackDaemon)
expected_extras['hooks_module'] = 'rhodecode.lib.hooks_daemon'
assert extras == expected_extras
@pytest.mark.parametrize('protocol, expected_class', (
('pyro4', hooks_daemon.Pyro4HooksCallbackDaemon),
('Pyro4', hooks_daemon.Pyro4HooksCallbackDaemon),
('HTTP', hooks_daemon.HttpHooksCallbackDaemon),
('http', hooks_daemon.HttpHooksCallbackDaemon)
))
def test_returns_real_hooks_callback_daemon_when_protocol_is_specified(
@ -339,13 +339,30 @@ class TestPrepareHooksDaemon(object):
'hooks_protocol': protocol.lower()
}
callback, extras = hooks_daemon.prepare_callback_daemon(
expected_extras.copy(), protocol=protocol)
expected_extras.copy(), protocol=protocol, use_direct_calls=False)
assert isinstance(callback, expected_class)
hooks_uri = extras.pop('hooks_uri')
assert extras == expected_extras
if protocol.lower() == 'pyro4':
assert hooks_uri.startswith('PYRO')
@pytest.mark.parametrize('protocol', (
'invalid',
'Pyro4',
'Http',
'HTTP',
))
def test_raises_on_invalid_protocol(self, protocol):
expected_extras = {
'extra1': 'value1',
'hooks_protocol': protocol.lower()
}
with pytest.raises(Exception):
callback, extras = hooks_daemon.prepare_callback_daemon(
expected_extras.copy(),
protocol=protocol,
use_direct_calls=False)
class MockRequest(object):
def __init__(self, request):

View file

@ -46,7 +46,7 @@ def test_vcs_connections_have_a_timeout_set(pylonsapp, short_timeout):
with pytest.raises(TimeoutError):
# TODO: johbo: Find a better way to set this number
for number in xrange(100):
server = create_vcsserver_proxy(server_and_port)
server = create_vcsserver_proxy(server_and_port, protocol='pyro4')
server.ping()
proxy_objects.append(server)
@ -54,7 +54,7 @@ def test_vcs_connections_have_a_timeout_set(pylonsapp, short_timeout):
def test_vcs_remote_calls_are_bound_by_timeout(pylonsapp, short_timeout):
server_and_port = pylonsapp.config['vcs.server']
with pytest.raises(TimeoutError):
server = create_vcsserver_proxy(server_and_port)
server = create_vcsserver_proxy(server_and_port, protocol='pyro4')
server.sleep(short_timeout + 1.0)