[python-nextgen] better datetime support in parameters (#14621)

* add allowStringInDateTimeParameters option

* add tests

* add files

* add tests for datetime query parameters

* fix file anme

* trigger build

* fix pytest

* install test requirement

* trigger build

* break build

* add new files

* fix Locale.ROOT

* update doc
This commit is contained in:
William Cheng
2023-02-12 21:11:29 +08:00
committed by GitHub
parent 72c02e4bc1
commit 110460b71a
97 changed files with 8482 additions and 1 deletions

View File

@@ -0,0 +1,56 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.models.bird import Bird # noqa: E501
from openapi_client.rest import ApiException
class TestBird(unittest.TestCase):
"""Bird unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test Bird
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `Bird`
"""
model = openapi_client.models.bird.Bird() # noqa: E501
if include_optional :
return Bird(
size = '',
color = ''
)
else :
return Bird(
)
"""
def testBird(self):
"""Test Bird"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,41 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import openapi_client
from openapi_client.api.body_api import BodyApi # noqa: E501
from openapi_client.rest import ApiException
class TestBodyApi(unittest.TestCase):
"""BodyApi unit test stubs"""
def setUp(self):
self.api = openapi_client.api.body_api.BodyApi() # noqa: E501
def tearDown(self):
pass
def test_test_echo_body_pet(self):
"""Test case for test_echo_body_pet
Test body parameter(s) # noqa: E501
"""
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,56 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.models.category import Category # noqa: E501
from openapi_client.rest import ApiException
class TestCategory(unittest.TestCase):
"""Category unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test Category
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `Category`
"""
model = openapi_client.models.category.Category() # noqa: E501
if include_optional :
return Category(
id = 1,
name = 'Dogs'
)
else :
return Category(
)
"""
def testCategory(self):
"""Test Category"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,57 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.models.data_query import DataQuery # noqa: E501
from openapi_client.rest import ApiException
class TestDataQuery(unittest.TestCase):
"""DataQuery unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test DataQuery
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `DataQuery`
"""
model = openapi_client.models.data_query.DataQuery() # noqa: E501
if include_optional :
return DataQuery(
suffix = '',
text = 'Some text',
var_date = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f')
)
else :
return DataQuery(
)
"""
def testDataQuery(self):
"""Test DataQuery"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,57 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.models.data_query_all_of import DataQueryAllOf # noqa: E501
from openapi_client.rest import ApiException
class TestDataQueryAllOf(unittest.TestCase):
"""DataQueryAllOf unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test DataQueryAllOf
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `DataQueryAllOf`
"""
model = openapi_client.models.data_query_all_of.DataQueryAllOf() # noqa: E501
if include_optional :
return DataQueryAllOf(
suffix = '',
text = 'Some text',
var_date = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f')
)
else :
return DataQueryAllOf(
)
"""
def testDataQueryAllOf(self):
"""Test DataQueryAllOf"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,70 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.models.default_value import DefaultValue # noqa: E501
from openapi_client.rest import ApiException
class TestDefaultValue(unittest.TestCase):
"""DefaultValue unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test DefaultValue
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `DefaultValue`
"""
model = openapi_client.models.default_value.DefaultValue() # noqa: E501
if include_optional :
return DefaultValue(
array_string_enum_default = [
'success'
],
array_string_default = [
''
],
array_integer_default = [
56
],
array_string = [
''
],
array_string_nullable = [
''
],
string_nullable = ''
)
else :
return DefaultValue(
)
"""
def testDefaultValue(self):
"""Test DefaultValue"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,41 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import openapi_client
from openapi_client.api.form_api import FormApi # noqa: E501
from openapi_client.rest import ApiException
class TestFormApi(unittest.TestCase):
"""FormApi unit test stubs"""
def setUp(self):
self.api = openapi_client.api.form_api.FormApi() # noqa: E501
def tearDown(self):
pass
def test_test_form_integer_boolean_string(self):
"""Test case for test_form_integer_boolean_string
Test form parameter(s) # noqa: E501
"""
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,41 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import openapi_client
from openapi_client.api.header_api import HeaderApi # noqa: E501
from openapi_client.rest import ApiException
class TestHeaderApi(unittest.TestCase):
"""HeaderApi unit test stubs"""
def setUp(self):
self.api = openapi_client.api.header_api.HeaderApi() # noqa: E501
def tearDown(self):
pass
def test_test_header_integer_boolean_string(self):
"""Test case for test_header_integer_boolean_string
Test header parameter(s) # noqa: E501
"""
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,77 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.api.query_api import QueryApi # noqa: E501
from openapi_client.rest import ApiException
class TestManual(unittest.TestCase):
"""Manually written tests"""
def setUp(self):
pass
def tearDown(self):
pass
def testDateTimeQueryWithDateTime(self):
api_instance = openapi_client.QueryApi()
datetime_query = datetime.datetime.fromisoformat('2013-10-20T19:20:30+01:00') # datetime | (optional)
date_query = '2013-10-20' # date | (optional)
string_query = 'string_query_example' # str | (optional)
# Test query parameter(s)
api_response = api_instance.test_query_datetime_date_string(datetime_query=datetime_query, date_query=date_query, string_query=string_query)
e = EchoServerResponseParser(api_response)
self.assertEqual(e.path, "/query/datetime/date/string?datetime_query=2013-10-20T19:20:30+01:00&date_query=2013-10-20&string_query=string_query_example")
def testDateTimeQueryWithString(self):
api_instance = openapi_client.QueryApi()
datetime_query = '2013-10-20T19:20:30+01:00' # datetime | (optional)
date_query = '2013-10-20' # date | (optional)
string_query = 'string_query_example' # str | (optional)
# Test query parameter(s)
api_response = api_instance.test_query_datetime_date_string(datetime_query=datetime_query, date_query=date_query, string_query=string_query)
e = EchoServerResponseParser(api_response)
self.assertEqual(e.path, "/query/datetime/date/string?datetime_query=2013-10-20T19:20:30+01:00&date_query=2013-10-20&string_query=string_query_example")
class EchoServerResponseParser():
def __init__(self, http_response):
if http_response is None:
raise ValueError("http response must not be None.")
lines = http_response.split("\n")
self.headers = dict()
x = 0
while x < len(lines):
if x == 0:
items = lines[x].split(" ")
self.method = items[0];
self.path = items[1];
self.protocol = items[2];
elif lines[x] == "": # blank line
self.body = "\n".join(lines[x:])
else:
key_value = lines[x].split(": ")
# store the header key-value pair in headers
if len(key_value) == 2:
self.headers[key_value[0]] = key_value[1]
x = x+1
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,41 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import openapi_client
from openapi_client.api.path_api import PathApi # noqa: E501
from openapi_client.rest import ApiException
class TestPathApi(unittest.TestCase):
"""PathApi unit test stubs"""
def setUp(self):
self.api = openapi_client.api.path_api.PathApi() # noqa: E501
def tearDown(self):
pass
def test_tests_path_string_path_string_integer_path_integer(self):
"""Test case for tests_path_string_path_string_integer_path_integer
Test path parameter(s) # noqa: E501
"""
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,72 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.models.pet import Pet # noqa: E501
from openapi_client.rest import ApiException
class TestPet(unittest.TestCase):
"""Pet unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test Pet
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `Pet`
"""
model = openapi_client.models.pet.Pet() # noqa: E501
if include_optional :
return Pet(
id = 10,
name = 'doggie',
category = openapi_client.models.category.Category(
id = 1,
name = 'Dogs', ),
photo_urls = [
''
],
tags = [
openapi_client.models.tag.Tag(
id = 56,
name = '', )
],
status = 'available'
)
else :
return Pet(
name = 'doggie',
photo_urls = [
''
],
)
"""
def testPet(self):
"""Test Pet"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,58 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.models.query import Query # noqa: E501
from openapi_client.rest import ApiException
class TestQuery(unittest.TestCase):
"""Query unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test Query
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `Query`
"""
model = openapi_client.models.query.Query() # noqa: E501
if include_optional :
return Query(
id = 56,
outcomes = [
'SUCCESS'
]
)
else :
return Query(
)
"""
def testQuery(self):
"""Test Query"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,55 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import openapi_client
from openapi_client.api.query_api import QueryApi # noqa: E501
from openapi_client.rest import ApiException
class TestQueryApi(unittest.TestCase):
"""QueryApi unit test stubs"""
def setUp(self):
self.api = openapi_client.api.query_api.QueryApi() # noqa: E501
def tearDown(self):
pass
def test_test_query_integer_boolean_string(self):
"""Test case for test_query_integer_boolean_string
Test query parameter(s) # noqa: E501
"""
pass
def test_test_query_style_form_explode_true_array_string(self):
"""Test case for test_query_style_form_explode_true_array_string
Test query parameter(s) # noqa: E501
"""
pass
def test_test_query_style_form_explode_true_object(self):
"""Test case for test_query_style_form_explode_true_object
Test query parameter(s) # noqa: E501
"""
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,37 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.models.string_enum_ref import StringEnumRef # noqa: E501
from openapi_client.rest import ApiException
class TestStringEnumRef(unittest.TestCase):
"""StringEnumRef unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testStringEnumRef(self):
"""Test StringEnumRef"""
# inst = StringEnumRef()
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,56 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.models.tag import Tag # noqa: E501
from openapi_client.rest import ApiException
class TestTag(unittest.TestCase):
"""Tag unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test Tag
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `Tag`
"""
model = openapi_client.models.tag.Tag() # noqa: E501
if include_optional :
return Tag(
id = 56,
name = ''
)
else :
return Tag(
)
"""
def testTag(self):
"""Test Tag"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,58 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.models.test_query_style_deep_object_explode_true_object_all_of_query_object_parameter import TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter # noqa: E501
from openapi_client.rest import ApiException
class TestTestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(unittest.TestCase):
"""TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter`
"""
model = openapi_client.models.test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter() # noqa: E501
if include_optional :
return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(
size = '',
color = '',
id = 1,
name = 'Dogs'
)
else :
return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(
)
"""
def testTestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(self):
"""Test TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,57 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import openapi_client
from openapi_client.models.test_query_style_form_explode_true_array_string_query_object_parameter import TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter # noqa: E501
from openapi_client.rest import ApiException
class TestTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(unittest.TestCase):
"""TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter`
"""
model = openapi_client.models.test_query_style_form_explode_true_array_string_query_object_parameter.TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter() # noqa: E501
if include_optional :
return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(
values = [
''
]
)
else :
return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(
)
"""
def testTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(self):
"""Test TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()