MCPcopy Create free account
hub / github.com/mlco2/codecarbon / setUp

Method setUp

tests/cli/test_cli.py:16–47  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

14@patch("codecarbon.cli.main.ApiClient")
15class TestApp(unittest.TestCase):
16 def setUp(self):
17 self.runner = CliRunner()
18 self.mock_api_client = MagicMock()
19 self.mock_api_client.get_list_organizations.return_value = [
20 {"id": "1", "name": "test org Code Carbon"}
21 ]
22 self.mock_api_client.list_teams_from_organization.return_value = [
23 {"id": "1", "name": "test team Code Carbon"}
24 ]
25
26 self.mock_api_client.list_projects_from_team.return_value = [
27 {"id": "1", "name": "test project Code Carbon"}
28 ]
29 self.mock_api_client.list_experiments_from_project.return_value = [
30 {"id": "1", "name": "test experiment Code Carbon"}
31 ]
32 self.mock_api_client.create_organization.return_value = {
33 "id": "1",
34 "name": "test org Code Carbon",
35 }
36 self.mock_api_client.create_team.return_value = {
37 "id": "1",
38 "name": "test team Code Carbon",
39 }
40 self.mock_api_client.create_project.return_value = {
41 "id": "1",
42 "name": "test project Code Carbon",
43 }
44 self.mock_api_client.add_experiment.return_value = {
45 "id": "1",
46 "name": "test experiment Code Carbon",
47 }
48
49 def test_app(self, MockApiClient):
50 result = self.runner.invoke(codecarbon, ["--version"])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected