def test_to_string(self, mocker): from openapi_python_client.parser.properties import Property name = mocker.MagicMock() snake_case = mocker.patch("openapi_python_client.utils.snake_case") p = Property(name=name, required=True, default=None, nullable=False) get_type_string = mocker.patch.object(p, "get_type_string") assert p.to_string() == f"{snake_case(name)}: {get_type_string()}" p.required = False assert p.to_string() == f"{snake_case(name)}: {get_type_string()} = None" p.default = "TEST" assert p.to_string() == f"{snake_case(name)}: {get_type_string()} = TEST"
def test_to_string(self, mocker, default, required, expected): from openapi_python_client.parser.properties import Property name = "test" mocker.patch.object(Property, "_type_string", "TestType") p = Property(name=name, required=required, default=default, nullable=False) assert p.to_string() == expected
def test_to_string(self, mocker): from openapi_python_client.parser.properties import Property name = "test" get_type_string = mocker.patch.object(Property, "get_type_string") p = Property(name=name, required=True, default=None, nullable=False) assert p.to_string() == f"{name}: {get_type_string()}" p = Property(name=name, required=False, default=None, nullable=False) assert p.to_string() == f"{name}: {get_type_string()} = UNSET" p = Property(name=name, required=True, default=None, nullable=False) assert p.to_string() == f"{name}: {get_type_string()}" p = Property(name=name, required=True, default="TEST", nullable=False) assert p.to_string() == f"{name}: {get_type_string()} = TEST"