# HG changeset patch # User Martin Bornhold # Date 2016-06-28 11:36:11 # Node ID afa60f33ce33c48b1e5b8f5113bcdc85afd3286d # Parent cf5b3f9cd5f068a4b81e71d133d747f8c507a21b tests: Adapt vcs test to check that the session factory returns the same session object. diff --git a/rhodecode/tests/vcs/test_client_http.py b/rhodecode/tests/vcs/test_client_http.py --- a/rhodecode/tests/vcs/test_client_http.py +++ b/rhodecode/tests/vcs/test_client_http.py @@ -76,12 +76,15 @@ def test_repo_maker_uses_session_for_ins 'http://server_and_port/endpoint', data=mock.ANY) +@mock.patch('rhodecode.lib.vcs.client_http.ThreadlocalSessionFactory') @mock.patch('rhodecode.lib.vcs.connection') -def test_connect_passes_in_the_same_session(connection, stub_session): - session_factory_patcher = mock.patch.object( - vcs, '_create_http_rpc_session', return_value=stub_session) - with session_factory_patcher: - vcs.connect_http('server_and_port') - assert connection.Hg._session == stub_session - assert connection.Svn._session == stub_session - assert connection.Git._session == stub_session +def test_connect_passes_in_the_same_session(connection, session_factory_class, + stub_session): + session_factory = session_factory_class.return_value + session_factory.return_value = stub_session + + vcs.connect_http('server_and_port') + + assert connection.Hg._session_factory() == stub_session + assert connection.Svn._session_factory() == stub_session + assert connection.Git._session_factory() == stub_session