-
Notifications
You must be signed in to change notification settings - Fork 374
Expand file tree
/
Copy pathtest_list.py
More file actions
81 lines (58 loc) · 2.73 KB
/
test_list.py
File metadata and controls
81 lines (58 loc) · 2.73 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
import typing as t
import pytest
from pathlib import Path
from click.testing import Result
pytestmark = pytest.mark.slow
def test_list(jaffle_shop_duckdb: Path, invoke_cli: t.Callable[..., Result]):
result = invoke_cli(["list"])
assert result.exit_code == 0
assert not result.exception
assert "─ jaffle_shop.orders" in result.output
assert "─ jaffle_shop.customers" in result.output
assert "─ jaffle_shop.staging.stg_payments" in result.output
assert "─ jaffle_shop.raw_orders" in result.output
def test_list_select(jaffle_shop_duckdb: Path, invoke_cli: t.Callable[..., Result]):
result = invoke_cli(["list", "--select", "raw_customers+"])
assert result.exit_code == 0
assert not result.exception
assert "─ jaffle_shop.customers" in result.output
assert "─ jaffle_shop.staging.stg_customers" in result.output
assert "─ jaffle_shop.raw_customers" in result.output
assert "─ jaffle_shop.staging.stg_payments" not in result.output
assert "─ jaffle_shop.raw_orders" not in result.output
def test_list_select_exclude(jaffle_shop_duckdb: Path, invoke_cli: t.Callable[..., Result]):
# single exclude
result = invoke_cli(["list", "--select", "raw_customers+", "--exclude", "orders"])
assert result.exit_code == 0
assert not result.exception
assert "─ jaffle_shop.customers" in result.output
assert "─ jaffle_shop.staging.stg_customers" in result.output
assert "─ jaffle_shop.raw_customers" in result.output
assert "─ jaffle_shop.orders" not in result.output
assert "─ jaffle_shop.staging.stg_payments" not in result.output
assert "─ jaffle_shop.raw_orders" not in result.output
# multiple exclude
for args in (
["--select", "stg_orders+", "--exclude", "customers", "--exclude", "orders"],
["--select", "stg_orders+", "--exclude", "customers orders"],
):
result = invoke_cli(["list", *args])
assert result.exit_code == 0
assert not result.exception
assert "─ jaffle_shop.staging.stg_orders" in result.output
assert "─ jaffle_shop.customers" not in result.output
assert "─ jaffle_shop.orders" not in result.output
def test_list_with_vars(jaffle_shop_duckdb: Path, invoke_cli: t.Callable[..., Result]):
(
jaffle_shop_duckdb / "models" / "vars_model.sql"
).write_text("""
select * from {{ ref('custom' + var('foo')) }}
""")
result = invoke_cli(["list", "--vars", "foo: ers"])
assert result.exit_code == 0
assert not result.exception
assert (
"""├── jaffle_shop.vars_model
│ └── depends_on: jaffle_shop.customers"""
in result.output
)