diff --git a/guardrails/cli/configure.py b/guardrails/cli/configure.py index a8739227a..11ffdaad7 100644 --- a/guardrails/cli/configure.py +++ b/guardrails/cli/configure.py @@ -43,6 +43,8 @@ def save_configuration_file( rc_file.writelines(lines) rc_file.close() + settings._initialize() + def _get_default_token() -> str: """Get the default token from the configuration file.""" @@ -106,6 +108,7 @@ def configure( try: save_configuration_file(token, enable_metrics, remote_inferencing) + # update setting singleton logger.info("Configuration saved.") except Exception as e: logger.error("An unexpected error occured saving configuration!") diff --git a/tests/unit_tests/cli/test_configure.py b/tests/unit_tests/cli/test_configure.py index fc043462f..e241fa0f7 100644 --- a/tests/unit_tests/cli/test_configure.py +++ b/tests/unit_tests/cli/test_configure.py @@ -69,6 +69,9 @@ def test_save_configuration_file(mocker): expanduser_mock = mocker.patch("guardrails.cli.configure.expanduser") expanduser_mock.return_value = "/Home" + rcexpanduser_mock = mocker.patch("guardrails.classes.rc.expanduser") + rcexpanduser_mock.return_value = "/Home" + import os join_spy = mocker.spy(os.path, "join") @@ -88,7 +91,9 @@ def test_save_configuration_file(mocker): save_configuration_file("token", True) assert expanduser_mock.called is True - join_spy.assert_called_once_with("/Home", ".guardrailsrc") + assert rcexpanduser_mock.called is True + join_spy.assert_called_with("/Home", ".guardrailsrc") + assert join_spy.call_count == 2 assert mock_open.call_count == 1 writelines_spy.assert_called_once_with(