Skip to content

Commit 47b87f4

Browse files
committed
Add a test for parse error output (coverage)
1 parent b82e808 commit 47b87f4

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

end_to_end_tests/invalid_openapi.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
openapi: "3.1.0"
2+
info:
3+
title: "There's something wrong with me"
4+
version: "0.1.0"
5+
paths:
6+
"/{optional}":
7+
get:
8+
parameters:
9+
- in: "path"
10+
name: "optional"
11+
schema:
12+
type: "string"
13+
responses:
14+
"200":
15+
description: "Successful Response"
16+
content:
17+
"application/json":
18+
schema:
19+
const: "Why have a fixed response? I dunno"

end_to_end_tests/test_end_to_end.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,14 @@ def test_bad_url():
222222
assert "Could not get OpenAPI document from provided URL" in result.stdout
223223

224224

225+
def test_invalid_document():
226+
runner = CliRunner()
227+
path = Path(__file__).parent / "invalid_openapi.yaml"
228+
result = runner.invoke(app, ["generate", f"--path={path}", "--fail-on-warning"])
229+
assert result.exit_code == 1
230+
assert "Warning(s) encountered while generating" in result.stdout
231+
232+
225233
def test_custom_post_hooks():
226234
shutil.rmtree(Path.cwd() / "my-test-api-client", ignore_errors=True)
227235
runner = CliRunner()

0 commit comments

Comments
 (0)