-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathtest_options.py
More file actions
23 lines (21 loc) · 928 Bytes
/
test_options.py
File metadata and controls
23 lines (21 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import typing as t
import pytest
from sqlmesh_dbt.options import YamlParamType
from click.exceptions import BadParameter
@pytest.mark.parametrize(
"input,expected",
[
(1, BadParameter("Input value '1' should be a string")),
("", BadParameter("String '' is not valid YAML")),
("['a', 'b']", BadParameter("String.*did not evaluate to a dict, got.*")),
("foo: bar", {"foo": "bar"}),
('{"key": "value", "date": 20180101}', {"key": "value", "date": 20180101}),
("{key: value, date: 20180101}", {"key": "value", "date": 20180101}),
],
)
def test_yaml_param_type(input: str, expected: t.Union[BadParameter, t.Dict[str, t.Any]]):
if isinstance(expected, BadParameter):
with pytest.raises(BadParameter, match=expected.message):
YamlParamType().convert(input, None, None)
else:
assert YamlParamType().convert(input, None, None) == expected