Skip to content

Commit

Permalink
Fix context mocking for CondaSession test (#13087)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard committed Sep 11, 2023
1 parent 8faf745 commit cc1dc07
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/gateways/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,15 @@ def test_get_session_with_channel_settings_no_handler(mocker):
"conda.gateways.connection.session.get_channel_name_from_url",
return_value="defaults",
)
mock_context = mocker.patch("conda.gateways.connection.session.context")
mock_context.plugin_manager.get_auth_handler.return_value = None
mock_context.channel_settings = ({"channel": "defaults", "auth": "dummy_two"},)
mock = mocker.patch(
"conda.plugins.manager.CondaPluginManager.get_auth_handler",
return_value=None,
)
mocker.patch(
"conda.base.context.Context.channel_settings",
new_callable=mocker.PropertyMock,
return_value=({"channel": "defaults", "auth": "dummy_two"},),
)

url = "https://localhost/test2"

Expand All @@ -236,10 +242,7 @@ def test_get_session_with_channel_settings_no_handler(mocker):
assert type(session_obj.auth) is CondaHttpAuth

# Make sure we tried to retrieve our auth handler in this function
assert (
mocker.call("dummy_two")
in mock_context.plugin_manager.get_auth_handler.mock_calls
)
assert mocker.call("dummy_two") in mock.mock_calls


@pytest.mark.parametrize(
Expand Down

0 comments on commit cc1dc07

Please sign in to comment.