Skip to content

Commit a19763f

Browse files
committed
ci: Improve test coverage
1 parent 70060bf commit a19763f

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

openapi_python_client/parser/properties/schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from ..errors import ParseError
88

9-
if TYPE_CHECKING:
9+
if TYPE_CHECKING: # pragma: no cover
1010
from .enum_property import EnumProperty
1111
from .model_property import ModelProperty
1212
else:

tests/test_parser/test_properties/test_model_property.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def string_property(**kwargs) -> StringProperty:
241241

242242

243243
class TestProcessProperties:
244-
def test_conflicting_properties(self, model_property):
244+
def test_conflicting_properties_different_types(self, model_property):
245245
from openapi_python_client.parser.properties import Schemas
246246
from openapi_python_client.parser.properties.model_property import _process_properties
247247

@@ -261,6 +261,22 @@ def test_conflicting_properties(self, model_property):
261261

262262
assert isinstance(result, PropertyError)
263263

264+
def test_conflicting_properties_same_types(self, model_property):
265+
from openapi_python_client.parser.properties import Schemas
266+
from openapi_python_client.parser.properties.model_property import _process_properties
267+
268+
data = oai.Schema.construct(allOf=[oai.Reference.construct(ref="First"), oai.Reference.construct(ref="Second")])
269+
schemas = Schemas(
270+
models={
271+
"First": model_property(optional_properties=[string_property(default="abc")]),
272+
"Second": model_property(optional_properties=[string_property()]),
273+
}
274+
)
275+
276+
result = _process_properties(data=data, schemas=schemas, class_name="")
277+
278+
assert isinstance(result, PropertyError)
279+
264280
def test_duplicate_properties(self, model_property):
265281
from openapi_python_client.parser.properties import Schemas
266282
from openapi_python_client.parser.properties.model_property import _process_properties
@@ -311,3 +327,25 @@ def test_mixed_requirements(self, model_property, first_nullable, second_nullabl
311327
assert result.optional_props == [expected_prop]
312328
else:
313329
assert result.required_props == [expected_prop]
330+
331+
def test_direct_properties_non_ref(self):
332+
from openapi_python_client.parser.properties import Schemas
333+
from openapi_python_client.parser.properties.model_property import _process_properties
334+
335+
data = oai.Schema.construct(
336+
allOf=[
337+
oai.Schema.construct(
338+
required=["first"],
339+
properties={
340+
"first": oai.Schema.construct(type="string"),
341+
"second": oai.Schema.construct(type="string"),
342+
},
343+
)
344+
]
345+
)
346+
schemas = Schemas()
347+
348+
result = _process_properties(data=data, schemas=schemas, class_name="")
349+
350+
assert result.optional_props == [string_property(name="second", required=False, nullable=False)]
351+
assert result.required_props == [string_property(name="first", required=True, nullable=False)]

0 commit comments

Comments
 (0)