mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-21 13:58:15 +00:00
feat: add support for parsing actions list from environment variables (#346)
* feat: add support for parsing actions list from environment variables This commit introduces a new function, _parse_actions_list, to handle the parsing of a string representation of a list of tool names from environment variables. The CrewaiEnterpriseTools now utilizes this function to filter tools based on the parsed actions list, enhancing flexibility in tool selection. Additionally, a new test case is added to verify the correct usage of the environment actions list. * test: simplify environment actions list test setup This commit refactors the test for CrewaiEnterpriseTools to streamline the setup of environment variables. The environment token and actions list are now set in a single patch.dict call, improving readability and reducing redundancy in the test code.
This commit is contained in:
@@ -73,3 +73,16 @@ class TestCrewaiEnterpriseTools(unittest.TestCase):
|
||||
def test_uses_environment_token_when_no_token_provided(self):
|
||||
CrewaiEnterpriseTools(enterprise_token="")
|
||||
self.MockAdapter.assert_called_once_with(enterprise_action_token="env-token")
|
||||
|
||||
@patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"CREWAI_ENTERPRISE_TOOLS_TOKEN": "env-token",
|
||||
"CREWAI_ENTERPRISE_TOOLS_ACTIONS_LIST": '["tool1", "tool3"]',
|
||||
},
|
||||
)
|
||||
def test_uses_environment_actions_list(self):
|
||||
tools = CrewaiEnterpriseTools()
|
||||
self.assertEqual(len(tools), 2)
|
||||
self.assertEqual(tools[0].name, "tool1")
|
||||
self.assertEqual(tools[1].name, "tool3")
|
||||
|
||||
Reference in New Issue
Block a user