-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtest_cssync.py
58 lines (45 loc) · 1.53 KB
/
test_cssync.py
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
from __future__ import annotations
from pathlib import Path
import yaml
from typer.testing import CliRunner
from diracx.cli import app
from diracx.core.config.schema import Config
runner = CliRunner()
file_path = Path(__file__).parent
def test_cs_sync(tmp_path, monkeypatch):
monkeypatch.setenv("DIRAC_COMPAT_ENABLE_CS_CONVERSION", "Yes")
output_file = tmp_path / "default.yml"
result = runner.invoke(
app,
[
"internal",
"legacy",
"cs-sync",
f"{file_path / 'integration_test.cfg'}",
str(output_file),
],
)
assert result.exit_code == 0
assert output_file.is_file()
actual_output = yaml.safe_load(output_file.read_text())
expected_output = yaml.safe_load((file_path / "integration_test.yaml").read_text())
assert actual_output == expected_output
Config.model_validate(actual_output)
def test_disabled_vos_empty(tmp_path, monkeypatch):
# # DisabledVOs cannot be set if any Legacy clients are enabled
monkeypatch.setenv("DIRAC_COMPAT_ENABLE_CS_CONVERSION", "Yes")
output_file = tmp_path / "default.yml"
result = runner.invoke(
app,
[
"internal",
"legacy",
"cs-sync",
f"{file_path / 'integration_test_buggy.cfg'}",
str(output_file),
],
)
assert result.exit_code == 1
assert not output_file.is_file()
assert isinstance(result.exception, RuntimeError)
assert "DisabledVOs cannot be set" in str(result.exception)