Loading src/edgecloud/clients/i2edge/client.py +3 −13 Original line number Diff line number Diff line Loading @@ -34,19 +34,9 @@ class EdgeApplicationManager(EdgeCloudManagementInterface): def get_edge_cloud_zones( self, region: Optional[str] = None, status: Optional[str] = None ) -> list[dict]: # Note: status is not supported by i2Edge; won't be used # XXX Currently coded: region == av_zone. Is this correct? try: params = {} if region is not None: url = "{}/zone/{}".format(self.base_url, region) if status is not None: params["status"] = status response = i2edge_get(url, params=params) else: url = "{}/zones/list".format(self.base_url) if status is not None: params["status"] = status params = {} try: response = i2edge_get(url, params=params) log.info("Availability zones retrieved successfully") return response Loading tests/test_edgecloud_clients.py +8 −43 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ def test_factory_edgecloud(client_name, base_url): """ Test the factory pattern for the edgecloud client. """ # Map client names to their corresponding client classes client_class_map = { "i2edge": I2EdgeClient, "aeros": AerosClient, Loading @@ -47,52 +46,18 @@ def test_get_edge_cloud_zones(client_name, base_url): """ Test the format of the response from get_edge_cloud_zones for each client. """ # Create the edgecloud client edgecloud_platform = EdgeCloudFactory.create_edgecloud_client( client_name, base_url ) # Case 1: status & region (which are optional) not specified try: zones = edgecloud_platform.get_edge_cloud_zones() assert isinstance( zones, list ), f"Expected a list of zones for {client_name}, but got {type(zones)}" if zones: # Check content if the list is not empty assert all( isinstance(zone, dict) for zone in zones ), "Each zone should be a dictionary" # Case 2: region specified zones = edgecloud_platform.get_edge_cloud_zones(region="Omega") assert isinstance( zones, dict ), ( ( f"Expected a dict for {client_name} when region is specified, " f"but got {type(zones)}" ) ) # Case 3: status specified zones = edgecloud_platform.get_edge_cloud_zones(status="active") assert isinstance( zones, list ), f"Expected a list of zones for {client_name}, but got {type(zones)}" if zones: # Check content if the list is not empty assert all( isinstance(zone, dict) for zone in zones ), "Each zone should be a dictionary" # Case 4: status & region specified zones = edgecloud_platform.get_edge_cloud_zones( region="Omega", status="active" ) assert isinstance( zones, dict ), ( f"Expected a dict for {client_name} when region & status is specified, " f"but got {type(zones)}" ) assert isinstance(zones, list) for zone in zones: assert "zoneId" in zone assert "geographyDetails" in zone except I2EdgeError as e: pytest.fail(f"Failed to retrieve zones: {e}") ####################################### Loading Loading
src/edgecloud/clients/i2edge/client.py +3 −13 Original line number Diff line number Diff line Loading @@ -34,19 +34,9 @@ class EdgeApplicationManager(EdgeCloudManagementInterface): def get_edge_cloud_zones( self, region: Optional[str] = None, status: Optional[str] = None ) -> list[dict]: # Note: status is not supported by i2Edge; won't be used # XXX Currently coded: region == av_zone. Is this correct? try: params = {} if region is not None: url = "{}/zone/{}".format(self.base_url, region) if status is not None: params["status"] = status response = i2edge_get(url, params=params) else: url = "{}/zones/list".format(self.base_url) if status is not None: params["status"] = status params = {} try: response = i2edge_get(url, params=params) log.info("Availability zones retrieved successfully") return response Loading
tests/test_edgecloud_clients.py +8 −43 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ def test_factory_edgecloud(client_name, base_url): """ Test the factory pattern for the edgecloud client. """ # Map client names to their corresponding client classes client_class_map = { "i2edge": I2EdgeClient, "aeros": AerosClient, Loading @@ -47,52 +46,18 @@ def test_get_edge_cloud_zones(client_name, base_url): """ Test the format of the response from get_edge_cloud_zones for each client. """ # Create the edgecloud client edgecloud_platform = EdgeCloudFactory.create_edgecloud_client( client_name, base_url ) # Case 1: status & region (which are optional) not specified try: zones = edgecloud_platform.get_edge_cloud_zones() assert isinstance( zones, list ), f"Expected a list of zones for {client_name}, but got {type(zones)}" if zones: # Check content if the list is not empty assert all( isinstance(zone, dict) for zone in zones ), "Each zone should be a dictionary" # Case 2: region specified zones = edgecloud_platform.get_edge_cloud_zones(region="Omega") assert isinstance( zones, dict ), ( ( f"Expected a dict for {client_name} when region is specified, " f"but got {type(zones)}" ) ) # Case 3: status specified zones = edgecloud_platform.get_edge_cloud_zones(status="active") assert isinstance( zones, list ), f"Expected a list of zones for {client_name}, but got {type(zones)}" if zones: # Check content if the list is not empty assert all( isinstance(zone, dict) for zone in zones ), "Each zone should be a dictionary" # Case 4: status & region specified zones = edgecloud_platform.get_edge_cloud_zones( region="Omega", status="active" ) assert isinstance( zones, dict ), ( f"Expected a dict for {client_name} when region & status is specified, " f"but got {type(zones)}" ) assert isinstance(zones, list) for zone in zones: assert "zoneId" in zone assert "geographyDetails" in zone except I2EdgeError as e: pytest.fail(f"Failed to retrieve zones: {e}") ####################################### Loading