Skip to content

Commit

Permalink
tested
Browse files Browse the repository at this point in the history
  • Loading branch information
rabelmervin committed Nov 20, 2024
1 parent b162ff2 commit e13d509
Showing 1 changed file with 53 additions and 7 deletions.
60 changes: 53 additions & 7 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path
from typing import Literal
import pytest

from typer.testing import CliRunner
Expand All @@ -9,7 +11,7 @@
runner = CliRunner()


def test_graph(package_path):
def test_graph(package_path: Path):
result = runner.invoke(
app,
["graph", "example.base:Base", "--import-module", "example.models", "--python-dir", str(package_path)],
Expand All @@ -20,7 +22,7 @@ def test_graph(package_path):


@pytest.mark.parametrize("column_sort_arg", ["key-based", "preserve-order"])
def test_graph_column_sort(package_path, column_sort_arg):
def test_graph_column_sort(package_path: Path, column_sort_arg: Literal['key-based'] | Literal['preserve-order']):
result = runner.invoke(
app,
[
Expand All @@ -39,7 +41,7 @@ def test_graph_column_sort(package_path, column_sort_arg):
mermaid_assert(result.stdout)


def test_graph_with_exclusion(package_path):
def test_graph_with_exclusion(package_path: Path):
result = runner.invoke(
app,
[
Expand All @@ -58,7 +60,7 @@ def test_graph_with_exclusion(package_path):
assert "comments {" not in result.stdout


def test_graph_with_inclusion(package_path):
def test_graph_with_inclusion(package_path: Path):
result = runner.invoke(
app,
[
Expand All @@ -77,7 +79,7 @@ def test_graph_with_inclusion(package_path):
assert "comments {" in result.stdout


def test_inject_check(package_path):
def test_inject_check(package_path: Path):
result = runner.invoke(
app,
[
Expand All @@ -94,7 +96,7 @@ def test_inject_check(package_path):
assert result.exit_code == 1


def test_inject(package_path):
def test_inject(package_path: Path):
result = runner.invoke(
app,
[
Expand All @@ -115,7 +117,7 @@ def test_inject(package_path):


@pytest.mark.parametrize("column_sort_arg", ["key-based", "preserve-order"])
def test_inject_column_sort(package_path, column_sort_arg):
def test_inject_column_sort(package_path: Path, column_sort_arg: Literal['key-based'] | Literal['preserve-order']):
result = runner.invoke(
app,
[
Expand All @@ -140,3 +142,47 @@ def test_inject_column_sort(package_path, column_sort_arg):
def test_version():
result = runner.invoke(app, ["version"])
assert result.exit_code == 0

from click.testing import CliRunner
from paracelsus.cli import cli



def test_graph_with_inclusion_regex(package_path: Path):
result = runner.invoke(
app,
[
"graph",
"example.base:Base",
"--import-module",
"example.models",
"--python-dir",
str(package_path),
"--include-tables",
"^com.*",
],
)
assert result.exit_code == 0
assert "regular_table {" not in result.stdout
assert "first_test {" in result.stdout
assert "second{" not in result.stdout


def test_graph_with_exclusion_regex(package_path: Path):
result = runner.invoke(
app,
[
"graph",
"example.base:Base",
"--import-module",
"example.models",
"--python-dir",
str(package_path),
"--exclude-tables",
"pos.*",
],
)
assert result.exit_code == 0
assert "regular_table {" in result.stdout
assert "first {" not in result.stdout
assert "second {" in result.stdout

0 comments on commit e13d509

Please sign in to comment.