style: Fix code formatting and improve readability

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-02-22 16:56:47 +00:00
parent 9207133413
commit 7c98269a79
2 changed files with 27 additions and 23 deletions

View File

@@ -252,6 +252,7 @@ def validate_api_keys(env_vars: Dict[str, str]) -> bool:
for key in api_keys
)
def write_env_file(folder_path: Path, env_vars: Dict[str, str]) -> None:
"""
Writes environment variables to a .env file in the specified folder.

View File

@@ -318,29 +318,32 @@ def test_flow_add_crew(mock_path_exists, mock_create_embedded_crew, runner):
assert isinstance(call_kwargs["parent_folder"], Path)
@pytest.mark.parametrize("provider,model,api_key,has_valid_keys,expected_outputs", [
(
"mistral",
TEST_CONSTANTS["MISTRAL_MODEL"],
TEST_CONSTANTS["MISTRAL_API_KEY"],
True,
["API keys and model saved", f"Selected model: {TEST_CONSTANTS['MISTRAL_MODEL']}"]
),
(
"mistral",
TEST_CONSTANTS["MISTRAL_MODEL"],
TEST_CONSTANTS["EMPTY_KEY"],
False,
["No API keys provided", f"Selected model: {TEST_CONSTANTS['MISTRAL_MODEL']}"]
),
(
"mistral",
None,
TEST_CONSTANTS["EMPTY_KEY"],
False,
["No model selected"]
),
])
@pytest.mark.parametrize(
"provider,model,api_key,has_valid_keys,expected_outputs",
[
(
"mistral",
TEST_CONSTANTS["MISTRAL_MODEL"],
TEST_CONSTANTS["MISTRAL_API_KEY"],
True,
["API keys and model saved", f"Selected model: {TEST_CONSTANTS['MISTRAL_MODEL']}"]
),
(
"mistral",
TEST_CONSTANTS["MISTRAL_MODEL"],
TEST_CONSTANTS["EMPTY_KEY"],
False,
["No API keys provided", f"Selected model: {TEST_CONSTANTS['MISTRAL_MODEL']}"]
),
(
"mistral",
None,
TEST_CONSTANTS["EMPTY_KEY"],
False,
["No model selected"]
),
]
)
@mock.patch("crewai.cli.create_crew.validate_api_keys")
@mock.patch("crewai.cli.create_crew.write_env_file")
@mock.patch("crewai.cli.create_crew.load_env_vars")