1
+ from pathlib import Path
2
+ from typing import Literal
1
3
import pytest
2
4
3
5
from typer .testing import CliRunner
9
11
runner = CliRunner ()
10
12
11
13
12
- def test_graph (package_path ):
14
+ def test_graph (package_path : Path ):
13
15
result = runner .invoke (
14
16
app ,
15
17
["graph" , "example.base:Base" , "--import-module" , "example.models" , "--python-dir" , str (package_path )],
@@ -20,7 +22,7 @@ def test_graph(package_path):
20
22
21
23
22
24
@pytest .mark .parametrize ("column_sort_arg" , ["key-based" , "preserve-order" ])
23
- def test_graph_column_sort (package_path , column_sort_arg ):
25
+ def test_graph_column_sort (package_path : Path , column_sort_arg : Literal [ "key-based" ] | Literal [ "preserve-order" ] ):
24
26
result = runner .invoke (
25
27
app ,
26
28
[
@@ -39,7 +41,7 @@ def test_graph_column_sort(package_path, column_sort_arg):
39
41
mermaid_assert (result .stdout )
40
42
41
43
42
- def test_graph_with_exclusion (package_path ):
44
+ def test_graph_with_exclusion (package_path : Path ):
43
45
result = runner .invoke (
44
46
app ,
45
47
[
@@ -58,7 +60,7 @@ def test_graph_with_exclusion(package_path):
58
60
assert "comments {" not in result .stdout
59
61
60
62
61
- def test_graph_with_inclusion (package_path ):
63
+ def test_graph_with_inclusion (package_path : Path ):
62
64
result = runner .invoke (
63
65
app ,
64
66
[
@@ -77,7 +79,7 @@ def test_graph_with_inclusion(package_path):
77
79
assert "comments {" in result .stdout
78
80
79
81
80
- def test_inject_check (package_path ):
82
+ def test_inject_check (package_path : Path ):
81
83
result = runner .invoke (
82
84
app ,
83
85
[
@@ -94,7 +96,7 @@ def test_inject_check(package_path):
94
96
assert result .exit_code == 1
95
97
96
98
97
- def test_inject (package_path ):
99
+ def test_inject (package_path : Path ):
98
100
result = runner .invoke (
99
101
app ,
100
102
[
@@ -115,7 +117,7 @@ def test_inject(package_path):
115
117
116
118
117
119
@pytest .mark .parametrize ("column_sort_arg" , ["key-based" , "preserve-order" ])
118
- def test_inject_column_sort (package_path , column_sort_arg ):
120
+ def test_inject_column_sort (package_path : Path , column_sort_arg : Literal [ "key-based" ] | Literal [ "preserve-order" ] ):
119
121
result = runner .invoke (
120
122
app ,
121
123
[
@@ -140,3 +142,43 @@ def test_inject_column_sort(package_path, column_sort_arg):
140
142
def test_version ():
141
143
result = runner .invoke (app , ["version" ])
142
144
assert result .exit_code == 0
145
+
146
+
147
+ def test_graph_with_inclusion_regex (package_path : Path ):
148
+ result = runner .invoke (
149
+ app ,
150
+ [
151
+ "graph" ,
152
+ "example.base:Base" ,
153
+ "--import-module" ,
154
+ "example.models" ,
155
+ "--python-dir" ,
156
+ str (package_path ),
157
+ "--include-tables" ,
158
+ "^com.*" ,
159
+ ],
160
+ )
161
+ assert result .exit_code == 0
162
+ assert "comments {" in result .stdout
163
+ assert "users {" not in result .stdout
164
+ assert "post{" not in result .stdout
165
+
166
+
167
+ def test_graph_with_exclusion_regex (package_path : Path ):
168
+ result = runner .invoke (
169
+ app ,
170
+ [
171
+ "graph" ,
172
+ "example.base:Base" ,
173
+ "--import-module" ,
174
+ "example.models" ,
175
+ "--python-dir" ,
176
+ str (package_path ),
177
+ "--exclude-tables" ,
178
+ "^pos*." ,
179
+ ],
180
+ )
181
+ assert result .exit_code == 0
182
+ assert "comments {" in result .stdout
183
+ assert "users {" in result .stdout
184
+ assert "post {" not in result .stdout
0 commit comments