Skip to content

Commit b09c67b

Browse files
committed
Fix tests
1 parent 3ba029a commit b09c67b

File tree

2 files changed

+42
-48
lines changed

2 files changed

+42
-48
lines changed

src/tests/_internal/cli/commands/test_config.py

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from pathlib import Path
2+
from unittest.mock import patch
3+
4+
import yaml
5+
from pytest import CaptureFixture
6+
7+
from tests._internal.cli.common import run_dstack_cli
8+
9+
10+
class TestProjectAdd:
11+
def test_adds_project(self, capsys: CaptureFixture, tmp_path: Path):
12+
cli_config_path = tmp_path / ".dstack" / "config.yml"
13+
with patch("dstack.api.server.APIClient") as APIClientMock:
14+
api_client_mock = APIClientMock.return_value
15+
exit_code = run_dstack_cli(
16+
[
17+
"project",
18+
"add",
19+
"--name",
20+
"project",
21+
"--url",
22+
"http://127.0.0.1:31313",
23+
"--token",
24+
"token",
25+
"-y",
26+
],
27+
home_dir=tmp_path,
28+
)
29+
APIClientMock.assert_called_once_with(base_url="http://127.0.0.1:31313", token="token")
30+
api_client_mock.projects.get.assert_called_with("project")
31+
assert exit_code == 0
32+
assert yaml.load(cli_config_path.read_text(), yaml.FullLoader) == {
33+
"projects": [
34+
{
35+
"default": True,
36+
"name": "project",
37+
"token": "token",
38+
"url": "http://127.0.0.1:31313",
39+
}
40+
],
41+
"repos": [],
42+
}

0 commit comments

Comments
 (0)