Skip to content

Commit 42a0727

Browse files
author
Roxanne Farhad
committed
update the tests
1 parent 7881ec2 commit 42a0727

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/agentex/lib/sdk/config/environment_config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_config_for_env(self, env_name: str) -> AgentEnvironmentConfig:
118118
)
119119
return self.environments[env_name]
120120

121-
def get_configs_for_env(self, env: str) -> List[AgentEnvironmentConfig]:
121+
def get_configs_for_env(self, env: str) -> dict[str, AgentEnvironmentConfig]:
122122
"""Get configuration for a specific environment based on the expected mapping.
123123
The environment is either:
124124
1. explicitly specified like so using a key-map in the environments conifg:
@@ -154,15 +154,15 @@ def get_configs_for_env(self, env: str) -> List[AgentEnvironmentConfig]:
154154
Raises:
155155
ValueError: If environment is not found
156156
"""
157-
envs_to_deploy = []
157+
envs_to_deploy = {}
158158
if env in self.environments:
159159
# this supports if the top-level key is just "dev, staging, etc" and matches
160160
# the environment name exactly without any explicit mapping
161-
envs_to_deploy.append(self.environments[env])
161+
envs_to_deploy[env] = self.environments[env]
162162

163-
for _, config in self.environments.items():
163+
for env_name, config in self.environments.items():
164164
if config.environment == env:
165-
envs_to_deploy.append(config)
165+
envs_to_deploy[env_name] = config
166166

167167
if len(envs_to_deploy) == 0:
168168
available_envs = [env.environment for env in self.environments.values() if env.environment] + [

tests/lib/cli/test_environment_config.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,25 @@ def test_get_config_by_specific_cluster_name(self, multi_cluster_same_env_config
9393
assert result is not None
9494

9595
def test_get_configs_without_explicit_mapping(self, single_env_config: AgentEnvironmentsConfig):
96-
"""Test getting config without explicit mapping"""
97-
96+
"""Test getting config without explicit mapping returns a dict with env name as key."""
9897
result = single_env_config.get_configs_for_env("dev")
98+
assert isinstance(result, dict)
9999
assert len(result) == 1
100-
assert result[0] == single_env_config.get_config_for_env("dev")
100+
assert "dev" in result
101+
assert result["dev"] == single_env_config.get_config_for_env("dev")
101102

102103
def test_multiple_envs_same_keyword_returns_multiple(self, multi_cluster_same_env_config: AgentEnvironmentsConfig):
103104
"""Test that querying 'dev' when multiple envs have environment='dev' returns multiple.
104105
105-
This documents current behavior - may need to change based on design decision.
106+
Returns a dict mapping env names (dev-aws, dev-gcp) to their configs.
106107
"""
107108
result = multi_cluster_same_env_config.get_configs_for_env("dev")
108-
# Current implementation returns a list
109-
assert isinstance(result, list)
110-
assert len(result) >= 1
109+
assert isinstance(result, dict)
110+
assert len(result) == 2
111+
assert "dev-aws" in result
112+
assert "dev-gcp" in result
113+
assert result["dev-aws"].kubernetes.namespace == "dev-ns-aws"
114+
assert result["dev-gcp"].kubernetes.namespace == "dev-ns-gcp"
111115

112116
def test_list_environments(self, multi_env_config: AgentEnvironmentsConfig):
113117
"""Test listing all environment names."""

0 commit comments

Comments
 (0)