File tree Expand file tree Collapse file tree 2 files changed +42
-48
lines changed
src/tests/_internal/cli/commands Expand file tree Collapse file tree 2 files changed +42
-48
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments