diff --git a/AGENTS.md b/AGENTS.md index fbbf11e7c..71e734258 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,10 +35,13 @@ Before touching a subsystem, read the relevant notes in `contributing/`: `ARCHIT ## Testing Guidelines - Default to `uv run pytest`. Use markers from `tests/conftest.py` like `--runpostgres` if need to include specific tests. +- Scope the run to the change: for trivial or localized edits, run only the affected test modules, `Test*` classes, or `-k` selection instead of the whole suite. Reserve the full suite for broad or cross-cutting changes. +- Speed up large runs with `-n auto` (pytest-xdist), e.g. `uv run pytest -n auto`. - Group tests for the same unit (function/class) using `Test*` classes that mirror unit's name. - Keep tests hermetic (network disabled except localhost per `pytest.ini`); stub cloud calls with mocks. ## Commit & Pull Request Guidelines +- Name branches `issue_{issue_num}_{title}` when the work tracks an issue (e.g. `issue_3959_replicated_alb_gateways`), and `pr_{title}` otherwise. - Commit messages follow the existing style: short, imperative summaries (e.g., “Fix exclude_not_available ignored”); include rationale in the body if needed. - For PRs, describe behavior changes and link related issues. - Include screenshots or terminal output when touching UX/CLI messages or frontend flows. diff --git a/src/dstack/api/server/_backends.py b/src/dstack/api/server/_backends.py index 4e742f6f7..37afa04e0 100644 --- a/src/dstack/api/server/_backends.py +++ b/src/dstack/api/server/_backends.py @@ -46,5 +46,7 @@ def delete(self, project_name: str, backends_names: List[BackendType]): def config_info( self, project_name: str, backend_name: BackendType ) -> AnyBackendConfigWithCreds: - resp = self._request(f"/api/project/{project_name}/backends/{backend_name}/config_info") + resp = self._request( + f"/api/project/{project_name}/backends/{backend_name.value}/config_info" + ) return validate_extra_ignore(AnyBackendConfigWithCredsTagged, resp.json()) diff --git a/src/tests/api/test_backends.py b/src/tests/api/test_backends.py new file mode 100644 index 000000000..c5af11e13 --- /dev/null +++ b/src/tests/api/test_backends.py @@ -0,0 +1,22 @@ +import logging + +from dstack._internal.core.models.backends.base import BackendType +from dstack.api.server._backends import BackendsAPIClient +from tests.api.common import RequestRecorder + +AWS_CONFIG_PAYLOAD = { + "type": "aws", + "regions": ["eu-west-1"], + "creds": {"type": "access_key", "access_key": "key", "secret_key": "secret"}, +} + + +class TestBackendsAPIClientConfigInfo: + def test_renders_backend_type_value_in_path(self): + recorder = RequestRecorder(AWS_CONFIG_PAYLOAD) + client = BackendsAPIClient(_request=recorder, _logger=logging.getLogger("test")) + + result = client.config_info("main", BackendType.AWS) + + assert recorder.last_path == "/api/project/main/backends/aws/config_info" + assert result.type == "aws"