Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions tests/test_cli_contract.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
from __future__ import annotations

import json
import re
from pathlib import Path

from typer.testing import CliRunner

from openapi_get_avro.cli import app

FIXTURES = Path(__file__).parent / "fixtures"
ANSI_ESCAPE_RE = re.compile(r"\x1b\[[0-?]*[ -/]*[@-~]")


def _strip_ansi(text: str) -> str:
return ANSI_ESCAPE_RE.sub("", text)


def test_cli_generates_expected_schema(tmp_path: Path) -> None:
Expand Down Expand Up @@ -38,13 +44,19 @@ def test_cli_generates_expected_schema(tmp_path: Path) -> None:
def test_cli_help_exposes_generation_policy_options() -> None:
runner = CliRunner()

result = runner.invoke(app, ["generate", "--help"])
result = runner.invoke(
app,
["generate", "--help"],
env={"COLUMNS": "120"},
terminal_width=120,
)

assert result.exit_code == 0
assert "--name-strategy" in result.output
assert "--any-of-policy" in result.output
assert "--enum-policy" in result.output
assert "--unknown-object-policy" in result.output
help_output = _strip_ansi(result.output)
assert "--name-strategy" in help_output
assert "--any-of-policy" in help_output
assert "--enum-policy" in help_output
assert "--unknown-object-policy" in help_output


def test_cli_include_status_codes_preserves_requested_order(tmp_path: Path) -> None:
Expand Down