forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cli_local.py
More file actions
61 lines (47 loc) · 1.97 KB
/
Copy pathtest_cli_local.py
File metadata and controls
61 lines (47 loc) · 1.97 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
import subprocess
import sys
import tempfile
from pathlib import Path
from textwrap import dedent
from typing import List
from feast import cli
from tests.cli.online_read_write_test import basic_rw_test
class CliRunner:
"""
NB. We can't use test runner helper from click here, since it doesn't start a new Python
interpreter. And we need a new interpreter for each test since we dynamically import
modules from the feature repo, and it is hard to clean up that state otherwise.
"""
def run(self, args: List[str], cwd: Path) -> subprocess.CompletedProcess:
return subprocess.run([sys.executable, cli.__file__] + args, cwd=cwd)
class TestCliLocal:
def test_basic(self) -> None:
runner = CliRunner()
with tempfile.TemporaryDirectory() as repo_dir_name, tempfile.TemporaryDirectory() as data_dir_name:
repo_path = Path(repo_dir_name)
data_path = Path(data_dir_name)
repo_config = repo_path / "feature_store.yaml"
repo_config.write_text(
dedent(
f"""
project: foo
metadata_store: {data_path / "metadata.db"}
provider: local
online_store:
local:
path: {data_path / "online_store.db"}
"""
)
)
repo_example = repo_path / "example.py"
repo_example.write_text(
(Path(__file__).parent / "example_feature_repo_1.py").read_text()
)
result = runner.run(["apply", str(repo_path)], cwd=repo_path)
assert result.returncode == 0
# Doing another apply should be a no op, and should not cause errors
result = runner.run(["apply", str(repo_path)], cwd=repo_path)
assert result.returncode == 0
basic_rw_test(repo_path, "foo")
result = runner.run(["teardown", str(repo_path)], cwd=repo_path)
assert result.returncode == 0