fix: removed the diff when default profile changes. Printed the current profile info instead (#92)
This commit is contained in:
+40
-27
@@ -28,53 +28,66 @@ def test_read_write_config(mock_profile_config_path, profile_factory):
|
||||
assert read_config() == profiles
|
||||
|
||||
|
||||
def test_ensure_config_create_profiles_file_with_default_profile(
|
||||
def test_ensure_config_create_profiles_file_with_default_profile_with_name_default(
|
||||
mock_profile_config_path, mock_default_model_configuration
|
||||
):
|
||||
assert not mock_profile_config_path.exists()
|
||||
|
||||
ensure_config(name="default")
|
||||
(profile_name, profile) = ensure_config(name=None)
|
||||
|
||||
expected_profile = default_profile(*mock_default_model_configuration())
|
||||
|
||||
assert profile_name == "default"
|
||||
assert profile == expected_profile
|
||||
assert mock_profile_config_path.exists()
|
||||
|
||||
assert read_config() == {"default": default_profile(*mock_default_model_configuration())}
|
||||
assert read_config() == {"default": expected_profile}
|
||||
|
||||
|
||||
def test_ensure_config_add_default_profile(mock_profile_config_path, profile_factory, mock_default_model_configuration):
|
||||
def test_ensure_config_create_profiles_file_with_default_profile_with_profile_name(
|
||||
mock_profile_config_path, mock_default_model_configuration
|
||||
):
|
||||
assert not mock_profile_config_path.exists()
|
||||
|
||||
(profile_name, profile) = ensure_config(name="my_profile")
|
||||
|
||||
expected_profile = default_profile(*mock_default_model_configuration())
|
||||
|
||||
assert profile_name == "my_profile"
|
||||
assert profile == expected_profile
|
||||
assert mock_profile_config_path.exists()
|
||||
assert read_config() == {"my_profile": expected_profile}
|
||||
|
||||
|
||||
def test_ensure_config_add_default_profile_when_profile_not_exist(
|
||||
mock_profile_config_path, profile_factory, mock_default_model_configuration
|
||||
):
|
||||
existing_profile = profile_factory({"provider": "providerA"})
|
||||
write_config({"profile1": existing_profile})
|
||||
|
||||
ensure_config(name="default")
|
||||
(profile_name, new_profile) = ensure_config(name="my_new_profile")
|
||||
|
||||
expected_profile = default_profile(*mock_default_model_configuration())
|
||||
assert profile_name == "my_new_profile"
|
||||
assert new_profile == expected_profile
|
||||
assert read_config() == {
|
||||
"profile1": existing_profile,
|
||||
"default": default_profile(*mock_default_model_configuration()),
|
||||
"my_new_profile": expected_profile,
|
||||
}
|
||||
|
||||
|
||||
@patch("goose.cli.config.Confirm.ask", return_value=True)
|
||||
def test_ensure_config_overwrite_default_profile(
|
||||
mock_confirm, mock_profile_config_path, profile_factory, mock_default_model_configuration
|
||||
def test_ensure_config_get_existing_profile_not_exist(
|
||||
mock_profile_config_path, profile_factory, mock_default_model_configuration
|
||||
):
|
||||
existing_profile = profile_factory({"provider": "providerA"})
|
||||
profile_name = "default"
|
||||
write_config({profile_name: existing_profile})
|
||||
write_config({"profile1": existing_profile})
|
||||
|
||||
expected_default_profile = default_profile(*mock_default_model_configuration())
|
||||
assert ensure_config(name="default") == expected_default_profile
|
||||
assert read_config() == {"default": expected_default_profile}
|
||||
(profile_name, profile) = ensure_config(name="profile1")
|
||||
|
||||
|
||||
@patch("goose.cli.config.Confirm.ask", return_value=False)
|
||||
def test_ensure_config_keep_original_default_profile(
|
||||
mock_confirm, mock_profile_config_path, profile_factory, mock_default_model_configuration
|
||||
):
|
||||
existing_profile = profile_factory({"provider": "providerA"})
|
||||
profile_name = "default"
|
||||
write_config({profile_name: existing_profile})
|
||||
|
||||
assert ensure_config(name="default") == existing_profile
|
||||
|
||||
assert read_config() == {"default": existing_profile}
|
||||
assert profile_name == "profile1"
|
||||
assert profile == existing_profile
|
||||
assert read_config() == {
|
||||
"profile1": existing_profile,
|
||||
}
|
||||
|
||||
|
||||
def test_session_path(mock_sessions_path):
|
||||
|
||||
Reference in New Issue
Block a user