-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathtest_variable.py
More file actions
51 lines (34 loc) · 1.04 KB
/
test_variable.py
File metadata and controls
51 lines (34 loc) · 1.04 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
import pytest
from databricks.bundles.core import Variable
from databricks.bundles.core._variable import variables
@variables
class MyVariables:
foo: Variable[str]
unresolved_foo: "Variable[str]"
def test_my_variables():
assert MyVariables.foo == Variable(
path="var.foo",
type=str,
)
def test_my_variables_unresolved():
assert MyVariables.unresolved_foo == Variable(
path="var.unresolved_foo",
type=str,
)
def test_my_variables_untyped():
with pytest.raises(ValueError) as exc_info:
@variables
class UntypedVariables: # noqa
foo: Variable
[msg] = exc_info.value.args
assert msg == "Variable type must be specified for 'foo', e.g. Variable[str]"
def test_bad_type():
with pytest.raises(ValueError) as exc_info:
@variables
class BadType: # noqa
foo: str
[msg] = exc_info.value.args
assert (
msg
== "Only 'Variable' type is allowed in classes annotated with @variables, got <class 'str'>"
)