Skip to content

Commit 1c59c6c

Browse files
committed
coverage
1 parent 80c8333 commit 1c59c6c

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_spec_format.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
class TestInvalidSpecFormats:
88
@pytest.mark.parametrize(
9-
("content", "expected_error"),
9+
("filename_suffix", "content", "expected_error"),
1010
(
11-
("not a valid openapi document", "Failed to parse OpenAPI document"),
12-
("Invalid JSON", "Invalid JSON"),
13-
("{", "Invalid YAML"),
11+
(".yaml", "not a valid openapi document", "Failed to parse OpenAPI document"),
12+
(".json", "Invalid JSON", "Invalid JSON"),
13+
(".yaml", "{", "Invalid YAML"),
1414
),
1515
ids=("invalid_openapi", "invalid_json", "invalid_yaml"),
1616
)
17-
def test_unparseable_file(self, content, expected_error):
18-
result = inline_spec_should_fail(content, add_missing_sections=False)
17+
def test_unparseable_file(self, filename_suffix, content, expected_error):
18+
result = inline_spec_should_fail(content, filename_suffix=filename_suffix, add_missing_sections=False)
1919
assert expected_error in result.output
2020

2121
def test_missing_openapi_version(self):

end_to_end_tests/functional_tests/helpers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,20 @@ def inline_spec_should_fail(
8282
openapi_spec: str,
8383
extra_args: List[str] = [],
8484
config: str = "",
85+
filename_suffix: str = "",
8586
add_missing_sections = True,
8687
) -> Result:
8788
"""Asserts that the generator could not process the spec.
8889
8990
Returns the command result, which could include stdout data or an exception.
9091
"""
9192
with generate_client_from_inline_spec(
92-
openapi_spec, extra_args, config, add_missing_sections=add_missing_sections, raise_on_error=False
93+
openapi_spec,
94+
extra_args,
95+
config,
96+
filename_suffix=filename_suffix,
97+
add_missing_sections=add_missing_sections,
98+
raise_on_error=False,
9399
) as generated_client:
94100
assert generated_client.generator_result.exit_code != 0
95101
return generated_client.generator_result

end_to_end_tests/generated_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def generate_client_from_inline_spec(
102102
openapi_spec: str,
103103
extra_args: List[str] = [],
104104
config: str = "",
105+
filename_suffix: Optional[str] = None,
105106
base_module: str = "testapi_client",
106107
add_missing_sections = True,
107108
raise_on_error: bool = True,
@@ -119,7 +120,7 @@ def generate_client_from_inline_spec(
119120
openapi_spec += "\npaths: {}\n"
120121

121122
output_path = tempfile.mkdtemp()
122-
file = tempfile.NamedTemporaryFile(delete=False)
123+
file = tempfile.NamedTemporaryFile(suffix=filename_suffix, delete=False)
123124
file.write(openapi_spec.encode('utf-8'))
124125
file.close()
125126

0 commit comments

Comments
 (0)