From 135fb7ae8b98d28b6ec93f851367e48765cf0ecf Mon Sep 17 00:00:00 2001 From: benoit-cty <4-benoit-cty@users.noreply.git.leximpact.dev> Date: Wed, 18 Dec 2024 20:03:51 +0100 Subject: [PATCH] Fix test --- tests/test_cli.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index c5fbc75c..bc495a63 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -52,12 +52,19 @@ def test_app(self, MockApiClient): self.assertIn(__app_name__, result.stdout) self.assertIn(__version__, result.stdout) + @patch("codecarbon.cli.main.get_api_key") @patch("codecarbon.cli.main.Path.exists") @patch("codecarbon.cli.main.Confirm.ask") @patch("codecarbon.cli.main.questionary_prompt") @patch("codecarbon.cli.main._get_access_token") def test_config_no_local_new_all( - self, mock_token, mock_prompt, mock_confirm, mock_path_exists, MockApiClient + self, + mock_token, + mock_prompt, + mock_confirm, + mock_path_exists, + mock_get_api_key, + MockApiClient, ): temp_dir = os.getenv("RUNNER_TEMP", tempfile.gettempdir()) temp_codecarbon_config = tempfile.NamedTemporaryFile( @@ -75,6 +82,7 @@ def side_effect_wrapper(*args, **kwargs): side_effect_wrapper.call_count = 0 mock_path_exists.side_effect = side_effect_wrapper MockApiClient.return_value = self.mock_api_client + mock_get_api_key.return_value = "api_key" mock_token.return_value = "user_token" mock_prompt.side_effect = [ "Create New Organization", @@ -88,6 +96,7 @@ def side_effect_wrapper(*args, **kwargs): ["config"], input=f"{temp_codecarbon_config.name}\n", ) + print(result) self.assertEqual(result.exit_code, 0) self.assertIn( "Creating new experiment\nExperiment name : [Code Carbon user test]",