forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_repo_config.py
More file actions
135 lines (114 loc) · 2.85 KB
/
test_repo_config.py
File metadata and controls
135 lines (114 loc) · 2.85 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import tempfile
from pathlib import Path
from textwrap import dedent
from typing import Optional
from feast.repo_config import FeastConfigError, load_repo_config
def _test_config(config_text, expect_error: Optional[str]):
"""
Try loading a repo config and check raised error against a regex.
"""
with tempfile.TemporaryDirectory() as repo_dir_name:
repo_path = Path(repo_dir_name)
repo_config = repo_path / "feature_store.yaml"
repo_config.write_text(config_text)
error = None
try:
load_repo_config(repo_path)
except FeastConfigError as e:
error = e
if expect_error is not None:
assert expect_error in str(error)
else:
print(f"error: {error}")
assert error is None
def test_local_config():
_test_config(
dedent(
"""
project: foo
registry: "registry.db"
provider: local
"""
),
expect_error=None,
)
def test_local_config_with_full_online_class():
_test_config(
dedent(
"""
project: foo
registry: "registry.db"
provider: local
online_store:
type: feast.infra.online_stores.sqlite.SqliteOnlineStore
"""
),
expect_error=None,
)
def test_gcp_config():
_test_config(
dedent(
"""
project: foo
registry: gs://registry.db
provider: gcp
"""
),
expect_error=None,
)
def test_extra_field():
_test_config(
dedent(
"""
project: foo
registry: "registry.db"
provider: local
online_store:
type: sqlite
that_field_should_not_be_here: yes
path: "online_store.db"
"""
),
expect_error="__root__ -> online_store -> that_field_should_not_be_here\n"
" extra fields not permitted (type=value_error.extra)",
)
def test_no_online_store_type():
_test_config(
dedent(
"""
project: foo
registry: "registry.db"
provider: local
online_store:
path: "blah"
"""
),
expect_error=None,
)
def test_bad_type():
_test_config(
dedent(
"""
project: foo
registry: "registry.db"
provider: local
online_store:
path: 100500
"""
),
expect_error="__root__ -> online_store -> path\n str type expected",
)
def test_no_project():
_test_config(
dedent(
"""
registry: "registry.db"
provider: local
online_store:
path: foo
"""
),
expect_error="1 validation error for RepoConfig\n"
"project\n"
" field required (type=value_error.missing)",
)