diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java index e5fecbb684df..d17480ee0290 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java @@ -1687,12 +1687,13 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { */ private void addSchemaToIncludedSchemaList(List includedSchemas, Schema schema) { - // if the schema is in the list, issue a warning + // if the schema is in the list, then throw an exception. + // this should never happen if(includedSchemas.contains(schema)) { - LOGGER.warn("Attempted to add a schema to the includedSchemas list twice"); - } else { - includedSchemas.add(schema); + throw new RuntimeException("Attempted to add a schema to the includedSchemas list twice"); } + + includedSchemas.add(schema); } /*** diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_allows_a_schema_which_should_validate.py new file mode 100644 index 000000000000..9d9c82d710e1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_allows_a_schema_which_should_validate.py @@ -0,0 +1,64 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate +from unit_test_api import configuration + + +class TestAdditionalpropertiesAllowsASchemaWhichShouldValidate(unittest.TestCase): + """AdditionalpropertiesAllowsASchemaWhichShouldValidate unit test stubs""" + _configuration = configuration.Configuration() + + def test_no_additional_properties_is_valid_passes(self): + # no additional properties is valid + AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + def test_an_additional_invalid_property_is_invalid_fails(self): + # an additional invalid property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + "quux": + 12, + }, + _configuration=self._configuration + ) + + def test_an_additional_valid_property_is_valid_passes(self): + # an additional valid property is valid + AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + "quux": + True, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_are_allowed_by_default.py new file mode 100644 index 000000000000..e52b193fdb34 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_are_allowed_by_default.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault +from unit_test_api import configuration + + +class TestAdditionalpropertiesAreAllowedByDefault(unittest.TestCase): + """AdditionalpropertiesAreAllowedByDefault unit test stubs""" + _configuration = configuration.Configuration() + + def test_additional_properties_are_allowed_passes(self): + # additional properties are allowed + AdditionalpropertiesAreAllowedByDefault._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + "quux": + True, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_can_exist_by_itself.py new file mode 100644 index 000000000000..3a6473f23ba0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_can_exist_by_itself.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself +from unit_test_api import configuration + + +class TestAdditionalpropertiesCanExistByItself(unittest.TestCase): + """AdditionalpropertiesCanExistByItself unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_additional_invalid_property_is_invalid_fails(self): + # an additional invalid property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AdditionalpropertiesCanExistByItself._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + def test_an_additional_valid_property_is_valid_passes(self): + # an additional valid property is valid + AdditionalpropertiesCanExistByItself._from_openapi_data( + { + "foo": + True, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_should_not_look_in_applicators.py new file mode 100644 index 000000000000..a85e54f74eac --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_additionalproperties_should_not_look_in_applicators.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators +from unit_test_api import configuration + + +class TestAdditionalpropertiesShouldNotLookInApplicators(unittest.TestCase): + """AdditionalpropertiesShouldNotLookInApplicators unit test stubs""" + _configuration = configuration.Configuration() + + def test_properties_defined_in_allof_are_not_examined_fails(self): + # properties defined in allOf are not examined + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AdditionalpropertiesShouldNotLookInApplicators._from_openapi_data( + { + "foo": + 1, + "bar": + True, + }, + _configuration=self._configuration + ) + + def test_valid_test_case_passes(self): + # valid test case + AdditionalpropertiesShouldNotLookInApplicators._from_openapi_data( + { + "foo": + False, + "bar": + True, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof.py new file mode 100644 index 000000000000..9337a2edd4cf --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof.py @@ -0,0 +1,72 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof import Allof +from unit_test_api import configuration + + +class TestAllof(unittest.TestCase): + """Allof unit test stubs""" + _configuration = configuration.Configuration() + + def test_allof_passes(self): + # allOf + Allof._from_openapi_data( + { + "foo": + "baz", + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_mismatch_first_fails(self): + # mismatch first + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Allof._from_openapi_data( + { + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_mismatch_second_fails(self): + # mismatch second + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Allof._from_openapi_data( + { + "foo": + "baz", + }, + _configuration=self._configuration + ) + + def test_wrong_type_fails(self): + # wrong type + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Allof._from_openapi_data( + { + "foo": + "baz", + "bar": + "quux", + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_combined_with_anyof_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_combined_with_anyof_oneof.py new file mode 100644 index 000000000000..56a76b5d052f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_combined_with_anyof_oneof.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_combined_with_anyof_oneof import AllofCombinedWithAnyofOneof +from unit_test_api import configuration + + +class TestAllofCombinedWithAnyofOneof(unittest.TestCase): + """AllofCombinedWithAnyofOneof unit test stubs""" + _configuration = configuration.Configuration() + + def test_allof_true_anyof_false_oneof_false_fails(self): + # allOf: true, anyOf: false, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 2, + _configuration=self._configuration + ) + + def test_allof_false_anyof_false_oneof_true_fails(self): + # allOf: false, anyOf: false, oneOf: true + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 5, + _configuration=self._configuration + ) + + def test_allof_false_anyof_true_oneof_true_fails(self): + # allOf: false, anyOf: true, oneOf: true + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 15, + _configuration=self._configuration + ) + + def test_allof_true_anyof_true_oneof_false_fails(self): + # allOf: true, anyOf: true, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 6, + _configuration=self._configuration + ) + + def test_allof_true_anyof_true_oneof_true_passes(self): + # allOf: true, anyOf: true, oneOf: true + AllofCombinedWithAnyofOneof._from_openapi_data( + 30, + _configuration=self._configuration + ) + + def test_allof_true_anyof_false_oneof_true_fails(self): + # allOf: true, anyOf: false, oneOf: true + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 10, + _configuration=self._configuration + ) + + def test_allof_false_anyof_true_oneof_false_fails(self): + # allOf: false, anyOf: true, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 3, + _configuration=self._configuration + ) + + def test_allof_false_anyof_false_oneof_false_fails(self): + # allOf: false, anyOf: false, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_simple_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_simple_types.py new file mode 100644 index 000000000000..db0c8b5b52f2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_simple_types.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_simple_types import AllofSimpleTypes +from unit_test_api import configuration + + +class TestAllofSimpleTypes(unittest.TestCase): + """AllofSimpleTypes unit test stubs""" + _configuration = configuration.Configuration() + + def test_valid_passes(self): + # valid + AllofSimpleTypes._from_openapi_data( + 25, + _configuration=self._configuration + ) + + def test_mismatch_one_fails(self): + # mismatch one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofSimpleTypes._from_openapi_data( + 35, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_base_schema.py new file mode 100644 index 000000000000..f9922161cb01 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_base_schema.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_base_schema import AllofWithBaseSchema +from unit_test_api import configuration + + +class TestAllofWithBaseSchema(unittest.TestCase): + """AllofWithBaseSchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_valid_passes(self): + # valid + AllofWithBaseSchema._from_openapi_data( + { + "foo": + "quux", + "bar": + 2, + "baz": + None, + }, + _configuration=self._configuration + ) + + def test_mismatch_first_allof_fails(self): + # mismatch first allOf + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema._from_openapi_data( + { + "bar": + 2, + "baz": + None, + }, + _configuration=self._configuration + ) + + def test_mismatch_base_schema_fails(self): + # mismatch base schema + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema._from_openapi_data( + { + "foo": + "quux", + "baz": + None, + }, + _configuration=self._configuration + ) + + def test_mismatch_both_fails(self): + # mismatch both + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema._from_openapi_data( + { + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_mismatch_second_allof_fails(self): + # mismatch second allOf + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema._from_openapi_data( + { + "foo": + "quux", + "bar": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_one_empty_schema.py new file mode 100644 index 000000000000..ac60d408568f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_one_empty_schema.py @@ -0,0 +1,32 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_one_empty_schema import AllofWithOneEmptySchema +from unit_test_api import configuration + + +class TestAllofWithOneEmptySchema(unittest.TestCase): + """AllofWithOneEmptySchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_any_data_is_valid_passes(self): + # any data is valid + AllofWithOneEmptySchema._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_the_first_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_the_first_empty_schema.py new file mode 100644 index 000000000000..5dacdfb9797b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_the_first_empty_schema.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_the_first_empty_schema import AllofWithTheFirstEmptySchema +from unit_test_api import configuration + + +class TestAllofWithTheFirstEmptySchema(unittest.TestCase): + """AllofWithTheFirstEmptySchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_string_is_invalid_fails(self): + # string is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithTheFirstEmptySchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_number_is_valid_passes(self): + # number is valid + AllofWithTheFirstEmptySchema._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_the_last_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_the_last_empty_schema.py new file mode 100644 index 000000000000..bd425c3147ca --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_the_last_empty_schema.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_the_last_empty_schema import AllofWithTheLastEmptySchema +from unit_test_api import configuration + + +class TestAllofWithTheLastEmptySchema(unittest.TestCase): + """AllofWithTheLastEmptySchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_string_is_invalid_fails(self): + # string is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithTheLastEmptySchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_number_is_valid_passes(self): + # number is valid + AllofWithTheLastEmptySchema._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_two_empty_schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_two_empty_schemas.py new file mode 100644 index 000000000000..45356cece7b2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_allof_with_two_empty_schemas.py @@ -0,0 +1,32 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_two_empty_schemas import AllofWithTwoEmptySchemas +from unit_test_api import configuration + + +class TestAllofWithTwoEmptySchemas(unittest.TestCase): + """AllofWithTwoEmptySchemas unit test stubs""" + _configuration = configuration.Configuration() + + def test_any_data_is_valid_passes(self): + # any data is valid + AllofWithTwoEmptySchemas._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof.py new file mode 100644 index 000000000000..197c3449a9e4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof import Anyof +from unit_test_api import configuration + + +class TestAnyof(unittest.TestCase): + """Anyof unit test stubs""" + _configuration = configuration.Configuration() + + def test_second_anyof_valid_passes(self): + # second anyOf valid + Anyof._from_openapi_data( + 2.5, + _configuration=self._configuration + ) + + def test_neither_anyof_valid_fails(self): + # neither anyOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Anyof._from_openapi_data( + 1.5, + _configuration=self._configuration + ) + + def test_both_anyof_valid_passes(self): + # both anyOf valid + Anyof._from_openapi_data( + 3, + _configuration=self._configuration + ) + + def test_first_anyof_valid_passes(self): + # first anyOf valid + Anyof._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof_complex_types.py new file mode 100644 index 000000000000..eeb533e61960 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof_complex_types.py @@ -0,0 +1,70 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_complex_types import AnyofComplexTypes +from unit_test_api import configuration + + +class TestAnyofComplexTypes(unittest.TestCase): + """AnyofComplexTypes unit test stubs""" + _configuration = configuration.Configuration() + + def test_second_anyof_valid_complex_passes(self): + # second anyOf valid (complex) + AnyofComplexTypes._from_openapi_data( + { + "foo": + "baz", + }, + _configuration=self._configuration + ) + + def test_neither_anyof_valid_complex_fails(self): + # neither anyOf valid (complex) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AnyofComplexTypes._from_openapi_data( + { + "foo": + 2, + "bar": + "quux", + }, + _configuration=self._configuration + ) + + def test_both_anyof_valid_complex_passes(self): + # both anyOf valid (complex) + AnyofComplexTypes._from_openapi_data( + { + "foo": + "baz", + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_first_anyof_valid_complex_passes(self): + # first anyOf valid (complex) + AnyofComplexTypes._from_openapi_data( + { + "bar": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof_with_base_schema.py new file mode 100644 index 000000000000..96e03720d645 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof_with_base_schema.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_with_base_schema import AnyofWithBaseSchema +from unit_test_api import configuration + + +class TestAnyofWithBaseSchema(unittest.TestCase): + """AnyofWithBaseSchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_one_anyof_valid_passes(self): + # one anyOf valid + AnyofWithBaseSchema._from_openapi_data( + "foobar", + _configuration=self._configuration + ) + + def test_both_anyof_invalid_fails(self): + # both anyOf invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AnyofWithBaseSchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_mismatch_base_schema_fails(self): + # mismatch base schema + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AnyofWithBaseSchema._from_openapi_data( + 3, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof_with_one_empty_schema.py new file mode 100644 index 000000000000..dcb2c0ea80a5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_anyof_with_one_empty_schema.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_with_one_empty_schema import AnyofWithOneEmptySchema +from unit_test_api import configuration + + +class TestAnyofWithOneEmptySchema(unittest.TestCase): + """AnyofWithOneEmptySchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_string_is_valid_passes(self): + # string is valid + AnyofWithOneEmptySchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_number_is_valid_passes(self): + # number is valid + AnyofWithOneEmptySchema._from_openapi_data( + 123, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_array_type_matches_arrays.py new file mode 100644 index 000000000000..b8bc156e18b3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_array_type_matches_arrays.py @@ -0,0 +1,82 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays +from unit_test_api import configuration + + +class TestArrayTypeMatchesArrays(unittest.TestCase): + """ArrayTypeMatchesArrays unit test stubs""" + _configuration = configuration.Configuration() + + def test_a_float_is_not_an_array_fails(self): + # a float is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_a_boolean_is_not_an_array_fails(self): + # a boolean is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_null_is_not_an_array_fails(self): + # null is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_an_object_is_not_an_array_fails(self): + # an object is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_a_string_is_not_an_array_fails(self): + # a string is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_an_array_is_an_array_passes(self): + # an array is an array + ArrayTypeMatchesArrays._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_an_integer_is_not_an_array_fails(self): + # an integer is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_boolean_type_matches_booleans.py new file mode 100644 index 000000000000..3ffb73ed957a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_boolean_type_matches_booleans.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans +from unit_test_api import configuration + + +class TestBooleanTypeMatchesBooleans(unittest.TestCase): + """BooleanTypeMatchesBooleans unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_empty_string_is_not_a_boolean_fails(self): + # an empty string is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_a_float_is_not_a_boolean_fails(self): + # a float is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_null_is_not_a_boolean_fails(self): + # null is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_zero_is_not_a_boolean_fails(self): + # zero is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_an_array_is_not_a_boolean_fails(self): + # an array is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_a_string_is_not_a_boolean_fails(self): + # a string is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_false_is_a_boolean_passes(self): + # false is a boolean + BooleanTypeMatchesBooleans._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_an_integer_is_not_a_boolean_fails(self): + # an integer is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_true_is_a_boolean_passes(self): + # true is a boolean + BooleanTypeMatchesBooleans._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_an_object_is_not_a_boolean_fails(self): + # an object is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_by_int.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_by_int.py new file mode 100644 index 000000000000..26254a7aaa81 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_by_int.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_int import ByInt +from unit_test_api import configuration + + +class TestByInt(unittest.TestCase): + """ByInt unit test stubs""" + _configuration = configuration.Configuration() + + def test_int_by_int_fail_fails(self): + # int by int fail + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ByInt._from_openapi_data( + 7, + _configuration=self._configuration + ) + + def test_int_by_int_passes(self): + # int by int + ByInt._from_openapi_data( + 10, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + ByInt._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_by_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_by_number.py new file mode 100644 index 000000000000..928b8f3c6450 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_by_number.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_number import ByNumber +from unit_test_api import configuration + + +class TestByNumber(unittest.TestCase): + """ByNumber unit test stubs""" + _configuration = configuration.Configuration() + + def test_45_is_multiple_of15_passes(self): + # 4.5 is multiple of 1.5 + ByNumber._from_openapi_data( + 4.5, + _configuration=self._configuration + ) + + def test_35_is_not_multiple_of15_fails(self): + # 35 is not multiple of 1.5 + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ByNumber._from_openapi_data( + 35, + _configuration=self._configuration + ) + + def test_zero_is_multiple_of_anything_passes(self): + # zero is multiple of anything + ByNumber._from_openapi_data( + 0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_by_small_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_by_small_number.py new file mode 100644 index 000000000000..cc683feebe2b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_by_small_number.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_small_number import BySmallNumber +from unit_test_api import configuration + + +class TestBySmallNumber(unittest.TestCase): + """BySmallNumber unit test stubs""" + _configuration = configuration.Configuration() + + def test_000751_is_not_multiple_of00001_fails(self): + # 0.00751 is not multiple of 0.0001 + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BySmallNumber._from_openapi_data( + 0.00751, + _configuration=self._configuration + ) + + def test_00075_is_multiple_of00001_passes(self): + # 0.0075 is multiple of 0.0001 + BySmallNumber._from_openapi_data( + 0.0075, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_date_time_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_date_time_format.py new file mode 100644 index 000000000000..b3a2b154373b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_date_time_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.date_time_format import DateTimeFormat +from unit_test_api import configuration + + +class TestDateTimeFormat(unittest.TestCase): + """DateTimeFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + DateTimeFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + DateTimeFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + DateTimeFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + DateTimeFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + DateTimeFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + DateTimeFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_email_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_email_format.py new file mode 100644 index 000000000000..c6b2d51c19c4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_email_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.email_format import EmailFormat +from unit_test_api import configuration + + +class TestEmailFormat(unittest.TestCase): + """EmailFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + EmailFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + EmailFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + EmailFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + EmailFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + EmailFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + EmailFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with0_does_not_match_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with0_does_not_match_false.py new file mode 100644 index 000000000000..f2917a571bca --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with0_does_not_match_false.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with0_does_not_match_false import EnumWith0DoesNotMatchFalse +from unit_test_api import configuration + + +class TestEnumWith0DoesNotMatchFalse(unittest.TestCase): + """EnumWith0DoesNotMatchFalse unit test stubs""" + _configuration = configuration.Configuration() + + def test_integer_zero_is_valid_passes(self): + # integer zero is valid + EnumWith0DoesNotMatchFalse._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_float_zero_is_valid_passes(self): + # float zero is valid + EnumWith0DoesNotMatchFalse._from_openapi_data( + 0.0, + _configuration=self._configuration + ) + + def test_false_is_invalid_fails(self): + # false is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWith0DoesNotMatchFalse._from_openapi_data( + False, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with1_does_not_match_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with1_does_not_match_true.py new file mode 100644 index 000000000000..8b4981807637 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with1_does_not_match_true.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with1_does_not_match_true import EnumWith1DoesNotMatchTrue +from unit_test_api import configuration + + +class TestEnumWith1DoesNotMatchTrue(unittest.TestCase): + """EnumWith1DoesNotMatchTrue unit test stubs""" + _configuration = configuration.Configuration() + + def test_true_is_invalid_fails(self): + # true is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWith1DoesNotMatchTrue._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_integer_one_is_valid_passes(self): + # integer one is valid + EnumWith1DoesNotMatchTrue._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_float_one_is_valid_passes(self): + # float one is valid + EnumWith1DoesNotMatchTrue._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with_escaped_characters.py new file mode 100644 index 000000000000..658588f2b0dc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with_escaped_characters.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_escaped_characters import EnumWithEscapedCharacters +from unit_test_api import configuration + + +class TestEnumWithEscapedCharacters(unittest.TestCase): + """EnumWithEscapedCharacters unit test stubs""" + _configuration = configuration.Configuration() + + def test_member2_is_valid_passes(self): + # member 2 is valid + EnumWithEscapedCharacters._from_openapi_data( + "foo\rbar", + _configuration=self._configuration + ) + + def test_member1_is_valid_passes(self): + # member 1 is valid + EnumWithEscapedCharacters._from_openapi_data( + "foo\nbar", + _configuration=self._configuration + ) + + def test_another_string_is_invalid_fails(self): + # another string is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWithEscapedCharacters._from_openapi_data( + "abc", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with_false_does_not_match0.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with_false_does_not_match0.py new file mode 100644 index 000000000000..c62d5f790918 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with_false_does_not_match0.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_false_does_not_match0 import EnumWithFalseDoesNotMatch0 +from unit_test_api import configuration + + +class TestEnumWithFalseDoesNotMatch0(unittest.TestCase): + """EnumWithFalseDoesNotMatch0 unit test stubs""" + _configuration = configuration.Configuration() + + def test_false_is_valid_passes(self): + # false is valid + EnumWithFalseDoesNotMatch0._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_float_zero_is_invalid_fails(self): + # float zero is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWithFalseDoesNotMatch0._from_openapi_data( + 0.0, + _configuration=self._configuration + ) + + def test_integer_zero_is_invalid_fails(self): + # integer zero is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWithFalseDoesNotMatch0._from_openapi_data( + 0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with_true_does_not_match1.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with_true_does_not_match1.py new file mode 100644 index 000000000000..9339856f4f5a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enum_with_true_does_not_match1.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_true_does_not_match1 import EnumWithTrueDoesNotMatch1 +from unit_test_api import configuration + + +class TestEnumWithTrueDoesNotMatch1(unittest.TestCase): + """EnumWithTrueDoesNotMatch1 unit test stubs""" + _configuration = configuration.Configuration() + + def test_float_one_is_invalid_fails(self): + # float one is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWithTrueDoesNotMatch1._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + def test_true_is_valid_passes(self): + # true is valid + EnumWithTrueDoesNotMatch1._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_integer_one_is_invalid_fails(self): + # integer one is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWithTrueDoesNotMatch1._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enums_in_properties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enums_in_properties.py new file mode 100644 index 000000000000..87c5112a3fb8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_enums_in_properties.py @@ -0,0 +1,93 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enums_in_properties import EnumsInProperties +from unit_test_api import configuration + + +class TestEnumsInProperties(unittest.TestCase): + """EnumsInProperties unit test stubs""" + _configuration = configuration.Configuration() + + def test_missing_optional_property_is_valid_passes(self): + # missing optional property is valid + EnumsInProperties._from_openapi_data( + { + "bar": + "bar", + }, + _configuration=self._configuration + ) + + def test_wrong_foo_value_fails(self): + # wrong foo value + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumsInProperties._from_openapi_data( + { + "foo": + "foot", + "bar": + "bar", + }, + _configuration=self._configuration + ) + + def test_both_properties_are_valid_passes(self): + # both properties are valid + EnumsInProperties._from_openapi_data( + { + "foo": + "foo", + "bar": + "bar", + }, + _configuration=self._configuration + ) + + def test_wrong_bar_value_fails(self): + # wrong bar value + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumsInProperties._from_openapi_data( + { + "foo": + "foo", + "bar": + "bart", + }, + _configuration=self._configuration + ) + + def test_missing_all_properties_is_invalid_fails(self): + # missing all properties is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumsInProperties._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_missing_required_property_is_invalid_fails(self): + # missing required property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumsInProperties._from_openapi_data( + { + "foo": + "foo", + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_forbidden_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_forbidden_property.py new file mode 100644 index 000000000000..b48d39902f6e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_forbidden_property.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.forbidden_property import ForbiddenProperty +from unit_test_api import configuration + + +class TestForbiddenProperty(unittest.TestCase): + """ForbiddenProperty unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_present_fails(self): + # property present + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ForbiddenProperty._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_property_absent_passes(self): + # property absent + ForbiddenProperty._from_openapi_data( + { + "bar": + 1, + "baz": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_hostname_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_hostname_format.py new file mode 100644 index 000000000000..32a6f0d003ea --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_hostname_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.hostname_format import HostnameFormat +from unit_test_api import configuration + + +class TestHostnameFormat(unittest.TestCase): + """HostnameFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + HostnameFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + HostnameFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + HostnameFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + HostnameFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + HostnameFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + HostnameFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_integer_type_matches_integers.py new file mode 100644 index 000000000000..ecf83a0586c2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_integer_type_matches_integers.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers +from unit_test_api import configuration + + +class TestIntegerTypeMatchesIntegers(unittest.TestCase): + """IntegerTypeMatchesIntegers unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_object_is_not_an_integer_fails(self): + # an object is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_a_string_is_not_an_integer_fails(self): + # a string is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_null_is_not_an_integer_fails(self): + # null is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): + # a float with zero fractional part is an integer + IntegerTypeMatchesIntegers._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + def test_a_float_is_not_an_integer_fails(self): + # a float is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_a_boolean_is_not_an_integer_fails(self): + # a boolean is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_an_integer_is_an_integer_passes(self): + # an integer is an integer + IntegerTypeMatchesIntegers._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): + # a string is still not an integer, even if it looks like one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + "1", + _configuration=self._configuration + ) + + def test_an_array_is_not_an_integer_fails(self): + # an array is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_invalid_instance_should_not_raise_error_when_float_division_inf.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_invalid_instance_should_not_raise_error_when_float_division_inf.py new file mode 100644 index 000000000000..e2b83a32ec0b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_invalid_instance_should_not_raise_error_when_float_division_inf.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.invalid_instance_should_not_raise_error_when_float_division_inf import InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf +from unit_test_api import configuration + + +class TestInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf(unittest.TestCase): + """InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf unit test stubs""" + _configuration = configuration.Configuration() + + def test_always_invalid_but_naive_implementations_may_raise_an_overflow_error_fails(self): + # always invalid, but naive implementations may raise an overflow error + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf._from_openapi_data( + 1.0E308, + _configuration=self._configuration + ) + + def test_valid_integer_with_multipleof_float_passes(self): + # valid integer with multipleOf float + InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf._from_openapi_data( + 123456789, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_invalid_string_value_for_default.py new file mode 100644 index 000000000000..50f165727b5d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_invalid_string_value_for_default.py @@ -0,0 +1,43 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault +from unit_test_api import configuration + + +class TestInvalidStringValueForDefault(unittest.TestCase): + """InvalidStringValueForDefault unit test stubs""" + _configuration = configuration.Configuration() + + def test_valid_when_property_is_specified_passes(self): + # valid when property is specified + InvalidStringValueForDefault._from_openapi_data( + { + "bar": + "good", + }, + _configuration=self._configuration + ) + + def test_still_valid_when_the_invalid_default_is_used_passes(self): + # still valid when the invalid default is used + InvalidStringValueForDefault._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ipv4_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ipv4_format.py new file mode 100644 index 000000000000..cd4cd9a69d9c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ipv4_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ipv4_format import Ipv4Format +from unit_test_api import configuration + + +class TestIpv4Format(unittest.TestCase): + """Ipv4Format unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + Ipv4Format._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + Ipv4Format._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + Ipv4Format._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + Ipv4Format._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + Ipv4Format._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + Ipv4Format._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ipv6_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ipv6_format.py new file mode 100644 index 000000000000..e9e10a489057 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ipv6_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ipv6_format import Ipv6Format +from unit_test_api import configuration + + +class TestIpv6Format(unittest.TestCase): + """Ipv6Format unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + Ipv6Format._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + Ipv6Format._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + Ipv6Format._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + Ipv6Format._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + Ipv6Format._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + Ipv6Format._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_json_pointer_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_json_pointer_format.py new file mode 100644 index 000000000000..f20c6aff949b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_json_pointer_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.json_pointer_format import JsonPointerFormat +from unit_test_api import configuration + + +class TestJsonPointerFormat(unittest.TestCase): + """JsonPointerFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + JsonPointerFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + JsonPointerFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + JsonPointerFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + JsonPointerFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + JsonPointerFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + JsonPointerFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maximum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maximum_validation.py new file mode 100644 index 000000000000..5c0e51f822af --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maximum_validation.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maximum_validation import MaximumValidation +from unit_test_api import configuration + + +class TestMaximumValidation(unittest.TestCase): + """MaximumValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_below_the_maximum_is_valid_passes(self): + # below the maximum is valid + MaximumValidation._from_openapi_data( + 2.6, + _configuration=self._configuration + ) + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MaximumValidation._from_openapi_data( + 3.0, + _configuration=self._configuration + ) + + def test_above_the_maximum_is_invalid_fails(self): + # above the maximum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MaximumValidation._from_openapi_data( + 3.5, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MaximumValidation._from_openapi_data( + "x", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maximum_validation_with_unsigned_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maximum_validation_with_unsigned_integer.py new file mode 100644 index 000000000000..4bc8a4f83722 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maximum_validation_with_unsigned_integer.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maximum_validation_with_unsigned_integer import MaximumValidationWithUnsignedInteger +from unit_test_api import configuration + + +class TestMaximumValidationWithUnsignedInteger(unittest.TestCase): + """MaximumValidationWithUnsignedInteger unit test stubs""" + _configuration = configuration.Configuration() + + def test_below_the_maximum_is_invalid_passes(self): + # below the maximum is invalid + MaximumValidationWithUnsignedInteger._from_openapi_data( + 299.97, + _configuration=self._configuration + ) + + def test_above_the_maximum_is_invalid_fails(self): + # above the maximum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MaximumValidationWithUnsignedInteger._from_openapi_data( + 300.5, + _configuration=self._configuration + ) + + def test_boundary_point_integer_is_valid_passes(self): + # boundary point integer is valid + MaximumValidationWithUnsignedInteger._from_openapi_data( + 300, + _configuration=self._configuration + ) + + def test_boundary_point_float_is_valid_passes(self): + # boundary point float is valid + MaximumValidationWithUnsignedInteger._from_openapi_data( + 300.0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxitems_validation.py new file mode 100644 index 000000000000..10804599c31c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxitems_validation.py @@ -0,0 +1,63 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxitems_validation import MaxitemsValidation +from unit_test_api import configuration + + +class TestMaxitemsValidation(unittest.TestCase): + """MaxitemsValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MaxitemsValidation._from_openapi_data( + [ + 1, + 2, + 3, + ], + _configuration=self._configuration + ) + + def test_ignores_non_arrays_passes(self): + # ignores non-arrays + MaxitemsValidation._from_openapi_data( + "foobar", + _configuration=self._configuration + ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxitemsValidation._from_openapi_data( + [ + 1, + ], + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxitemsValidation._from_openapi_data( + [ + 1, + 2, + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxlength_validation.py new file mode 100644 index 000000000000..e5871ed0f1c0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxlength_validation.py @@ -0,0 +1,61 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxlength_validation import MaxlengthValidation +from unit_test_api import configuration + + +class TestMaxlengthValidation(unittest.TestCase): + """MaxlengthValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MaxlengthValidation._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_ignores_non_strings_passes(self): + # ignores non-strings + MaxlengthValidation._from_openapi_data( + 100, + _configuration=self._configuration + ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxlengthValidation._from_openapi_data( + "f", + _configuration=self._configuration + ) + + def test_two_supplementary_unicode_code_points_is_long_enough_passes(self): + # two supplementary Unicode code points is long enough + MaxlengthValidation._from_openapi_data( + "💩💩", + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxlengthValidation._from_openapi_data( + "fo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxproperties0_means_the_object_is_empty.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxproperties0_means_the_object_is_empty.py new file mode 100644 index 000000000000..57764ac4a848 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxproperties0_means_the_object_is_empty.py @@ -0,0 +1,44 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxproperties0_means_the_object_is_empty import Maxproperties0MeansTheObjectIsEmpty +from unit_test_api import configuration + + +class TestMaxproperties0MeansTheObjectIsEmpty(unittest.TestCase): + """Maxproperties0MeansTheObjectIsEmpty unit test stubs""" + _configuration = configuration.Configuration() + + def test_no_properties_is_valid_passes(self): + # no properties is valid + Maxproperties0MeansTheObjectIsEmpty._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_one_property_is_invalid_fails(self): + # one property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Maxproperties0MeansTheObjectIsEmpty._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxproperties_validation.py new file mode 100644 index 000000000000..cd87cbfc645a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_maxproperties_validation.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxproperties_validation import MaxpropertiesValidation +from unit_test_api import configuration + + +class TestMaxpropertiesValidation(unittest.TestCase): + """MaxpropertiesValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MaxpropertiesValidation._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + "baz": + 3, + }, + _configuration=self._configuration + ) + + def test_ignores_arrays_passes(self): + # ignores arrays + MaxpropertiesValidation._from_openapi_data( + [ + 1, + 2, + 3, + ], + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + MaxpropertiesValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_ignores_strings_passes(self): + # ignores strings + MaxpropertiesValidation._from_openapi_data( + "foobar", + _configuration=self._configuration + ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxpropertiesValidation._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxpropertiesValidation._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minimum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minimum_validation.py new file mode 100644 index 000000000000..d72abd6e1f8b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minimum_validation.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minimum_validation import MinimumValidation +from unit_test_api import configuration + + +class TestMinimumValidation(unittest.TestCase): + """MinimumValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MinimumValidation._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_below_the_minimum_is_invalid_fails(self): + # below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinimumValidation._from_openapi_data( + 0.6, + _configuration=self._configuration + ) + + def test_above_the_minimum_is_valid_passes(self): + # above the minimum is valid + MinimumValidation._from_openapi_data( + 2.6, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MinimumValidation._from_openapi_data( + "x", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minimum_validation_with_signed_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minimum_validation_with_signed_integer.py new file mode 100644 index 000000000000..d4f2307a2a7f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minimum_validation_with_signed_integer.py @@ -0,0 +1,76 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minimum_validation_with_signed_integer import MinimumValidationWithSignedInteger +from unit_test_api import configuration + + +class TestMinimumValidationWithSignedInteger(unittest.TestCase): + """MinimumValidationWithSignedInteger unit test stubs""" + _configuration = configuration.Configuration() + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MinimumValidationWithSignedInteger._from_openapi_data( + -2, + _configuration=self._configuration + ) + + def test_positive_above_the_minimum_is_valid_passes(self): + # positive above the minimum is valid + MinimumValidationWithSignedInteger._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_int_below_the_minimum_is_invalid_fails(self): + # int below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinimumValidationWithSignedInteger._from_openapi_data( + -3, + _configuration=self._configuration + ) + + def test_float_below_the_minimum_is_invalid_fails(self): + # float below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinimumValidationWithSignedInteger._from_openapi_data( + -2.0001, + _configuration=self._configuration + ) + + def test_boundary_point_with_float_is_valid_passes(self): + # boundary point with float is valid + MinimumValidationWithSignedInteger._from_openapi_data( + -2.0, + _configuration=self._configuration + ) + + def test_negative_above_the_minimum_is_valid_passes(self): + # negative above the minimum is valid + MinimumValidationWithSignedInteger._from_openapi_data( + -1, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MinimumValidationWithSignedInteger._from_openapi_data( + "x", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minitems_validation.py new file mode 100644 index 000000000000..bca2643fcc8c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minitems_validation.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minitems_validation import MinitemsValidation +from unit_test_api import configuration + + +class TestMinitemsValidation(unittest.TestCase): + """MinitemsValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinitemsValidation._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_ignores_non_arrays_passes(self): + # ignores non-arrays + MinitemsValidation._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinitemsValidation._from_openapi_data( + [ + 1, + 2, + ], + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinitemsValidation._from_openapi_data( + [ + 1, + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minlength_validation.py new file mode 100644 index 000000000000..515b2958eb89 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minlength_validation.py @@ -0,0 +1,62 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minlength_validation import MinlengthValidation +from unit_test_api import configuration + + +class TestMinlengthValidation(unittest.TestCase): + """MinlengthValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinlengthValidation._from_openapi_data( + "f", + _configuration=self._configuration + ) + + def test_one_supplementary_unicode_code_point_is_not_long_enough_fails(self): + # one supplementary Unicode code point is not long enough + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinlengthValidation._from_openapi_data( + "💩", + _configuration=self._configuration + ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinlengthValidation._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_ignores_non_strings_passes(self): + # ignores non-strings + MinlengthValidation._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinlengthValidation._from_openapi_data( + "fo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minproperties_validation.py new file mode 100644 index 000000000000..b8202eb34654 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_minproperties_validation.py @@ -0,0 +1,78 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minproperties_validation import MinpropertiesValidation +from unit_test_api import configuration + + +class TestMinpropertiesValidation(unittest.TestCase): + """MinpropertiesValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + MinpropertiesValidation._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + MinpropertiesValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinpropertiesValidation._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_ignores_strings_passes(self): + # ignores strings + MinpropertiesValidation._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinpropertiesValidation._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinpropertiesValidation._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_model_not.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_model_not.py new file mode 100644 index 000000000000..7bc1095617d1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_model_not.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.model_not import ModelNot +from unit_test_api import configuration + + +class TestModelNot(unittest.TestCase): + """ModelNot unit test stubs""" + _configuration = configuration.Configuration() + + def test_allowed_passes(self): + # allowed + ModelNot._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_disallowed_fails(self): + # disallowed + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ModelNot._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_allof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_allof_to_check_validation_semantics.py new file mode 100644 index 000000000000..61cefebba043 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_allof_to_check_validation_semantics.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_allof_to_check_validation_semantics import NestedAllofToCheckValidationSemantics +from unit_test_api import configuration + + +class TestNestedAllofToCheckValidationSemantics(unittest.TestCase): + """NestedAllofToCheckValidationSemantics unit test stubs""" + _configuration = configuration.Configuration() + + def test_anything_non_null_is_invalid_fails(self): + # anything non-null is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedAllofToCheckValidationSemantics._from_openapi_data( + 123, + _configuration=self._configuration + ) + + def test_null_is_valid_passes(self): + # null is valid + NestedAllofToCheckValidationSemantics._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_anyof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_anyof_to_check_validation_semantics.py new file mode 100644 index 000000000000..9790a71c84e4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_anyof_to_check_validation_semantics.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_anyof_to_check_validation_semantics import NestedAnyofToCheckValidationSemantics +from unit_test_api import configuration + + +class TestNestedAnyofToCheckValidationSemantics(unittest.TestCase): + """NestedAnyofToCheckValidationSemantics unit test stubs""" + _configuration = configuration.Configuration() + + def test_anything_non_null_is_invalid_fails(self): + # anything non-null is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedAnyofToCheckValidationSemantics._from_openapi_data( + 123, + _configuration=self._configuration + ) + + def test_null_is_valid_passes(self): + # null is valid + NestedAnyofToCheckValidationSemantics._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_items.py new file mode 100644 index 000000000000..e6d42516d3f0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_items.py @@ -0,0 +1,129 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_items import NestedItems +from unit_test_api import configuration + + +class TestNestedItems(unittest.TestCase): + """NestedItems unit test stubs""" + _configuration = configuration.Configuration() + + def test_valid_nested_array_passes(self): + # valid nested array + NestedItems._from_openapi_data( + [ + [ + [ + [ + 1, + ], + ], + [ + [ + 2, + ], + [ + 3, + ], + ], + ], + [ + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ], + ], + _configuration=self._configuration + ) + + def test_nested_array_with_invalid_type_fails(self): + # nested array with invalid type + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedItems._from_openapi_data( + [ + [ + [ + [ + "1", + ], + ], + [ + [ + 2, + ], + [ + 3, + ], + ], + ], + [ + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ], + ], + _configuration=self._configuration + ) + + def test_not_deep_enough_fails(self): + # not deep enough + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedItems._from_openapi_data( + [ + [ + [ + 1, + ], + [ + 2, + ], + [ + 3, + ], + ], + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_oneof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_oneof_to_check_validation_semantics.py new file mode 100644 index 000000000000..48f2ffeb026c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nested_oneof_to_check_validation_semantics.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_oneof_to_check_validation_semantics import NestedOneofToCheckValidationSemantics +from unit_test_api import configuration + + +class TestNestedOneofToCheckValidationSemantics(unittest.TestCase): + """NestedOneofToCheckValidationSemantics unit test stubs""" + _configuration = configuration.Configuration() + + def test_anything_non_null_is_invalid_fails(self): + # anything non-null is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedOneofToCheckValidationSemantics._from_openapi_data( + 123, + _configuration=self._configuration + ) + + def test_null_is_valid_passes(self): + # null is valid + NestedOneofToCheckValidationSemantics._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_not_more_complex_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_not_more_complex_schema.py new file mode 100644 index 000000000000..b7ab21dadd42 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_not_more_complex_schema.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.not_more_complex_schema import NotMoreComplexSchema +from unit_test_api import configuration + + +class TestNotMoreComplexSchema(unittest.TestCase): + """NotMoreComplexSchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_other_match_passes(self): + # other match + NotMoreComplexSchema._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + def test_mismatch_fails(self): + # mismatch + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NotMoreComplexSchema._from_openapi_data( + { + "foo": + "bar", + }, + _configuration=self._configuration + ) + + def test_match_passes(self): + # match + NotMoreComplexSchema._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nul_characters_in_strings.py new file mode 100644 index 000000000000..5f9465d86872 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_nul_characters_in_strings.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nul_characters_in_strings import NulCharactersInStrings +from unit_test_api import configuration + + +class TestNulCharactersInStrings(unittest.TestCase): + """NulCharactersInStrings unit test stubs""" + _configuration = configuration.Configuration() + + def test_match_string_with_nul_passes(self): + # match string with nul + NulCharactersInStrings._from_openapi_data( + "hello\x00there", + _configuration=self._configuration + ) + + def test_do_not_match_string_lacking_nul_fails(self): + # do not match string lacking nul + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NulCharactersInStrings._from_openapi_data( + "hellothere", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_null_type_matches_only_the_null_object.py new file mode 100644 index 000000000000..0057f89b2b1c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_null_type_matches_only_the_null_object.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject +from unit_test_api import configuration + + +class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): + """NullTypeMatchesOnlyTheNullObject unit test stubs""" + _configuration = configuration.Configuration() + + def test_a_float_is_not_null_fails(self): + # a float is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_an_object_is_not_null_fails(self): + # an object is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_false_is_not_null_fails(self): + # false is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_an_integer_is_not_null_fails(self): + # an integer is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_true_is_not_null_fails(self): + # true is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_zero_is_not_null_fails(self): + # zero is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_an_empty_string_is_not_null_fails(self): + # an empty string is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_null_is_null_passes(self): + # null is null + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_an_array_is_not_null_fails(self): + # an array is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_a_string_is_not_null_fails(self): + # a string is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_number_type_matches_numbers.py new file mode 100644 index 000000000000..c71c9a01f744 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_number_type_matches_numbers.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers +from unit_test_api import configuration + + +class TestNumberTypeMatchesNumbers(unittest.TestCase): + """NumberTypeMatchesNumbers unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_array_is_not_a_number_fails(self): + # an array is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_null_is_not_a_number_fails(self): + # null is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_an_object_is_not_a_number_fails(self): + # an object is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_a_boolean_is_not_a_number_fails(self): + # a boolean is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_a_float_is_a_number_passes(self): + # a float is a number + NumberTypeMatchesNumbers._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_a_string_is_still_not_a_number_even_if_it_looks_like_one_fails(self): + # a string is still not a number, even if it looks like one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + "1", + _configuration=self._configuration + ) + + def test_a_string_is_not_a_number_fails(self): + # a string is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_an_integer_is_a_number_passes(self): + # an integer is a number + NumberTypeMatchesNumbers._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_a_float_with_zero_fractional_part_is_a_number_and_an_integer_passes(self): + # a float with zero fractional part is a number (and an integer) + NumberTypeMatchesNumbers._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_object_properties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_object_properties_validation.py new file mode 100644 index 000000000000..f4e44b15adc1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_object_properties_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.object_properties_validation import ObjectPropertiesValidation +from unit_test_api import configuration + + +class TestObjectPropertiesValidation(unittest.TestCase): + """ObjectPropertiesValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + ObjectPropertiesValidation._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + ObjectPropertiesValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_one_property_invalid_is_invalid_fails(self): + # one property invalid is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ObjectPropertiesValidation._from_openapi_data( + { + "foo": + 1, + "bar": + { + }, + }, + _configuration=self._configuration + ) + + def test_both_properties_present_and_valid_is_valid_passes(self): + # both properties present and valid is valid + ObjectPropertiesValidation._from_openapi_data( + { + "foo": + 1, + "bar": + "baz", + }, + _configuration=self._configuration + ) + + def test_doesn_t_invalidate_other_properties_passes(self): + # doesn't invalidate other properties + ObjectPropertiesValidation._from_openapi_data( + { + "quux": + [ + ], + }, + _configuration=self._configuration + ) + + def test_both_properties_invalid_is_invalid_fails(self): + # both properties invalid is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ObjectPropertiesValidation._from_openapi_data( + { + "foo": + [ + ], + "bar": + { + }, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof.py new file mode 100644 index 000000000000..5daa47d179f7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof import Oneof +from unit_test_api import configuration + + +class TestOneof(unittest.TestCase): + """Oneof unit test stubs""" + _configuration = configuration.Configuration() + + def test_second_oneof_valid_passes(self): + # second oneOf valid + Oneof._from_openapi_data( + 2.5, + _configuration=self._configuration + ) + + def test_both_oneof_valid_fails(self): + # both oneOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Oneof._from_openapi_data( + 3, + _configuration=self._configuration + ) + + def test_first_oneof_valid_passes(self): + # first oneOf valid + Oneof._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_neither_oneof_valid_fails(self): + # neither oneOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Oneof._from_openapi_data( + 1.5, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof_complex_types.py new file mode 100644 index 000000000000..16e639618c3b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof_complex_types.py @@ -0,0 +1,71 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_complex_types import OneofComplexTypes +from unit_test_api import configuration + + +class TestOneofComplexTypes(unittest.TestCase): + """OneofComplexTypes unit test stubs""" + _configuration = configuration.Configuration() + + def test_first_oneof_valid_complex_passes(self): + # first oneOf valid (complex) + OneofComplexTypes._from_openapi_data( + { + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_neither_oneof_valid_complex_fails(self): + # neither oneOf valid (complex) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + OneofComplexTypes._from_openapi_data( + { + "foo": + 2, + "bar": + "quux", + }, + _configuration=self._configuration + ) + + def test_both_oneof_valid_complex_fails(self): + # both oneOf valid (complex) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + OneofComplexTypes._from_openapi_data( + { + "foo": + "baz", + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_second_oneof_valid_complex_passes(self): + # second oneOf valid (complex) + OneofComplexTypes._from_openapi_data( + { + "foo": + "baz", + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof_with_base_schema.py new file mode 100644 index 000000000000..52e075c47c37 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof_with_base_schema.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_with_base_schema import OneofWithBaseSchema +from unit_test_api import configuration + + +class TestOneofWithBaseSchema(unittest.TestCase): + """OneofWithBaseSchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_both_oneof_valid_fails(self): + # both oneOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + OneofWithBaseSchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_mismatch_base_schema_fails(self): + # mismatch base schema + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + OneofWithBaseSchema._from_openapi_data( + 3, + _configuration=self._configuration + ) + + def test_one_oneof_valid_passes(self): + # one oneOf valid + OneofWithBaseSchema._from_openapi_data( + "foobar", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof_with_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof_with_empty_schema.py new file mode 100644 index 000000000000..66b9d79990d8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_oneof_with_empty_schema.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_with_empty_schema import OneofWithEmptySchema +from unit_test_api import configuration + + +class TestOneofWithEmptySchema(unittest.TestCase): + """OneofWithEmptySchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_both_valid_invalid_fails(self): + # both valid - invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + OneofWithEmptySchema._from_openapi_data( + 123, + _configuration=self._configuration + ) + + def test_one_valid_valid_passes(self): + # one valid - valid + OneofWithEmptySchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_pattern_is_not_anchored.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_pattern_is_not_anchored.py new file mode 100644 index 000000000000..15eb5c255868 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_pattern_is_not_anchored.py @@ -0,0 +1,32 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.pattern_is_not_anchored import PatternIsNotAnchored +from unit_test_api import configuration + + +class TestPatternIsNotAnchored(unittest.TestCase): + """PatternIsNotAnchored unit test stubs""" + _configuration = configuration.Configuration() + + def test_matches_a_substring_passes(self): + # matches a substring + PatternIsNotAnchored._from_openapi_data( + "xxaayy", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_pattern_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_pattern_validation.py new file mode 100644 index 000000000000..fc76731c8309 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_pattern_validation.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.pattern_validation import PatternValidation +from unit_test_api import configuration + + +class TestPatternValidation(unittest.TestCase): + """PatternValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + PatternValidation._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_ignores_objects_passes(self): + # ignores objects + PatternValidation._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_ignores_null_passes(self): + # ignores null + PatternValidation._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_ignores_floats_passes(self): + # ignores floats + PatternValidation._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + def test_a_non_matching_pattern_is_invalid_fails(self): + # a non-matching pattern is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + PatternValidation._from_openapi_data( + "abc", + _configuration=self._configuration + ) + + def test_ignores_booleans_passes(self): + # ignores booleans + PatternValidation._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_a_matching_pattern_is_valid_passes(self): + # a matching pattern is valid + PatternValidation._from_openapi_data( + "aaa", + _configuration=self._configuration + ) + + def test_ignores_integers_passes(self): + # ignores integers + PatternValidation._from_openapi_data( + 123, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_properties_with_escaped_characters.py new file mode 100644 index 000000000000..d7a0c7b91964 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_properties_with_escaped_characters.py @@ -0,0 +1,66 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.properties_with_escaped_characters import PropertiesWithEscapedCharacters +from unit_test_api import configuration + + +class TestPropertiesWithEscapedCharacters(unittest.TestCase): + """PropertiesWithEscapedCharacters unit test stubs""" + _configuration = configuration.Configuration() + + def test_object_with_all_numbers_is_valid_passes(self): + # object with all numbers is valid + PropertiesWithEscapedCharacters._from_openapi_data( + { + "foo\nbar": + 1, + "foo\"bar": + 1, + "foo\\bar": + 1, + "foo\rbar": + 1, + "foo\tbar": + 1, + "foo\fbar": + 1, + }, + _configuration=self._configuration + ) + + def test_object_with_strings_is_invalid_fails(self): + # object with strings is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + PropertiesWithEscapedCharacters._from_openapi_data( + { + "foo\nbar": + "1", + "foo\"bar": + "1", + "foo\\bar": + "1", + "foo\rbar": + "1", + "foo\tbar": + "1", + "foo\fbar": + "1", + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_property_named_ref_that_is_not_a_reference.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_property_named_ref_that_is_not_a_reference.py new file mode 100644 index 000000000000..2599fd45d40c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_property_named_ref_that_is_not_a_reference.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from unit_test_api import configuration + + +class TestPropertyNamedRefThatIsNotAReference(unittest.TestCase): + """PropertyNamedRefThatIsNotAReference unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + PropertyNamedRefThatIsNotAReference._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + PropertyNamedRefThatIsNotAReference._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_additionalproperties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_additionalproperties.py new file mode 100644 index 000000000000..3079918ced19 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_additionalproperties.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_additionalproperties import RefInAdditionalproperties +from unit_test_api import configuration + + +class TestRefInAdditionalproperties(unittest.TestCase): + """RefInAdditionalproperties unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInAdditionalproperties._from_openapi_data( + { + "someProp": + { + "$ref": + "a", + }, + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInAdditionalproperties._from_openapi_data( + { + "someProp": + { + "$ref": + 2, + }, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_allof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_allof.py new file mode 100644 index 000000000000..a1bcc3650913 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_allof.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_allof import RefInAllof +from unit_test_api import configuration + + +class TestRefInAllof(unittest.TestCase): + """RefInAllof unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInAllof._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInAllof._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_anyof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_anyof.py new file mode 100644 index 000000000000..33ece563af9e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_anyof.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_anyof import RefInAnyof +from unit_test_api import configuration + + +class TestRefInAnyof(unittest.TestCase): + """RefInAnyof unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInAnyof._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInAnyof._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_items.py new file mode 100644 index 000000000000..1cc69e3556ba --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_items.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_items import RefInItems +from unit_test_api import configuration + + +class TestRefInItems(unittest.TestCase): + """RefInItems unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInItems._from_openapi_data( + [ + { + "$ref": + "a", + }, + ], + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInItems._from_openapi_data( + [ + { + "$ref": + 2, + }, + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_oneof.py new file mode 100644 index 000000000000..f063204479f4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_oneof.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_oneof import RefInOneof +from unit_test_api import configuration + + +class TestRefInOneof(unittest.TestCase): + """RefInOneof unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInOneof._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInOneof._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_property.py new file mode 100644 index 000000000000..da213d35ed12 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_property.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_property import RefInProperty +from unit_test_api import configuration + + +class TestRefInProperty(unittest.TestCase): + """RefInProperty unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInProperty._from_openapi_data( + { + "a": + { + "$ref": + "a", + }, + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInProperty._from_openapi_data( + { + "a": + { + "$ref": + 2, + }, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_required_default_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_required_default_validation.py new file mode 100644 index 000000000000..c17d16842b76 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_required_default_validation.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_default_validation import RequiredDefaultValidation +from unit_test_api import configuration + + +class TestRequiredDefaultValidation(unittest.TestCase): + """RequiredDefaultValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_not_required_by_default_passes(self): + # not required by default + RequiredDefaultValidation._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_required_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_required_validation.py new file mode 100644 index 000000000000..559f0be8d52f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_required_validation.py @@ -0,0 +1,68 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_validation import RequiredValidation +from unit_test_api import configuration + + +class TestRequiredValidation(unittest.TestCase): + """RequiredValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + RequiredValidation._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_present_required_property_is_valid_passes(self): + # present required property is valid + RequiredValidation._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + RequiredValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_ignores_strings_passes(self): + # ignores strings + RequiredValidation._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_non_present_required_property_is_invalid_fails(self): + # non-present required property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RequiredValidation._from_openapi_data( + { + "bar": + 1, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_required_with_empty_array.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_required_with_empty_array.py new file mode 100644 index 000000000000..aced932c7039 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_required_with_empty_array.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_with_empty_array import RequiredWithEmptyArray +from unit_test_api import configuration + + +class TestRequiredWithEmptyArray(unittest.TestCase): + """RequiredWithEmptyArray unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_not_required_passes(self): + # property not required + RequiredWithEmptyArray._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_simple_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_simple_enum_validation.py new file mode 100644 index 000000000000..56d2746b84af --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_simple_enum_validation.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.simple_enum_validation import SimpleEnumValidation +from unit_test_api import configuration + + +class TestSimpleEnumValidation(unittest.TestCase): + """SimpleEnumValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_something_else_is_invalid_fails(self): + # something else is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + SimpleEnumValidation._from_openapi_data( + 4, + _configuration=self._configuration + ) + + def test_one_of_the_enum_is_valid_passes(self): + # one of the enum is valid + SimpleEnumValidation._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_string_type_matches_strings.py new file mode 100644 index 000000000000..807e2afe1c9c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_string_type_matches_strings.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings +from unit_test_api import configuration + + +class TestStringTypeMatchesStrings(unittest.TestCase): + """StringTypeMatchesStrings unit test stubs""" + _configuration = configuration.Configuration() + + def test_1_is_not_a_string_fails(self): + # 1 is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_a_string_is_still_a_string_even_if_it_looks_like_a_number_passes(self): + # a string is still a string, even if it looks like a number + StringTypeMatchesStrings._from_openapi_data( + "1", + _configuration=self._configuration + ) + + def test_an_empty_string_is_still_a_string_passes(self): + # an empty string is still a string + StringTypeMatchesStrings._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_a_float_is_not_a_string_fails(self): + # a float is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_an_object_is_not_a_string_fails(self): + # an object is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_an_array_is_not_a_string_fails(self): + # an array is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_a_boolean_is_not_a_string_fails(self): + # a boolean is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_null_is_not_a_string_fails(self): + # null is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_a_string_is_a_string_passes(self): + # a string is a string + StringTypeMatchesStrings._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py new file mode 100644 index 000000000000..4f8e583c41a9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing +from unit_test_api import configuration + + +class TestTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing(unittest.TestCase): + """TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing unit test stubs""" + _configuration = configuration.Configuration() + + def test_missing_properties_are_not_filled_in_with_the_default_passes(self): + # missing properties are not filled in with the default + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_an_explicit_property_value_is_checked_against_maximum_passing_passes(self): + # an explicit property value is checked against maximum (passing) + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( + { + "alpha": + 1, + }, + _configuration=self._configuration + ) + + def test_an_explicit_property_value_is_checked_against_maximum_failing_fails(self): + # an explicit property value is checked against maximum (failing) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( + { + "alpha": + 5, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uniqueitems_false_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uniqueitems_false_validation.py new file mode 100644 index 000000000000..afe2f481d7e9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uniqueitems_false_validation.py @@ -0,0 +1,246 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uniqueitems_false_validation import UniqueitemsFalseValidation +from unit_test_api import configuration + + +class TestUniqueitemsFalseValidation(unittest.TestCase): + """UniqueitemsFalseValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_non_unique_array_of_integers_is_valid_passes(self): + # non-unique array of integers is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + 1, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_objects_is_valid_passes(self): + # unique array of objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + "foo": + "bar", + }, + { + "foo": + "baz", + }, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_nested_objects_is_valid_passes(self): + # non-unique array of nested objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_objects_is_valid_passes(self): + # non-unique array of objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + "foo": + "bar", + }, + { + "foo": + "bar", + }, + ], + _configuration=self._configuration + ) + + def test_1_and_true_are_unique_passes(self): + # 1 and true are unique + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + True, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_integers_is_valid_passes(self): + # unique array of integers is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + 2, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_arrays_is_valid_passes(self): + # non-unique array of arrays is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + [ + "foo", + ], + [ + "foo", + ], + ], + _configuration=self._configuration + ) + + def test_numbers_are_unique_if_mathematically_unequal_passes(self): + # numbers are unique if mathematically unequal + UniqueitemsFalseValidation._from_openapi_data( + [ + 1.0, + 1.0, + 1, + ], + _configuration=self._configuration + ) + + def test_false_is_not_equal_to_zero_passes(self): + # false is not equal to zero + UniqueitemsFalseValidation._from_openapi_data( + [ + 0, + False, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_nested_objects_is_valid_passes(self): + # unique array of nested objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + { + "foo": + { + "bar": + { + "baz": + False, + }, + }, + }, + ], + _configuration=self._configuration + ) + + def test_0_and_false_are_unique_passes(self): + # 0 and false are unique + UniqueitemsFalseValidation._from_openapi_data( + [ + 0, + False, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_arrays_is_valid_passes(self): + # unique array of arrays is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + [ + "foo", + ], + [ + "bar", + ], + ], + _configuration=self._configuration + ) + + def test_true_is_not_equal_to_one_passes(self): + # true is not equal to one + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + True, + ], + _configuration=self._configuration + ) + + def test_non_unique_heterogeneous_types_are_valid_passes(self): + # non-unique heterogeneous types are valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + }, + [ + 1, + ], + True, + None, + { + }, + 1, + ], + _configuration=self._configuration + ) + + def test_unique_heterogeneous_types_are_valid_passes(self): + # unique heterogeneous types are valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + }, + [ + 1, + ], + True, + None, + 1, + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uniqueitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uniqueitems_validation.py new file mode 100644 index 000000000000..f4032887b692 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uniqueitems_validation.py @@ -0,0 +1,427 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uniqueitems_validation import UniqueitemsValidation +from unit_test_api import configuration + + +class TestUniqueitemsValidation(unittest.TestCase): + """UniqueitemsValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_unique_array_of_objects_is_valid_passes(self): + # unique array of objects is valid + UniqueitemsValidation._from_openapi_data( + [ + { + "foo": + "bar", + }, + { + "foo": + "baz", + }, + ], + _configuration=self._configuration + ) + + def test_a_true_and_a1_are_unique_passes(self): + # {"a": true} and {"a": 1} are unique + UniqueitemsValidation._from_openapi_data( + [ + { + "a": + True, + }, + { + "a": + 1, + }, + ], + _configuration=self._configuration + ) + + def test_non_unique_heterogeneous_types_are_invalid_fails(self): + # non-unique heterogeneous types are invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + }, + [ + 1, + ], + True, + None, + { + }, + 1, + ], + _configuration=self._configuration + ) + + def test_nested0_and_false_are_unique_passes(self): + # nested [0] and [false] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + [ + 0, + ], + "foo", + ], + [ + [ + False, + ], + "foo", + ], + ], + _configuration=self._configuration + ) + + def test_a_false_and_a0_are_unique_passes(self): + # {"a": false} and {"a": 0} are unique + UniqueitemsValidation._from_openapi_data( + [ + { + "a": + False, + }, + { + "a": + 0, + }, + ], + _configuration=self._configuration + ) + + def test_numbers_are_unique_if_mathematically_unequal_fails(self): + # numbers are unique if mathematically unequal + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + 1.0, + 1.0, + 1, + ], + _configuration=self._configuration + ) + + def test_false_is_not_equal_to_zero_passes(self): + # false is not equal to zero + UniqueitemsValidation._from_openapi_data( + [ + 0, + False, + ], + _configuration=self._configuration + ) + + def test_0_and_false_are_unique_passes(self): + # [0] and [false] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + 0, + ], + [ + False, + ], + ], + _configuration=self._configuration + ) + + def test_unique_array_of_arrays_is_valid_passes(self): + # unique array of arrays is valid + UniqueitemsValidation._from_openapi_data( + [ + [ + "foo", + ], + [ + "bar", + ], + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_nested_objects_is_invalid_fails(self): + # non-unique array of nested objects is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_more_than_two_integers_is_invalid_fails(self): + # non-unique array of more than two integers is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + 1, + 2, + 1, + ], + _configuration=self._configuration + ) + + def test_true_is_not_equal_to_one_passes(self): + # true is not equal to one + UniqueitemsValidation._from_openapi_data( + [ + 1, + True, + ], + _configuration=self._configuration + ) + + def test_objects_are_non_unique_despite_key_order_fails(self): + # objects are non-unique despite key order + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + "a": + 1, + "b": + 2, + }, + { + "b": + 2, + "a": + 1, + }, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_strings_is_valid_passes(self): + # unique array of strings is valid + UniqueitemsValidation._from_openapi_data( + [ + "foo", + "bar", + "baz", + ], + _configuration=self._configuration + ) + + def test_1_and_true_are_unique_passes(self): + # [1] and [true] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + 1, + ], + [ + True, + ], + ], + _configuration=self._configuration + ) + + def test_different_objects_are_unique_passes(self): + # different objects are unique + UniqueitemsValidation._from_openapi_data( + [ + { + "a": + 1, + "b": + 2, + }, + { + "a": + 2, + "b": + 1, + }, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_integers_is_valid_passes(self): + # unique array of integers is valid + UniqueitemsValidation._from_openapi_data( + [ + 1, + 2, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_more_than_two_arrays_is_invalid_fails(self): + # non-unique array of more than two arrays is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + [ + "foo", + ], + [ + "bar", + ], + [ + "foo", + ], + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_objects_is_invalid_fails(self): + # non-unique array of objects is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + "foo": + "bar", + }, + { + "foo": + "bar", + }, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_nested_objects_is_valid_passes(self): + # unique array of nested objects is valid + UniqueitemsValidation._from_openapi_data( + [ + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + { + "foo": + { + "bar": + { + "baz": + False, + }, + }, + }, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_arrays_is_invalid_fails(self): + # non-unique array of arrays is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + [ + "foo", + ], + [ + "foo", + ], + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_strings_is_invalid_fails(self): + # non-unique array of strings is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + "foo", + "bar", + "foo", + ], + _configuration=self._configuration + ) + + def test_nested1_and_true_are_unique_passes(self): + # nested [1] and [true] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + [ + 1, + ], + "foo", + ], + [ + [ + True, + ], + "foo", + ], + ], + _configuration=self._configuration + ) + + def test_unique_heterogeneous_types_are_valid_passes(self): + # unique heterogeneous types are valid + UniqueitemsValidation._from_openapi_data( + [ + { + }, + [ + 1, + ], + True, + None, + 1, + "{}", + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_integers_is_invalid_fails(self): + # non-unique array of integers is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + 1, + 1, + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uri_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uri_format.py new file mode 100644 index 000000000000..2f6def902438 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uri_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uri_format import UriFormat +from unit_test_api import configuration + + +class TestUriFormat(unittest.TestCase): + """UriFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + UriFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + UriFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + UriFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + UriFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + UriFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + UriFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uri_reference_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uri_reference_format.py new file mode 100644 index 000000000000..c5508b68bc6f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uri_reference_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uri_reference_format import UriReferenceFormat +from unit_test_api import configuration + + +class TestUriReferenceFormat(unittest.TestCase): + """UriReferenceFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + UriReferenceFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + UriReferenceFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + UriReferenceFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + UriReferenceFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + UriReferenceFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + UriReferenceFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uri_template_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uri_template_format.py new file mode 100644 index 000000000000..456c0794ad0c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_uri_template_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uri_template_format import UriTemplateFormat +from unit_test_api import configuration + + +class TestUriTemplateFormat(unittest.TestCase): + """UriTemplateFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + UriTemplateFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + UriTemplateFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + UriTemplateFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + UriTemplateFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + UriTemplateFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + UriTemplateFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/__init__.py new file mode 100644 index 000000000000..3d5920808059 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/__init__.py @@ -0,0 +1,68 @@ +import json +import typing + +import urllib3 +from urllib3._collections import HTTPHeaderDict + + +class ApiTestMixin: + json_content_type = 'application/json' + user_agent = 'OpenAPI-Generator/1.0.0/python' + + @classmethod + def assert_pool_manager_request_called_with( + cls, + mock_request, + url: str, + method: str = 'POST', + body: typing.Optional[bytes] = None, + content_type: typing.Optional[str] = None, + accept_content_type: typing.Optional[str] = None, + stream: bool = False, + ): + headers = { + 'User-Agent': cls.user_agent + } + if accept_content_type: + headers['Accept'] = accept_content_type + if content_type: + headers['Content-Type'] = content_type + kwargs = dict( + headers=HTTPHeaderDict(headers), + preload_content=not stream, + timeout=None, + ) + if content_type and method != 'GET': + kwargs['body'] = body + mock_request.assert_called_with( + method, + url, + **kwargs + ) + + @staticmethod + def headers_for_content_type(content_type: str) -> dict[str, str]: + return {'content-type': content_type} + + @classmethod + def response( + cls, + body: typing.Union[str, bytes], + status: int = 200, + content_type: str = json_content_type, + headers: typing.Optional[dict[str, str]] = None, + preload_content: bool = True + ) -> urllib3.HTTPResponse: + if headers is None: + headers = {} + headers.update(cls.headers_for_content_type(content_type)) + return urllib3.HTTPResponse( + body, + headers=headers, + status=status, + preload_content=preload_content + ) + + @staticmethod + def json_bytes(in_data: typing.Any) -> bytes: + return json.dumps(in_data, separators=(",", ":"), ensure_ascii=False).encode('utf-8') diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_are_allowed_by_default_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_are_allowed_by_default_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_are_allowed_by_default_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_are_allowed_by_default_request_body/test_post.py new file mode 100644 index 000000000000..cc5810bddb3a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_are_allowed_by_default_request_body/test_post.py @@ -0,0 +1,78 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_additionalproperties_are_allowed_by_default_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostAdditionalpropertiesAreAllowedByDefaultRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostAdditionalpropertiesAreAllowedByDefaultRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_additional_properties_are_allowed_passes(self): + content_type = 'application/json' + # additional properties are allowed + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + "bar": + 2, + "quux": + True, + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postAdditionalpropertiesAreAllowedByDefaultRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_can_exist_by_itself_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_can_exist_by_itself_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_can_exist_by_itself_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_can_exist_by_itself_request_body/test_post.py new file mode 100644 index 000000000000..39ee3e1f3387 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_can_exist_by_itself_request_body/test_post.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_additionalproperties_can_exist_by_itself_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostAdditionalpropertiesCanExistByItselfRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostAdditionalpropertiesCanExistByItselfRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_an_additional_invalid_property_is_invalid_fails(self): + content_type = 'application/json' + # an additional invalid property is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_additional_valid_property_is_valid_passes(self): + content_type = 'application/json' + # an additional valid property is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + True, + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postAdditionalpropertiesCanExistByItselfRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_should_not_look_in_applicators_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_should_not_look_in_applicators_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_should_not_look_in_applicators_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_should_not_look_in_applicators_request_body/test_post.py new file mode 100644 index 000000000000..bcfc1d8e01af --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_additionalproperties_should_not_look_in_applicators_request_body/test_post.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_additionalproperties_should_not_look_in_applicators_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostAdditionalpropertiesShouldNotLookInApplicatorsRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostAdditionalpropertiesShouldNotLookInApplicatorsRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_properties_defined_in_allof_are_not_examined_fails(self): + content_type = 'application/json' + # properties defined in allOf are not examined + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + "bar": + True, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_valid_test_case_passes(self): + content_type = 'application/json' + # valid test case + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + False, + "bar": + True, + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postAdditionalpropertiesShouldNotLookInApplicatorsRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_allof_simple_types_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_allof_simple_types_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_allof_simple_types_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_allof_simple_types_request_body/test_post.py new file mode 100644 index 000000000000..230e0fda24d0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_allof_simple_types_request_body/test_post.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_allof_simple_types_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostAllofSimpleTypesRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostAllofSimpleTypesRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_valid_passes(self): + content_type = 'application/json' + # valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 25 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postAllofSimpleTypesRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_mismatch_one_fails(self): + content_type = 'application/json' + # mismatch one + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 35 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_allof_with_base_schema_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_allof_with_base_schema_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_allof_with_base_schema_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_allof_with_base_schema_request_body/test_post.py new file mode 100644 index 000000000000..b06ff53af4ec --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_allof_with_base_schema_request_body/test_post.py @@ -0,0 +1,152 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_allof_with_base_schema_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostAllofWithBaseSchemaRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostAllofWithBaseSchemaRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_valid_passes(self): + content_type = 'application/json' + # valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "quux", + "bar": + 2, + "baz": + None, + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postAllofWithBaseSchemaRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_mismatch_first_allof_fails(self): + content_type = 'application/json' + # mismatch first allOf + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "bar": + 2, + "baz": + None, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_mismatch_base_schema_fails(self): + content_type = 'application/json' + # mismatch base schema + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "quux", + "baz": + None, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_mismatch_both_fails(self): + content_type = 'application/json' + # mismatch both + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "bar": + 2, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_mismatch_second_allof_fails(self): + content_type = 'application/json' + # mismatch second allOf + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "quux", + "bar": + 2, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_anyof_complex_types_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_anyof_complex_types_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_anyof_complex_types_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_anyof_complex_types_request_body/test_post.py new file mode 100644 index 000000000000..6528c59914f2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_anyof_complex_types_request_body/test_post.py @@ -0,0 +1,161 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_anyof_complex_types_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostAnyofComplexTypesRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostAnyofComplexTypesRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_second_anyof_valid_complex_passes(self): + content_type = 'application/json' + # second anyOf valid (complex) + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "baz", + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postAnyofComplexTypesRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_neither_anyof_valid_complex_fails(self): + content_type = 'application/json' + # neither anyOf valid (complex) + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 2, + "bar": + "quux", + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_both_anyof_valid_complex_passes(self): + content_type = 'application/json' + # both anyOf valid (complex) + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "baz", + "bar": + 2, + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postAnyofComplexTypesRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_first_anyof_valid_complex_passes(self): + content_type = 'application/json' + # first anyOf valid (complex) + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "bar": + 2, + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postAnyofComplexTypesRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_anyof_with_one_empty_schema_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_anyof_with_one_empty_schema_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_anyof_with_one_empty_schema_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_anyof_with_one_empty_schema_request_body/test_post.py new file mode 100644 index 000000000000..4d977e2de377 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_anyof_with_one_empty_schema_request_body/test_post.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_anyof_with_one_empty_schema_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostAnyofWithOneEmptySchemaRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostAnyofWithOneEmptySchemaRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_string_is_valid_passes(self): + content_type = 'application/json' + # string is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postAnyofWithOneEmptySchemaRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_number_is_valid_passes(self): + content_type = 'application/json' + # number is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 123 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postAnyofWithOneEmptySchemaRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_array_type_matches_arrays_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_array_type_matches_arrays_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_array_type_matches_arrays_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_array_type_matches_arrays_request_body/test_post.py new file mode 100644 index 000000000000..f0e9fb0ebe88 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_array_type_matches_arrays_request_body/test_post.py @@ -0,0 +1,157 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_array_type_matches_arrays_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostArrayTypeMatchesArraysRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostArrayTypeMatchesArraysRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_a_float_is_not_an_array_fails(self): + content_type = 'application/json' + # a float is not an array + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.1 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_boolean_is_not_an_array_fails(self): + content_type = 'application/json' + # a boolean is not an array + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_null_is_not_an_array_fails(self): + content_type = 'application/json' + # null is not an array + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_object_is_not_an_array_fails(self): + content_type = 'application/json' + # an object is not an array + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_string_is_not_an_array_fails(self): + content_type = 'application/json' + # a string is not an array + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_array_is_an_array_passes(self): + content_type = 'application/json' + # an array is an array + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postArrayTypeMatchesArraysRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_an_integer_is_not_an_array_fails(self): + content_type = 'application/json' + # an integer is not an array + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_boolean_type_matches_booleans_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_boolean_type_matches_booleans_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_boolean_type_matches_booleans_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_boolean_type_matches_booleans_request_body/test_post.py new file mode 100644 index 000000000000..f0781bdc36f6 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_boolean_type_matches_booleans_request_body/test_post.py @@ -0,0 +1,215 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_boolean_type_matches_booleans_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostBooleanTypeMatchesBooleansRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostBooleanTypeMatchesBooleansRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_an_empty_string_is_not_a_boolean_fails(self): + content_type = 'application/json' + # an empty string is not a boolean + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_float_is_not_a_boolean_fails(self): + content_type = 'application/json' + # a float is not a boolean + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.1 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_null_is_not_a_boolean_fails(self): + content_type = 'application/json' + # null is not a boolean + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_zero_is_not_a_boolean_fails(self): + content_type = 'application/json' + # zero is not a boolean + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_array_is_not_a_boolean_fails(self): + content_type = 'application/json' + # an array is not a boolean + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_string_is_not_a_boolean_fails(self): + content_type = 'application/json' + # a string is not a boolean + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_false_is_a_boolean_passes(self): + content_type = 'application/json' + # false is a boolean + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postBooleanTypeMatchesBooleansRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_an_integer_is_not_a_boolean_fails(self): + content_type = 'application/json' + # an integer is not a boolean + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_true_is_a_boolean_passes(self): + content_type = 'application/json' + # true is a boolean + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postBooleanTypeMatchesBooleansRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_an_object_is_not_a_boolean_fails(self): + content_type = 'application/json' + # an object is not a boolean + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_int_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_int_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_int_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_int_request_body/test_post.py new file mode 100644 index 000000000000..1856eaadb84c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_int_request_body/test_post.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_by_int_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostByIntRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostByIntRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_int_by_int_fail_fails(self): + content_type = 'application/json' + # int by int fail + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 7 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_int_by_int_passes(self): + content_type = 'application/json' + # int by int + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 10 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postByIntRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_ignores_non_numbers_passes(self): + content_type = 'application/json' + # ignores non-numbers + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postByIntRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_number_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_number_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_number_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_number_request_body/test_post.py new file mode 100644 index 000000000000..9cab6caaf5f9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_number_request_body/test_post.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_by_number_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostByNumberRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostByNumberRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_45_is_multiple_of15_passes(self): + content_type = 'application/json' + # 4.5 is multiple of 1.5 + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 4.5 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postByNumberRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_35_is_not_multiple_of15_fails(self): + content_type = 'application/json' + # 35 is not multiple of 1.5 + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 35 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_zero_is_multiple_of_anything_passes(self): + content_type = 'application/json' + # zero is multiple of anything + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postByNumberRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_small_number_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_small_number_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_small_number_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_small_number_request_body/test_post.py new file mode 100644 index 000000000000..f1b9d0d2f355 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_by_small_number_request_body/test_post.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_by_small_number_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostBySmallNumberRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostBySmallNumberRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_000751_is_not_multiple_of00001_fails(self): + content_type = 'application/json' + # 0.00751 is not multiple of 0.0001 + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0.00751 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_00075_is_multiple_of00001_passes(self): + content_type = 'application/json' + # 0.0075 is multiple of 0.0001 + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0.0075 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postBySmallNumberRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_enum_with_false_does_not_match0_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_enum_with_false_does_not_match0_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_enum_with_false_does_not_match0_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_enum_with_false_does_not_match0_request_body/test_post.py new file mode 100644 index 000000000000..3ff7e808eb64 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_enum_with_false_does_not_match0_request_body/test_post.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_enum_with_false_does_not_match0_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostEnumWithFalseDoesNotMatch0RequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostEnumWithFalseDoesNotMatch0RequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_false_is_valid_passes(self): + content_type = 'application/json' + # false is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postEnumWithFalseDoesNotMatch0RequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_float_zero_is_invalid_fails(self): + content_type = 'application/json' + # float zero is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0.0 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_integer_zero_is_invalid_fails(self): + content_type = 'application/json' + # integer zero is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_enum_with_true_does_not_match1_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_enum_with_true_does_not_match1_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_enum_with_true_does_not_match1_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_enum_with_true_does_not_match1_request_body/test_post.py new file mode 100644 index 000000000000..b9bdb176b3f5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_enum_with_true_does_not_match1_request_body/test_post.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_enum_with_true_does_not_match1_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostEnumWithTrueDoesNotMatch1RequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostEnumWithTrueDoesNotMatch1RequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_float_one_is_invalid_fails(self): + content_type = 'application/json' + # float one is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.0 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_true_is_valid_passes(self): + content_type = 'application/json' + # true is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postEnumWithTrueDoesNotMatch1RequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_integer_one_is_invalid_fails(self): + content_type = 'application/json' + # integer one is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_hostname_format_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_hostname_format_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_hostname_format_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_hostname_format_request_body/test_post.py new file mode 100644 index 000000000000..dfcc9cacd62b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_hostname_format_request_body/test_post.py @@ -0,0 +1,223 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_hostname_format_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostHostnameFormatRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostHostnameFormatRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_all_string_formats_ignore_objects_passes(self): + content_type = 'application/json' + # all string formats ignore objects + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postHostnameFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_booleans_passes(self): + content_type = 'application/json' + # all string formats ignore booleans + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postHostnameFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_integers_passes(self): + content_type = 'application/json' + # all string formats ignore integers + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postHostnameFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_floats_passes(self): + content_type = 'application/json' + # all string formats ignore floats + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 13.7 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postHostnameFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_arrays_passes(self): + content_type = 'application/json' + # all string formats ignore arrays + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postHostnameFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_nulls_passes(self): + content_type = 'application/json' + # all string formats ignore nulls + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postHostnameFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_integer_type_matches_integers_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_integer_type_matches_integers_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_integer_type_matches_integers_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_integer_type_matches_integers_request_body/test_post.py new file mode 100644 index 000000000000..cc9fc315a100 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_integer_type_matches_integers_request_body/test_post.py @@ -0,0 +1,201 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_integer_type_matches_integers_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostIntegerTypeMatchesIntegersRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostIntegerTypeMatchesIntegersRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_an_object_is_not_an_integer_fails(self): + content_type = 'application/json' + # an object is not an integer + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_string_is_not_an_integer_fails(self): + content_type = 'application/json' + # a string is not an integer + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_null_is_not_an_integer_fails(self): + content_type = 'application/json' + # null is not an integer + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): + content_type = 'application/json' + # a float with zero fractional part is an integer + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.0 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIntegerTypeMatchesIntegersRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_a_float_is_not_an_integer_fails(self): + content_type = 'application/json' + # a float is not an integer + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.1 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_boolean_is_not_an_integer_fails(self): + content_type = 'application/json' + # a boolean is not an integer + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_integer_is_an_integer_passes(self): + content_type = 'application/json' + # an integer is an integer + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIntegerTypeMatchesIntegersRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): + content_type = 'application/json' + # a string is still not an integer, even if it looks like one + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "1" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_array_is_not_an_integer_fails(self): + content_type = 'application/json' + # an array is not an integer + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_request_body/test_post.py new file mode 100644 index 000000000000..93fea1ad1eb2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_request_body/test_post.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInfRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInfRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_always_invalid_but_naive_implementations_may_raise_an_overflow_error_fails(self): + content_type = 'application/json' + # always invalid, but naive implementations may raise an overflow error + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.0E308 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_valid_integer_with_multipleof_float_passes(self): + content_type = 'application/json' + # valid integer with multipleOf float + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 123456789 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInfRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_invalid_string_value_for_default_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_invalid_string_value_for_default_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_invalid_string_value_for_default_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_invalid_string_value_for_default_request_body/test_post.py new file mode 100644 index 000000000000..8c05185793af --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_invalid_string_value_for_default_request_body/test_post.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_invalid_string_value_for_default_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostInvalidStringValueForDefaultRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostInvalidStringValueForDefaultRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_valid_when_property_is_specified_passes(self): + content_type = 'application/json' + # valid when property is specified + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "bar": + "good", + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postInvalidStringValueForDefaultRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_still_valid_when_the_invalid_default_is_used_passes(self): + content_type = 'application/json' + # still valid when the invalid default is used + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postInvalidStringValueForDefaultRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ipv4_format_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ipv4_format_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ipv4_format_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ipv4_format_request_body/test_post.py new file mode 100644 index 000000000000..12c1165d5608 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ipv4_format_request_body/test_post.py @@ -0,0 +1,223 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_ipv4_format_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostIpv4FormatRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostIpv4FormatRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_all_string_formats_ignore_objects_passes(self): + content_type = 'application/json' + # all string formats ignore objects + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv4FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_booleans_passes(self): + content_type = 'application/json' + # all string formats ignore booleans + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv4FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_integers_passes(self): + content_type = 'application/json' + # all string formats ignore integers + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv4FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_floats_passes(self): + content_type = 'application/json' + # all string formats ignore floats + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 13.7 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv4FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_arrays_passes(self): + content_type = 'application/json' + # all string formats ignore arrays + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv4FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_nulls_passes(self): + content_type = 'application/json' + # all string formats ignore nulls + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv4FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ipv6_format_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ipv6_format_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ipv6_format_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ipv6_format_request_body/test_post.py new file mode 100644 index 000000000000..a7558fe9d086 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ipv6_format_request_body/test_post.py @@ -0,0 +1,223 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_ipv6_format_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostIpv6FormatRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostIpv6FormatRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_all_string_formats_ignore_objects_passes(self): + content_type = 'application/json' + # all string formats ignore objects + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv6FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_booleans_passes(self): + content_type = 'application/json' + # all string formats ignore booleans + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv6FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_integers_passes(self): + content_type = 'application/json' + # all string formats ignore integers + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv6FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_floats_passes(self): + content_type = 'application/json' + # all string formats ignore floats + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 13.7 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv6FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_arrays_passes(self): + content_type = 'application/json' + # all string formats ignore arrays + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv6FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_nulls_passes(self): + content_type = 'application/json' + # all string formats ignore nulls + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postIpv6FormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_json_pointer_format_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_json_pointer_format_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_json_pointer_format_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_json_pointer_format_request_body/test_post.py new file mode 100644 index 000000000000..99bdb1b36a14 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_json_pointer_format_request_body/test_post.py @@ -0,0 +1,223 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_json_pointer_format_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostJsonPointerFormatRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostJsonPointerFormatRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_all_string_formats_ignore_objects_passes(self): + content_type = 'application/json' + # all string formats ignore objects + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postJsonPointerFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_booleans_passes(self): + content_type = 'application/json' + # all string formats ignore booleans + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postJsonPointerFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_integers_passes(self): + content_type = 'application/json' + # all string formats ignore integers + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postJsonPointerFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_floats_passes(self): + content_type = 'application/json' + # all string formats ignore floats + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 13.7 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postJsonPointerFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_arrays_passes(self): + content_type = 'application/json' + # all string formats ignore arrays + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postJsonPointerFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_nulls_passes(self): + content_type = 'application/json' + # all string formats ignore nulls + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postJsonPointerFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maximum_validation_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maximum_validation_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maximum_validation_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maximum_validation_request_body/test_post.py new file mode 100644 index 000000000000..d00875774e59 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maximum_validation_request_body/test_post.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_maximum_validation_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostMaximumValidationRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostMaximumValidationRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_below_the_maximum_is_valid_passes(self): + content_type = 'application/json' + # below the maximum is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 2.6 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postMaximumValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_boundary_point_is_valid_passes(self): + content_type = 'application/json' + # boundary point is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 3.0 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postMaximumValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_above_the_maximum_is_invalid_fails(self): + content_type = 'application/json' + # above the maximum is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 3.5 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_ignores_non_numbers_passes(self): + content_type = 'application/json' + # ignores non-numbers + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "x" + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postMaximumValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maxitems_validation_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maxitems_validation_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maxitems_validation_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maxitems_validation_request_body/test_post.py new file mode 100644 index 000000000000..b0d4c4fbfb8f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maxitems_validation_request_body/test_post.py @@ -0,0 +1,154 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_maxitems_validation_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostMaxitemsValidationRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostMaxitemsValidationRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_too_long_is_invalid_fails(self): + content_type = 'application/json' + # too long is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + 1, + 2, + 3, + ] + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_ignores_non_arrays_passes(self): + content_type = 'application/json' + # ignores non-arrays + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foobar" + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postMaxitemsValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_shorter_is_valid_passes(self): + content_type = 'application/json' + # shorter is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + 1, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postMaxitemsValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_exact_length_is_valid_passes(self): + content_type = 'application/json' + # exact length is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + 1, + 2, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postMaxitemsValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maxproperties0_means_the_object_is_empty_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maxproperties0_means_the_object_is_empty_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maxproperties0_means_the_object_is_empty_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maxproperties0_means_the_object_is_empty_request_body/test_post.py new file mode 100644 index 000000000000..928f69f9e181 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_maxproperties0_means_the_object_is_empty_request_body/test_post.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_maxproperties0_means_the_object_is_empty_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostMaxproperties0MeansTheObjectIsEmptyRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostMaxproperties0MeansTheObjectIsEmptyRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_no_properties_is_valid_passes(self): + content_type = 'application/json' + # no properties is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postMaxproperties0MeansTheObjectIsEmptyRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_one_property_is_invalid_fails(self): + content_type = 'application/json' + # one property is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_minimum_validation_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_minimum_validation_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_minimum_validation_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_minimum_validation_request_body/test_post.py new file mode 100644 index 000000000000..37db0353d8f9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_minimum_validation_request_body/test_post.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_minimum_validation_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostMinimumValidationRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostMinimumValidationRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_boundary_point_is_valid_passes(self): + content_type = 'application/json' + # boundary point is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.1 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postMinimumValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_below_the_minimum_is_invalid_fails(self): + content_type = 'application/json' + # below the minimum is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0.6 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_above_the_minimum_is_valid_passes(self): + content_type = 'application/json' + # above the minimum is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 2.6 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postMinimumValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_ignores_non_numbers_passes(self): + content_type = 'application/json' + # ignores non-numbers + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "x" + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postMinimumValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_nested_items_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_nested_items_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_nested_items_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_nested_items_request_body/test_post.py new file mode 100644 index 000000000000..efb58ea3f349 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_nested_items_request_body/test_post.py @@ -0,0 +1,180 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_nested_items_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostNestedItemsRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostNestedItemsRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_valid_nested_array_passes(self): + content_type = 'application/json' + # valid nested array + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + [ + [ + [ + 1, + ], + ], + [ + [ + 2, + ], + [ + 3, + ], + ], + ], + [ + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ], + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postNestedItemsRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_nested_array_with_invalid_type_fails(self): + content_type = 'application/json' + # nested array with invalid type + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + [ + [ + [ + "1", + ], + ], + [ + [ + 2, + ], + [ + 3, + ], + ], + ], + [ + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ], + ] + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_not_deep_enough_fails(self): + content_type = 'application/json' + # not deep enough + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + [ + [ + 1, + ], + [ + 2, + ], + [ + 3, + ], + ], + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ] + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_not_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_not_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_not_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_not_request_body/test_post.py new file mode 100644 index 000000000000..2c1f7f52391d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_not_request_body/test_post.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_not_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostNotRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostNotRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_allowed_passes(self): + content_type = 'application/json' + # allowed + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postNotRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_disallowed_fails(self): + content_type = 'application/json' + # disallowed + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_null_type_matches_only_the_null_object_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_null_type_matches_only_the_null_object_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_null_type_matches_only_the_null_object_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_null_type_matches_only_the_null_object_request_body/test_post.py new file mode 100644 index 000000000000..724a8506942c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_null_type_matches_only_the_null_object_request_body/test_post.py @@ -0,0 +1,199 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_null_type_matches_only_the_null_object_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostNullTypeMatchesOnlyTheNullObjectRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostNullTypeMatchesOnlyTheNullObjectRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_a_float_is_not_null_fails(self): + content_type = 'application/json' + # a float is not null + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.1 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_object_is_not_null_fails(self): + content_type = 'application/json' + # an object is not null + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_false_is_not_null_fails(self): + content_type = 'application/json' + # false is not null + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_integer_is_not_null_fails(self): + content_type = 'application/json' + # an integer is not null + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_true_is_not_null_fails(self): + content_type = 'application/json' + # true is not null + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_zero_is_not_null_fails(self): + content_type = 'application/json' + # zero is not null + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_empty_string_is_not_null_fails(self): + content_type = 'application/json' + # an empty string is not null + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_null_is_null_passes(self): + content_type = 'application/json' + # null is null + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postNullTypeMatchesOnlyTheNullObjectRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_an_array_is_not_null_fails(self): + content_type = 'application/json' + # an array is not null + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_string_is_not_null_fails(self): + content_type = 'application/json' + # a string is not null + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_number_type_matches_numbers_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_number_type_matches_numbers_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_number_type_matches_numbers_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_number_type_matches_numbers_request_body/test_post.py new file mode 100644 index 000000000000..c9c2f33a72e1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_number_type_matches_numbers_request_body/test_post.py @@ -0,0 +1,217 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_number_type_matches_numbers_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostNumberTypeMatchesNumbersRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostNumberTypeMatchesNumbersRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_an_array_is_not_a_number_fails(self): + content_type = 'application/json' + # an array is not a number + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_null_is_not_a_number_fails(self): + content_type = 'application/json' + # null is not a number + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_object_is_not_a_number_fails(self): + content_type = 'application/json' + # an object is not a number + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_boolean_is_not_a_number_fails(self): + content_type = 'application/json' + # a boolean is not a number + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_float_is_a_number_passes(self): + content_type = 'application/json' + # a float is a number + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.1 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postNumberTypeMatchesNumbersRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_a_string_is_still_not_a_number_even_if_it_looks_like_one_fails(self): + content_type = 'application/json' + # a string is still not a number, even if it looks like one + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "1" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_string_is_not_a_number_fails(self): + content_type = 'application/json' + # a string is not a number + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_integer_is_a_number_passes(self): + content_type = 'application/json' + # an integer is a number + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postNumberTypeMatchesNumbersRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_a_float_with_zero_fractional_part_is_a_number_and_an_integer_passes(self): + content_type = 'application/json' + # a float with zero fractional part is a number (and an integer) + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.0 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postNumberTypeMatchesNumbersRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_object_properties_validation_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_object_properties_validation_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_object_properties_validation_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_object_properties_validation_request_body/test_post.py new file mode 100644 index 000000000000..5b7660e499c5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_object_properties_validation_request_body/test_post.py @@ -0,0 +1,212 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_object_properties_validation_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostObjectPropertiesValidationRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostObjectPropertiesValidationRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_ignores_arrays_passes(self): + content_type = 'application/json' + # ignores arrays + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postObjectPropertiesValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_ignores_other_non_objects_passes(self): + content_type = 'application/json' + # ignores other non-objects + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postObjectPropertiesValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_one_property_invalid_is_invalid_fails(self): + content_type = 'application/json' + # one property invalid is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + "bar": + { + }, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_both_properties_present_and_valid_is_valid_passes(self): + content_type = 'application/json' + # both properties present and valid is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + "bar": + "baz", + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postObjectPropertiesValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_doesn_t_invalidate_other_properties_passes(self): + content_type = 'application/json' + # doesn't invalidate other properties + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "quux": + [ + ], + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postObjectPropertiesValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_both_properties_invalid_is_invalid_fails(self): + content_type = 'application/json' + # both properties invalid is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + [ + ], + "bar": + { + }, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_object_type_matches_objects_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_object_type_matches_objects_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_object_type_matches_objects_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_object_type_matches_objects_request_body/test_post.py new file mode 100644 index 000000000000..7c8c0c6776dd --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_object_type_matches_objects_request_body/test_post.py @@ -0,0 +1,157 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_object_type_matches_objects_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostObjectTypeMatchesObjectsRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostObjectTypeMatchesObjectsRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_a_float_is_not_an_object_fails(self): + content_type = 'application/json' + # a float is not an object + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.1 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_null_is_not_an_object_fails(self): + content_type = 'application/json' + # null is not an object + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_array_is_not_an_object_fails(self): + content_type = 'application/json' + # an array is not an object + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_object_is_an_object_passes(self): + content_type = 'application/json' + # an object is an object + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postObjectTypeMatchesObjectsRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_a_string_is_not_an_object_fails(self): + content_type = 'application/json' + # a string is not an object + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_an_integer_is_not_an_object_fails(self): + content_type = 'application/json' + # an integer is not an object + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_a_boolean_is_not_an_object_fails(self): + content_type = 'application/json' + # a boolean is not an object + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_request_body/test_post.py new file mode 100644 index 000000000000..17566d5bc6b2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_request_body/test_post.py @@ -0,0 +1,129 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_oneof_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostOneofRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostOneofRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_second_oneof_valid_passes(self): + content_type = 'application/json' + # second oneOf valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 2.5 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postOneofRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_both_oneof_valid_fails(self): + content_type = 'application/json' + # both oneOf valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 3 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_first_oneof_valid_passes(self): + content_type = 'application/json' + # first oneOf valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postOneofRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_neither_oneof_valid_fails(self): + content_type = 'application/json' + # neither oneOf valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.5 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_with_base_schema_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_with_base_schema_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_with_base_schema_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_with_base_schema_request_body/test_post.py new file mode 100644 index 000000000000..398dc1966dd6 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_with_base_schema_request_body/test_post.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_oneof_with_base_schema_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostOneofWithBaseSchemaRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostOneofWithBaseSchemaRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_both_oneof_valid_fails(self): + content_type = 'application/json' + # both oneOf valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_mismatch_base_schema_fails(self): + content_type = 'application/json' + # mismatch base schema + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 3 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_one_oneof_valid_passes(self): + content_type = 'application/json' + # one oneOf valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foobar" + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postOneofWithBaseSchemaRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_with_empty_schema_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_with_empty_schema_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_with_empty_schema_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_with_empty_schema_request_body/test_post.py new file mode 100644 index 000000000000..3ad3de795343 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_oneof_with_empty_schema_request_body/test_post.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_oneof_with_empty_schema_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostOneofWithEmptySchemaRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostOneofWithEmptySchemaRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_both_valid_invalid_fails(self): + content_type = 'application/json' + # both valid - invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 123 + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_one_valid_valid_passes(self): + content_type = 'application/json' + # one valid - valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postOneofWithEmptySchemaRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_pattern_validation_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_pattern_validation_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_pattern_validation_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_pattern_validation_request_body/test_post.py new file mode 100644 index 000000000000..c926fb0a57b2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_pattern_validation_request_body/test_post.py @@ -0,0 +1,267 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_pattern_validation_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostPatternValidationRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostPatternValidationRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_ignores_arrays_passes(self): + content_type = 'application/json' + # ignores arrays + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postPatternValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_ignores_objects_passes(self): + content_type = 'application/json' + # ignores objects + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postPatternValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_ignores_null_passes(self): + content_type = 'application/json' + # ignores null + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postPatternValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_ignores_floats_passes(self): + content_type = 'application/json' + # ignores floats + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.0 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postPatternValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_a_non_matching_pattern_is_invalid_fails(self): + content_type = 'application/json' + # a non-matching pattern is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "abc" + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + def test_ignores_booleans_passes(self): + content_type = 'application/json' + # ignores booleans + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postPatternValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_a_matching_pattern_is_valid_passes(self): + content_type = 'application/json' + # a matching pattern is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "aaa" + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postPatternValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_ignores_integers_passes(self): + content_type = 'application/json' + # ignores integers + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 123 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postPatternValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_properties_with_escaped_characters_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_properties_with_escaped_characters_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_properties_with_escaped_characters_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_properties_with_escaped_characters_request_body/test_post.py new file mode 100644 index 000000000000..f6b77207339d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_properties_with_escaped_characters_request_body/test_post.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_properties_with_escaped_characters_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostPropertiesWithEscapedCharactersRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostPropertiesWithEscapedCharactersRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_object_with_all_numbers_is_valid_passes(self): + content_type = 'application/json' + # object with all numbers is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo\nbar": + 1, + "foo\"bar": + 1, + "foo\\bar": + 1, + "foo\rbar": + 1, + "foo\tbar": + 1, + "foo\fbar": + 1, + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postPropertiesWithEscapedCharactersRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_object_with_strings_is_invalid_fails(self): + content_type = 'application/json' + # object with strings is invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo\nbar": + "1", + "foo\"bar": + "1", + "foo\\bar": + "1", + "foo\rbar": + "1", + "foo\tbar": + "1", + "foo\fbar": + "1", + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_allof_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_allof_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_allof_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_allof_request_body/test_post.py new file mode 100644 index 000000000000..9a60004b56c8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_allof_request_body/test_post.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_ref_in_allof_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostRefInAllofRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostRefInAllofRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_property_named_ref_valid_passes(self): + content_type = 'application/json' + # property named $ref valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + "a", + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postRefInAllofRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_property_named_ref_invalid_fails(self): + content_type = 'application/json' + # property named $ref invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + 2, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_anyof_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_anyof_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_anyof_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_anyof_request_body/test_post.py new file mode 100644 index 000000000000..4add768a3693 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_anyof_request_body/test_post.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_ref_in_anyof_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostRefInAnyofRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostRefInAnyofRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_property_named_ref_valid_passes(self): + content_type = 'application/json' + # property named $ref valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + "a", + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postRefInAnyofRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_property_named_ref_invalid_fails(self): + content_type = 'application/json' + # property named $ref invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + 2, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_property_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_property_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_property_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_property_request_body/test_post.py new file mode 100644 index 000000000000..061c42da7679 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_property_request_body/test_post.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_ref_in_property_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostRefInPropertyRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostRefInPropertyRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_property_named_ref_valid_passes(self): + content_type = 'application/json' + # property named $ref valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "a": + { + "$ref": + "a", + }, + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postRefInPropertyRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_property_named_ref_invalid_fails(self): + content_type = 'application/json' + # property named $ref invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "a": + { + "$ref": + 2, + }, + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_required_default_validation_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_required_default_validation_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_required_default_validation_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_required_default_validation_request_body/test_post.py new file mode 100644 index 000000000000..fecba5edcd98 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_required_default_validation_request_body/test_post.py @@ -0,0 +1,72 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_required_default_validation_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostRequiredDefaultValidationRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostRequiredDefaultValidationRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_not_required_by_default_passes(self): + content_type = 'application/json' + # not required by default + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postRequiredDefaultValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_required_with_empty_array_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_required_with_empty_array_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_required_with_empty_array_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_required_with_empty_array_request_body/test_post.py new file mode 100644 index 000000000000..b0ea2e23a434 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_required_with_empty_array_request_body/test_post.py @@ -0,0 +1,72 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_required_with_empty_array_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostRequiredWithEmptyArrayRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostRequiredWithEmptyArrayRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_property_not_required_passes(self): + content_type = 'application/json' + # property not required + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postRequiredWithEmptyArrayRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_uniqueitems_false_validation_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_uniqueitems_false_validation_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_uniqueitems_false_validation_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_uniqueitems_false_validation_request_body/test_post.py new file mode 100644 index 000000000000..3545c4ce3190 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_uniqueitems_false_validation_request_body/test_post.py @@ -0,0 +1,607 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_uniqueitems_false_validation_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostUniqueitemsFalseValidationRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostUniqueitemsFalseValidationRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_non_unique_array_of_integers_is_valid_passes(self): + content_type = 'application/json' + # non-unique array of integers is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + 1, + 1, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_unique_array_of_objects_is_valid_passes(self): + content_type = 'application/json' + # unique array of objects is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + { + "foo": + "bar", + }, + { + "foo": + "baz", + }, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_non_unique_array_of_nested_objects_is_valid_passes(self): + content_type = 'application/json' + # non-unique array of nested objects is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_non_unique_array_of_objects_is_valid_passes(self): + content_type = 'application/json' + # non-unique array of objects is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + { + "foo": + "bar", + }, + { + "foo": + "bar", + }, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_1_and_true_are_unique_passes(self): + content_type = 'application/json' + # 1 and true are unique + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + 1, + True, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_unique_array_of_integers_is_valid_passes(self): + content_type = 'application/json' + # unique array of integers is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + 1, + 2, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_non_unique_array_of_arrays_is_valid_passes(self): + content_type = 'application/json' + # non-unique array of arrays is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + [ + "foo", + ], + [ + "foo", + ], + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_numbers_are_unique_if_mathematically_unequal_passes(self): + content_type = 'application/json' + # numbers are unique if mathematically unequal + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + 1.0, + 1.0, + 1, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_false_is_not_equal_to_zero_passes(self): + content_type = 'application/json' + # false is not equal to zero + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + 0, + False, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_unique_array_of_nested_objects_is_valid_passes(self): + content_type = 'application/json' + # unique array of nested objects is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + { + "foo": + { + "bar": + { + "baz": + False, + }, + }, + }, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_0_and_false_are_unique_passes(self): + content_type = 'application/json' + # 0 and false are unique + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + 0, + False, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_unique_array_of_arrays_is_valid_passes(self): + content_type = 'application/json' + # unique array of arrays is valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + [ + "foo", + ], + [ + "bar", + ], + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_true_is_not_equal_to_one_passes(self): + content_type = 'application/json' + # true is not equal to one + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + 1, + True, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_non_unique_heterogeneous_types_are_valid_passes(self): + content_type = 'application/json' + # non-unique heterogeneous types are valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + { + }, + [ + 1, + ], + True, + None, + { + }, + 1, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_unique_heterogeneous_types_are_valid_passes(self): + content_type = 'application/json' + # unique heterogeneous types are valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + { + }, + [ + 1, + ], + True, + None, + 1, + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUniqueitemsFalseValidationRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_uri_format_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_uri_format_request_body/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_uri_format_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_uri_format_request_body/test_post.py new file mode 100644 index 000000000000..abef33875e99 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_uri_format_request_body/test_post.py @@ -0,0 +1,223 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_uri_format_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostUriFormatRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostUriFormatRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_all_string_formats_ignore_objects_passes(self): + content_type = 'application/json' + # all string formats ignore objects + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUriFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_booleans_passes(self): + content_type = 'application/json' + # all string formats ignore booleans + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUriFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_integers_passes(self): + content_type = 'application/json' + # all string formats ignore integers + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUriFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_floats_passes(self): + content_type = 'application/json' + # all string formats ignore floats + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 13.7 + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUriFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_arrays_passes(self): + content_type = 'application/json' + # all string formats ignore arrays + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUriFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_all_string_formats_ignore_nulls_passes(self): + content_type = 'application/json' + # all string formats ignore nulls + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postUriFormatRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_additionalproperties_allows_a_schema_which_should_validate_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_additionalproperties_allows_a_schema_which_should_validate_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_additionalproperties_allows_a_schema_which_should_validate_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_additionalproperties_allows_a_schema_which_should_validate_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..e341954cfdf2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_additionalproperties_allows_a_schema_which_should_validate_response_body_for_content_types/test_post.py @@ -0,0 +1,141 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_additionalproperties_allows_a_schema_which_should_validate_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostAdditionalpropertiesAllowsASchemaWhichShouldValidateResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostAdditionalpropertiesAllowsASchemaWhichShouldValidateResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_no_additional_properties_is_valid_passes(self): + # no additional properties is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAdditionalpropertiesAllowsASchemaWhichShouldValidateResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_an_additional_invalid_property_is_invalid_fails(self): + # an additional invalid property is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + "bar": + 2, + "quux": + 12, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAdditionalpropertiesAllowsASchemaWhichShouldValidateResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_an_additional_valid_property_is_valid_passes(self): + # an additional valid property is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + "bar": + 2, + "quux": + True, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAdditionalpropertiesAllowsASchemaWhichShouldValidateResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_simple_types_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_simple_types_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_simple_types_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_simple_types_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..64dd6c0946b5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_simple_types_response_body_for_content_types/test_post.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_allof_simple_types_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostAllofSimpleTypesResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostAllofSimpleTypesResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_valid_passes(self): + # valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 25 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAllofSimpleTypesResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_mismatch_one_fails(self): + # mismatch one + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 35 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAllofSimpleTypesResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_base_schema_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_base_schema_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_base_schema_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_base_schema_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..3e0840589cf4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_base_schema_response_body_for_content_types/test_post.py @@ -0,0 +1,191 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_allof_with_base_schema_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostAllofWithBaseSchemaResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostAllofWithBaseSchemaResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_valid_passes(self): + # valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "quux", + "bar": + 2, + "baz": + None, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAllofWithBaseSchemaResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_mismatch_first_allof_fails(self): + # mismatch first allOf + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "bar": + 2, + "baz": + None, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAllofWithBaseSchemaResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_mismatch_base_schema_fails(self): + # mismatch base schema + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "quux", + "baz": + None, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAllofWithBaseSchemaResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_mismatch_both_fails(self): + # mismatch both + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "bar": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAllofWithBaseSchemaResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_mismatch_second_allof_fails(self): + # mismatch second allOf + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "quux", + "bar": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAllofWithBaseSchemaResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_one_empty_schema_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_one_empty_schema_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_one_empty_schema_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_one_empty_schema_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..e62fe3e6dc1f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_one_empty_schema_response_body_for_content_types/test_post.py @@ -0,0 +1,70 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_allof_with_one_empty_schema_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostAllofWithOneEmptySchemaResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostAllofWithOneEmptySchemaResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_any_data_is_valid_passes(self): + # any data is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAllofWithOneEmptySchemaResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_the_first_empty_schema_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_the_first_empty_schema_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_the_first_empty_schema_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_the_first_empty_schema_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..34f60b255d08 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_allof_with_the_first_empty_schema_response_body_for_content_types/test_post.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_allof_with_the_first_empty_schema_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostAllofWithTheFirstEmptySchemaResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostAllofWithTheFirstEmptySchemaResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_string_is_invalid_fails(self): + # string is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAllofWithTheFirstEmptySchemaResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_number_is_valid_passes(self): + # number is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAllofWithTheFirstEmptySchemaResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_anyof_complex_types_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_anyof_complex_types_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_anyof_complex_types_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_anyof_complex_types_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..9d3cb6a9ce5c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_anyof_complex_types_response_body_for_content_types/test_post.py @@ -0,0 +1,170 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_anyof_complex_types_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostAnyofComplexTypesResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostAnyofComplexTypesResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_second_anyof_valid_complex_passes(self): + # second anyOf valid (complex) + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "baz", + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAnyofComplexTypesResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_neither_anyof_valid_complex_fails(self): + # neither anyOf valid (complex) + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 2, + "bar": + "quux", + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAnyofComplexTypesResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_both_anyof_valid_complex_passes(self): + # both anyOf valid (complex) + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "baz", + "bar": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAnyofComplexTypesResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_first_anyof_valid_complex_passes(self): + # first anyOf valid (complex) + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "bar": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAnyofComplexTypesResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_anyof_with_base_schema_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_anyof_with_base_schema_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_anyof_with_base_schema_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_anyof_with_base_schema_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..758478004564 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_anyof_with_base_schema_response_body_for_content_types/test_post.py @@ -0,0 +1,118 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_anyof_with_base_schema_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostAnyofWithBaseSchemaResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostAnyofWithBaseSchemaResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_one_anyof_valid_passes(self): + # one anyOf valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foobar" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAnyofWithBaseSchemaResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_both_anyof_invalid_fails(self): + # both anyOf invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAnyofWithBaseSchemaResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_mismatch_base_schema_fails(self): + # mismatch base schema + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 3 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postAnyofWithBaseSchemaResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_array_type_matches_arrays_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_array_type_matches_arrays_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_array_type_matches_arrays_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_array_type_matches_arrays_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..14dce02ed244 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_array_type_matches_arrays_response_body_for_content_types/test_post.py @@ -0,0 +1,216 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_array_type_matches_arrays_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostArrayTypeMatchesArraysResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostArrayTypeMatchesArraysResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_a_float_is_not_an_array_fails(self): + # a float is not an array + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postArrayTypeMatchesArraysResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_a_boolean_is_not_an_array_fails(self): + # a boolean is not an array + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postArrayTypeMatchesArraysResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_null_is_not_an_array_fails(self): + # null is not an array + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postArrayTypeMatchesArraysResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_an_object_is_not_an_array_fails(self): + # an object is not an array + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postArrayTypeMatchesArraysResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_a_string_is_not_an_array_fails(self): + # a string is not an array + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postArrayTypeMatchesArraysResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_an_array_is_an_array_passes(self): + # an array is an array + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postArrayTypeMatchesArraysResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_an_integer_is_not_an_array_fails(self): + # an integer is not an array + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postArrayTypeMatchesArraysResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_by_small_number_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_by_small_number_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_by_small_number_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_by_small_number_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..124b4565cfe9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_by_small_number_response_body_for_content_types/test_post.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_by_small_number_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostBySmallNumberResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostBySmallNumberResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_000751_is_not_multiple_of00001_fails(self): + # 0.00751 is not multiple of 0.0001 + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0.00751 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postBySmallNumberResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_00075_is_multiple_of00001_passes(self): + # 0.0075 is multiple of 0.0001 + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0.0075 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postBySmallNumberResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_date_time_format_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_date_time_format_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_date_time_format_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_date_time_format_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..89e9119e9e03 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_date_time_format_response_body_for_content_types/test_post.py @@ -0,0 +1,222 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_date_time_format_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostDateTimeFormatResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostDateTimeFormatResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postDateTimeFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postDateTimeFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postDateTimeFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 13.7 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postDateTimeFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postDateTimeFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postDateTimeFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with0_does_not_match_false_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with0_does_not_match_false_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with0_does_not_match_false_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with0_does_not_match_false_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..d86f4b952201 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with0_does_not_match_false_response_body_for_content_types/test_post.py @@ -0,0 +1,124 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_enum_with0_does_not_match_false_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostEnumWith0DoesNotMatchFalseResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostEnumWith0DoesNotMatchFalseResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_integer_zero_is_valid_passes(self): + # integer zero is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postEnumWith0DoesNotMatchFalseResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_float_zero_is_valid_passes(self): + # float zero is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0.0 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postEnumWith0DoesNotMatchFalseResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_false_is_invalid_fails(self): + # false is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postEnumWith0DoesNotMatchFalseResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with_escaped_characters_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with_escaped_characters_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with_escaped_characters_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with_escaped_characters_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..dcfb4389ad58 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with_escaped_characters_response_body_for_content_types/test_post.py @@ -0,0 +1,124 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_enum_with_escaped_characters_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostEnumWithEscapedCharactersResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostEnumWithEscapedCharactersResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_member2_is_valid_passes(self): + # member 2 is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo\rbar" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postEnumWithEscapedCharactersResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_member1_is_valid_passes(self): + # member 1 is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo\nbar" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postEnumWithEscapedCharactersResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_another_string_is_invalid_fails(self): + # another string is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "abc" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postEnumWithEscapedCharactersResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with_true_does_not_match1_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with_true_does_not_match1_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with_true_does_not_match1_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with_true_does_not_match1_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..5e461f7836ef --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_enum_with_true_does_not_match1_response_body_for_content_types/test_post.py @@ -0,0 +1,118 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_enum_with_true_does_not_match1_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostEnumWithTrueDoesNotMatch1ResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostEnumWithTrueDoesNotMatch1ResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_float_one_is_invalid_fails(self): + # float one is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.0 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postEnumWithTrueDoesNotMatch1ResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_true_is_valid_passes(self): + # true is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postEnumWithTrueDoesNotMatch1ResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_integer_one_is_invalid_fails(self): + # integer one is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postEnumWithTrueDoesNotMatch1ResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_forbidden_property_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_forbidden_property_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_forbidden_property_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_forbidden_property_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..89387ecd9266 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_forbidden_property_response_body_for_content_types/test_post.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_forbidden_property_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostForbiddenPropertyResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostForbiddenPropertyResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_property_present_fails(self): + # property present + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + "bar": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postForbiddenPropertyResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_property_absent_passes(self): + # property absent + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "bar": + 1, + "baz": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postForbiddenPropertyResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_integer_type_matches_integers_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_integer_type_matches_integers_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_integer_type_matches_integers_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_integer_type_matches_integers_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..6ae586f8b96f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_integer_type_matches_integers_response_body_for_content_types/test_post.py @@ -0,0 +1,270 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_integer_type_matches_integers_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostIntegerTypeMatchesIntegersResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostIntegerTypeMatchesIntegersResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_an_object_is_not_an_integer_fails(self): + # an object is not an integer + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIntegerTypeMatchesIntegersResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_a_string_is_not_an_integer_fails(self): + # a string is not an integer + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIntegerTypeMatchesIntegersResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_null_is_not_an_integer_fails(self): + # null is not an integer + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIntegerTypeMatchesIntegersResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): + # a float with zero fractional part is an integer + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.0 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIntegerTypeMatchesIntegersResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_a_float_is_not_an_integer_fails(self): + # a float is not an integer + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIntegerTypeMatchesIntegersResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_a_boolean_is_not_an_integer_fails(self): + # a boolean is not an integer + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIntegerTypeMatchesIntegersResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_an_integer_is_an_integer_passes(self): + # an integer is an integer + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIntegerTypeMatchesIntegersResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): + # a string is still not an integer, even if it looks like one + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "1" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIntegerTypeMatchesIntegersResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_an_array_is_not_an_integer_fails(self): + # an array is not an integer + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIntegerTypeMatchesIntegersResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..2abd9d64e41d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_response_body_for_content_types/test_post.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInfResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInfResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_always_invalid_but_naive_implementations_may_raise_an_overflow_error_fails(self): + # always invalid, but naive implementations may raise an overflow error + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.0E308 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInfResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_valid_integer_with_multipleof_float_passes(self): + # valid integer with multipleOf float + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 123456789 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInfResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ipv6_format_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ipv6_format_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ipv6_format_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ipv6_format_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..2550b2a4e69e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ipv6_format_response_body_for_content_types/test_post.py @@ -0,0 +1,222 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_ipv6_format_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostIpv6FormatResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostIpv6FormatResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIpv6FormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIpv6FormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIpv6FormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 13.7 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIpv6FormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIpv6FormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postIpv6FormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maximum_validation_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maximum_validation_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maximum_validation_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maximum_validation_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..ccc36c2a9747 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maximum_validation_response_body_for_content_types/test_post.py @@ -0,0 +1,154 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_maximum_validation_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostMaximumValidationResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostMaximumValidationResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_below_the_maximum_is_valid_passes(self): + # below the maximum is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 2.6 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaximumValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 3.0 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaximumValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_above_the_maximum_is_invalid_fails(self): + # above the maximum is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 3.5 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaximumValidationResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "x" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaximumValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxlength_validation_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxlength_validation_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxlength_validation_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxlength_validation_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..b5ee61f9396d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxlength_validation_response_body_for_content_types/test_post.py @@ -0,0 +1,184 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_maxlength_validation_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostMaxlengthValidationResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostMaxlengthValidationResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_too_long_is_invalid_fails(self): + # too long is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxlengthValidationResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_ignores_non_strings_passes(self): + # ignores non-strings + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 100 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxlengthValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_shorter_is_valid_passes(self): + # shorter is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "f" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxlengthValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_two_supplementary_unicode_code_points_is_long_enough_passes(self): + # two supplementary Unicode code points is long enough + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "💩💩" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxlengthValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_exact_length_is_valid_passes(self): + # exact length is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "fo" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxlengthValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxproperties0_means_the_object_is_empty_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxproperties0_means_the_object_is_empty_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxproperties0_means_the_object_is_empty_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxproperties0_means_the_object_is_empty_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..27f50231804c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxproperties0_means_the_object_is_empty_response_body_for_content_types/test_post.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_maxproperties0_means_the_object_is_empty_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostMaxproperties0MeansTheObjectIsEmptyResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostMaxproperties0MeansTheObjectIsEmptyResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_no_properties_is_valid_passes(self): + # no properties is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxproperties0MeansTheObjectIsEmptyResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_one_property_is_invalid_fails(self): + # one property is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxproperties0MeansTheObjectIsEmptyResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxproperties_validation_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxproperties_validation_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxproperties_validation_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxproperties_validation_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..2669082ed4f8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_maxproperties_validation_response_body_for_content_types/test_post.py @@ -0,0 +1,233 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_maxproperties_validation_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostMaxpropertiesValidationResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostMaxpropertiesValidationResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_too_long_is_invalid_fails(self): + # too long is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + "bar": + 2, + "baz": + 3, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxpropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_ignores_arrays_passes(self): + # ignores arrays + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + 1, + 2, + 3, + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxpropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxpropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_ignores_strings_passes(self): + # ignores strings + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foobar" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxpropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_shorter_is_valid_passes(self): + # shorter is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxpropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_exact_length_is_valid_passes(self): + # exact length is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + "bar": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMaxpropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_minimum_validation_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_minimum_validation_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..e6e67368bdb0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_minimum_validation_response_body_for_content_types/test_post.py @@ -0,0 +1,154 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_minimum_validation_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostMinimumValidationResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostMinimumValidationResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMinimumValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_below_the_minimum_is_invalid_fails(self): + # below the minimum is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0.6 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMinimumValidationResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_above_the_minimum_is_valid_passes(self): + # above the minimum is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 2.6 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMinimumValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "x" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMinimumValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_minlength_validation_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_minlength_validation_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_minlength_validation_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_minlength_validation_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..397068c0932e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_minlength_validation_response_body_for_content_types/test_post.py @@ -0,0 +1,178 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_minlength_validation_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostMinlengthValidationResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostMinlengthValidationResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_too_short_is_invalid_fails(self): + # too short is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "f" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMinlengthValidationResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_one_supplementary_unicode_code_point_is_not_long_enough_fails(self): + # one supplementary Unicode code point is not long enough + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "💩" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMinlengthValidationResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_longer_is_valid_passes(self): + # longer is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMinlengthValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_ignores_non_strings_passes(self): + # ignores non-strings + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMinlengthValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_exact_length_is_valid_passes(self): + # exact length is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "fo" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postMinlengthValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_nested_allof_to_check_validation_semantics_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_nested_allof_to_check_validation_semantics_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_nested_allof_to_check_validation_semantics_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_nested_allof_to_check_validation_semantics_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..b9bb65575819 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_nested_allof_to_check_validation_semantics_response_body_for_content_types/test_post.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_nested_allof_to_check_validation_semantics_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostNestedAllofToCheckValidationSemanticsResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostNestedAllofToCheckValidationSemanticsResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_anything_non_null_is_invalid_fails(self): + # anything non-null is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 123 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNestedAllofToCheckValidationSemanticsResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_null_is_valid_passes(self): + # null is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNestedAllofToCheckValidationSemanticsResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_nested_oneof_to_check_validation_semantics_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_nested_oneof_to_check_validation_semantics_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_nested_oneof_to_check_validation_semantics_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_nested_oneof_to_check_validation_semantics_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..341228ecc549 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_nested_oneof_to_check_validation_semantics_response_body_for_content_types/test_post.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_nested_oneof_to_check_validation_semantics_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostNestedOneofToCheckValidationSemanticsResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostNestedOneofToCheckValidationSemanticsResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_anything_non_null_is_invalid_fails(self): + # anything non-null is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 123 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNestedOneofToCheckValidationSemanticsResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_null_is_valid_passes(self): + # null is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNestedOneofToCheckValidationSemanticsResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_not_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_not_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_not_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_not_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..0460da0eca70 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_not_response_body_for_content_types/test_post.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_not_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostNotResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostNotResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_allowed_passes(self): + # allowed + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNotResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_disallowed_fails(self): + # disallowed + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNotResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_null_type_matches_only_the_null_object_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_null_type_matches_only_the_null_object_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_null_type_matches_only_the_null_object_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_null_type_matches_only_the_null_object_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..c97e35a6b8cd --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_null_type_matches_only_the_null_object_response_body_for_content_types/test_post.py @@ -0,0 +1,288 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_null_type_matches_only_the_null_object_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_a_float_is_not_null_fails(self): + # a float is not null + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_an_object_is_not_null_fails(self): + # an object is not null + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_false_is_not_null_fails(self): + # false is not null + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_an_integer_is_not_null_fails(self): + # an integer is not null + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_true_is_not_null_fails(self): + # true is not null + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_zero_is_not_null_fails(self): + # zero is not null + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 0 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_an_empty_string_is_not_null_fails(self): + # an empty string is not null + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_null_is_null_passes(self): + # null is null + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_an_array_is_not_null_fails(self): + # an array is not null + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_a_string_is_not_null_fails(self): + # a string is not null + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postNullTypeMatchesOnlyTheNullObjectResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_object_properties_validation_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_object_properties_validation_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_object_properties_validation_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_object_properties_validation_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..2b4fab89ba12 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_object_properties_validation_response_body_for_content_types/test_post.py @@ -0,0 +1,231 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_object_properties_validation_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostObjectPropertiesValidationResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostObjectPropertiesValidationResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_ignores_arrays_passes(self): + # ignores arrays + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postObjectPropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postObjectPropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_one_property_invalid_is_invalid_fails(self): + # one property invalid is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + "bar": + { + }, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postObjectPropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_both_properties_present_and_valid_is_valid_passes(self): + # both properties present and valid is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + "bar": + "baz", + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postObjectPropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_doesn_t_invalidate_other_properties_passes(self): + # doesn't invalidate other properties + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "quux": + [ + ], + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postObjectPropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_both_properties_invalid_is_invalid_fails(self): + # both properties invalid is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + [ + ], + "bar": + { + }, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postObjectPropertiesValidationResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_complex_types_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_complex_types_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_complex_types_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_complex_types_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..6efaff2ba5d1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_complex_types_response_body_for_content_types/test_post.py @@ -0,0 +1,164 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_oneof_complex_types_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostOneofComplexTypesResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostOneofComplexTypesResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_first_oneof_valid_complex_passes(self): + # first oneOf valid (complex) + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "bar": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postOneofComplexTypesResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_neither_oneof_valid_complex_fails(self): + # neither oneOf valid (complex) + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 2, + "bar": + "quux", + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postOneofComplexTypesResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_both_oneof_valid_complex_fails(self): + # both oneOf valid (complex) + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "baz", + "bar": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postOneofComplexTypesResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_second_oneof_valid_complex_passes(self): + # second oneOf valid (complex) + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + "baz", + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postOneofComplexTypesResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..064f4f939927 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_response_body_for_content_types/test_post.py @@ -0,0 +1,148 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_oneof_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostOneofResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostOneofResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_second_oneof_valid_passes(self): + # second oneOf valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 2.5 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postOneofResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_both_oneof_valid_fails(self): + # both oneOf valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 3 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postOneofResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_first_oneof_valid_passes(self): + # first oneOf valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postOneofResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_neither_oneof_valid_fails(self): + # neither oneOf valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.5 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postOneofResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_with_empty_schema_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_with_empty_schema_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_with_empty_schema_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_with_empty_schema_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..7468f53c1106 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_oneof_with_empty_schema_response_body_for_content_types/test_post.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_oneof_with_empty_schema_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostOneofWithEmptySchemaResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostOneofWithEmptySchemaResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_both_valid_invalid_fails(self): + # both valid - invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 123 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postOneofWithEmptySchemaResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_one_valid_valid_passes(self): + # one valid - valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "foo" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postOneofWithEmptySchemaResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_pattern_is_not_anchored_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_pattern_is_not_anchored_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_pattern_is_not_anchored_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_pattern_is_not_anchored_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..d3e613642439 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_pattern_is_not_anchored_response_body_for_content_types/test_post.py @@ -0,0 +1,70 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_pattern_is_not_anchored_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostPatternIsNotAnchoredResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostPatternIsNotAnchoredResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_matches_a_substring_passes(self): + # matches a substring + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "xxaayy" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postPatternIsNotAnchoredResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_pattern_validation_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_pattern_validation_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_pattern_validation_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_pattern_validation_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..67950a84c109 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_pattern_validation_response_body_for_content_types/test_post.py @@ -0,0 +1,276 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_pattern_validation_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostPatternValidationResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostPatternValidationResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_ignores_arrays_passes(self): + # ignores arrays + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postPatternValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_ignores_objects_passes(self): + # ignores objects + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postPatternValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_ignores_null_passes(self): + # ignores null + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postPatternValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_ignores_floats_passes(self): + # ignores floats + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 1.0 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postPatternValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_a_non_matching_pattern_is_invalid_fails(self): + # a non-matching pattern is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "abc" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postPatternValidationResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + def test_ignores_booleans_passes(self): + # ignores booleans + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + True + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postPatternValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_a_matching_pattern_is_valid_passes(self): + # a matching pattern is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "aaa" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postPatternValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_ignores_integers_passes(self): + # ignores integers + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 123 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postPatternValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_property_named_ref_that_is_not_a_reference_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_property_named_ref_that_is_not_a_reference_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_property_named_ref_that_is_not_a_reference_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_property_named_ref_that_is_not_a_reference_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..3c2a88e4ca9e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_property_named_ref_that_is_not_a_reference_response_body_for_content_types/test_post.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_property_named_ref_that_is_not_a_reference_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostPropertyNamedRefThatIsNotAReferenceResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostPropertyNamedRefThatIsNotAReferenceResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + "a", + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postPropertyNamedRefThatIsNotAReferenceResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postPropertyNamedRefThatIsNotAReferenceResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_allof_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_allof_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_allof_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_allof_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..fa850000c00d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_allof_response_body_for_content_types/test_post.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_ref_in_allof_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostRefInAllofResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostRefInAllofResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + "a", + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRefInAllofResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRefInAllofResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_anyof_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_anyof_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_anyof_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_anyof_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..df9b0409834d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_anyof_response_body_for_content_types/test_post.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_ref_in_anyof_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostRefInAnyofResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostRefInAnyofResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + "a", + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRefInAnyofResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRefInAnyofResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_items_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_items_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_items_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_items_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..6487c99399f5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_items_response_body_for_content_types/test_post.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_ref_in_items_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostRefInItemsResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostRefInItemsResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + { + "$ref": + "a", + }, + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRefInItemsResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + { + "$ref": + 2, + }, + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRefInItemsResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_property_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_property_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_property_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_property_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..3d2bc22e1bb5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_property_response_body_for_content_types/test_post.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_ref_in_property_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostRefInPropertyResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostRefInPropertyResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "a": + { + "$ref": + "a", + }, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRefInPropertyResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "a": + { + "$ref": + 2, + }, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRefInPropertyResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_default_validation_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_default_validation_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_default_validation_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_default_validation_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..6f47fefc8e53 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_default_validation_response_body_for_content_types/test_post.py @@ -0,0 +1,71 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_required_default_validation_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostRequiredDefaultValidationResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostRequiredDefaultValidationResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_not_required_by_default_passes(self): + # not required by default + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRequiredDefaultValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_validation_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_validation_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_validation_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_validation_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..20d47e513add --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_validation_response_body_for_content_types/test_post.py @@ -0,0 +1,191 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_required_validation_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostRequiredValidationResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostRequiredValidationResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_ignores_arrays_passes(self): + # ignores arrays + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRequiredValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_present_required_property_is_valid_passes(self): + # present required property is valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "foo": + 1, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRequiredValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRequiredValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_ignores_strings_passes(self): + # ignores strings + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + "" + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRequiredValidationResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_non_present_required_property_is_invalid_fails(self): + # non-present required property is invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "bar": + 1, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRequiredValidationResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_with_empty_array_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_with_empty_array_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_with_empty_array_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_with_empty_array_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..18030e9754d3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_required_with_empty_array_response_body_for_content_types/test_post.py @@ -0,0 +1,71 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_required_with_empty_array_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostRequiredWithEmptyArrayResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostRequiredWithEmptyArrayResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_property_not_required_passes(self): + # property not required + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRequiredWithEmptyArrayResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_the_default_keyword_does_not_do_anything_if_the_property_is_missing_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_the_default_keyword_does_not_do_anything_if_the_property_is_missing_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_the_default_keyword_does_not_do_anything_if_the_property_is_missing_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_the_default_keyword_does_not_do_anything_if_the_property_is_missing_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..87eb37da1dd2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_the_default_keyword_does_not_do_anything_if_the_property_is_missing_response_body_for_content_types/test_post.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_the_default_keyword_does_not_do_anything_if_the_property_is_missing_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissingResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissingResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_missing_properties_are_not_filled_in_with_the_default_passes(self): + # missing properties are not filled in with the default + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissingResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_an_explicit_property_value_is_checked_against_maximum_passing_passes(self): + # an explicit property value is checked against maximum (passing) + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "alpha": + 1, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissingResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_an_explicit_property_value_is_checked_against_maximum_failing_fails(self): + # an explicit property value is checked against maximum (failing) + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "alpha": + 5, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissingResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_uri_template_format_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_uri_template_format_response_body_for_content_types/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_uri_template_format_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_uri_template_format_response_body_for_content_types/test_post.py new file mode 100644 index 000000000000..83d14877392b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_uri_template_format_response_body_for_content_types/test_post.py @@ -0,0 +1,222 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_uri_template_format_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostUriTemplateFormatResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostUriTemplateFormatResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postUriTemplateFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + False + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postUriTemplateFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 12 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postUriTemplateFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + 13.7 + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postUriTemplateFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + [ + ] + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postUriTemplateFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + None + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postUriTemplateFormatResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + + + +if __name__ == '__main__': + unittest.main()