def test_build_enum_property_conflict(): from openapi_python_client.parser.properties import Schemas, build_enum_property data = oai.Schema() schemas = Schemas() _, schemas = build_enum_property( data=data, name="Existing", required=True, schemas=schemas, enum=["a"], parent_name=None, config=Config() ) err, schemas = build_enum_property( data=data, name="Existing", required=True, schemas=schemas, enum=["a", "b"], parent_name=None, config=Config() ) assert schemas == schemas assert err == PropertyError(detail="Found conflicting enums named Existing with incompatible values.", data=data)
def test_build_enum_property_no_values(): from openapi_python_client.parser.properties import Schemas, build_enum_property data = oai.Schema() schemas = Schemas() err, schemas = build_enum_property( data=data, name="Existing", required=True, schemas=schemas, enum=[], parent_name=None, config=Config() ) assert schemas == schemas assert err == PropertyError(detail="No values provided for Enum", data=data)
def test_build_enum_property_bad_default(): from openapi_python_client.parser.properties import Schemas, build_enum_property data = oai.Schema(default="B") schemas = Schemas() err, schemas = build_enum_property( data=data, name="Existing", required=True, schemas=schemas, enum=["A"], parent_name=None, config=Config() ) assert schemas == schemas assert err == PropertyError(detail="B is an invalid default for enum Existing", data=data)
def test_build_enum_property_conflict(mocker): from openapi_python_client.parser.properties import Schemas, build_enum_property data = oai.Schema() schemas = Schemas(enums={"Existing": mocker.MagicMock()}) err, schemas = build_enum_property( data=data, name="Existing", required=True, schemas=schemas, enum=[], parent_name=None ) assert schemas == schemas assert err == PropertyError(detail="Found conflicting enums named Existing with incompatible values.", data=data)