Debian Codegraph @

tests/test_input.py

raw symbols SCIP
1 """Test inputs."""
2
3 import pytest
4
5 from annotatedyaml import Input, UndefinedSubstitution, extract_inputs, substitute
6
7
8 def test_extract_inputs() -> None:
9 """Test extracting inputs from data."""
10 assert extract_inputs(Input("hello")) == {"hello"}
11 assert extract_inputs({"info": [1, Input("hello"), 2, Input("world")]}) == {
12 "hello",
13 "world",
14 }
15
16
17 def test_substitute() -> None:
18 """Test we can substitute."""
19 assert substitute(Input("hello"), {"hello": 5}) == 5
20
21 with pytest.raises(UndefinedSubstitution):
22 substitute(Input("hello"), {})
23
24 assert substitute(
25 {"info": [1, Input("hello"), 2, Input("world")]},
26 {"hello": 5, "world": 10},
27 ) == {"info": [1, 5, 2, 10]}