Repository navigation
Expand file tree
/
Copy pathtest_ops_setup.py
More file actions
62 lines (44 loc) · 2.05 KB
/
Copy pathtest_ops_setup.py
File metadata and controls
62 lines (44 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""Tests for psa ops setup command."""
from unittest.mock import MagicMock, patch
from typer.testing import CliRunner
from psa.cli import app as psa_app
from psa.core.config import OpsConfig, PsaConfig
runner = CliRunner()
class TestOpsSetup:
"""Test that 'psa ops setup --url' invokes ops-mode init."""
@patch("psa.commands.init._init_ops_mode")
@patch("psa.commands.init.get_config")
def test_ops_setup_calls_ops_mode(self, mock_get_config, mock_ops_mode):
mock_config = PsaConfig(ops=OpsConfig())
mock_get_config.return_value = mock_config
result = runner.invoke(psa_app, ["ops", "setup", "--url", "http://ops:8000", "--role", "app", "--yes"])
mock_ops_mode.assert_called_once_with(
mock_config, "http://ops:8000", None, "app", True
)
@patch("psa.commands.init._init_ops_mode")
@patch("psa.commands.init.get_config")
def test_ops_setup_passes_environment_id(self, mock_get_config, mock_ops_mode):
mock_config = PsaConfig(ops=OpsConfig())
mock_get_config.return_value = mock_config
result = runner.invoke(psa_app, [
"ops", "setup",
"--url", "http://ops:8000",
"--environment-id", "env-123",
"--role", "web",
"--yes",
])
mock_ops_mode.assert_called_once_with(
mock_config, "http://ops:8000", "env-123", "web", True
)
def test_ops_setup_requires_url(self):
result = runner.invoke(psa_app, ["ops", "setup"])
assert result.exit_code != 0
class TestConfigSetupStandalone:
"""Test that 'psa config setup' stays standalone-only."""
@patch("psa.commands.init._init_standalone_mode")
@patch("psa.commands.init.get_config")
def test_config_setup_calls_standalone(self, mock_get_config, mock_standalone):
mock_config = PsaConfig(ops=OpsConfig())
mock_get_config.return_value = mock_config
result = runner.invoke(psa_app, ["config", "setup", "--yes"])
mock_standalone.assert_called_once_with(mock_config, None, None, True)