Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit-cty committed Dec 18, 2024
1 parent edb45db commit 135fb7a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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",
Expand All @@ -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]",
Expand Down

0 comments on commit 135fb7a

Please sign in to comment.