[python] Renames python generators (#7965)

* python->python-legacy, python-experimental->python

* test with openjdk8

* test with openjdk11

* comment out rm

* move kotlin tests to circleci

* move kotlin tests

* move tests to circleci

* fix circleci

* rearrange test

* move tests

* use wrapper

Co-authored-by: Justin Black <justin.a.black@gmail.com>
This commit is contained in:
William Cheng
2020-11-18 14:34:00 +08:00
committed by GitHub
parent c08f14500e
commit 3bf8ca7484
1213 changed files with 40106 additions and 38656 deletions

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.additional_properties_any_type import AdditionalPropertiesAnyType
class TestAdditionalPropertiesAnyType(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestAdditionalPropertiesAnyType(unittest.TestCase):
def testAdditionalPropertiesAnyType(self):
"""Test AdditionalPropertiesAnyType"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.additional_properties_any_type.AdditionalPropertiesAnyType() # noqa: E501
# model = AdditionalPropertiesAnyType() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.additional_properties_array import AdditionalPropertiesArray # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.additional_properties_array import AdditionalPropertiesArray
class TestAdditionalPropertiesArray(unittest.TestCase):
@@ -30,9 +29,21 @@ class TestAdditionalPropertiesArray(unittest.TestCase):
def testAdditionalPropertiesArray(self):
"""Test AdditionalPropertiesArray"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.additional_properties_array.AdditionalPropertiesArray() # noqa: E501
pass
# can make model without additional properties
model = AdditionalPropertiesArray()
# can make one with additional properties
import datetime
some_val = []
model = AdditionalPropertiesArray(some_key=some_val)
assert model['some_key'] == some_val
some_val = [True, datetime.date(1970,1,1), datetime.datetime(1970,1,1), {}, 3.1, 1, [], 'hello']
model = AdditionalPropertiesArray(some_key=some_val)
assert model['some_key'] == some_val
# type checking works on additional properties
with self.assertRaises(petstore_api.ApiTypeError) as exc:
model = AdditionalPropertiesArray(some_key='some string')
if __name__ == '__main__':

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.additional_properties_boolean import AdditionalPropertiesBoolean # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.additional_properties_boolean import AdditionalPropertiesBoolean
class TestAdditionalPropertiesBoolean(unittest.TestCase):
@@ -30,9 +29,16 @@ class TestAdditionalPropertiesBoolean(unittest.TestCase):
def testAdditionalPropertiesBoolean(self):
"""Test AdditionalPropertiesBoolean"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.additional_properties_boolean.AdditionalPropertiesBoolean() # noqa: E501
pass
# can make model without additional properties
model = AdditionalPropertiesBoolean()
# can make one with additional properties
model = AdditionalPropertiesBoolean(some_key=True)
assert model['some_key'] == True
# type checking works on additional properties
with self.assertRaises(petstore_api.ApiTypeError) as exc:
model = AdditionalPropertiesBoolean(some_key='True')
if __name__ == '__main__':

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.additional_properties_class import AdditionalPropertiesClass # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.additional_properties_class import AdditionalPropertiesClass
class TestAdditionalPropertiesClass(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestAdditionalPropertiesClass(unittest.TestCase):
def testAdditionalPropertiesClass(self):
"""Test AdditionalPropertiesClass"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.additional_properties_class.AdditionalPropertiesClass() # noqa: E501
# model = AdditionalPropertiesClass() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.additional_properties_integer import AdditionalPropertiesInteger # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.additional_properties_integer import AdditionalPropertiesInteger
class TestAdditionalPropertiesInteger(unittest.TestCase):
@@ -30,9 +29,16 @@ class TestAdditionalPropertiesInteger(unittest.TestCase):
def testAdditionalPropertiesInteger(self):
"""Test AdditionalPropertiesInteger"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.additional_properties_integer.AdditionalPropertiesInteger() # noqa: E501
pass
# can make model without additional properties
model = AdditionalPropertiesInteger()
# can make one with additional properties
model = AdditionalPropertiesInteger(some_key=3)
assert model['some_key'] == 3
# type checking works on additional properties
with self.assertRaises(petstore_api.ApiTypeError) as exc:
model = AdditionalPropertiesInteger(some_key=11.3)
if __name__ == '__main__':

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.additional_properties_number import AdditionalPropertiesNumber # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.additional_properties_number import AdditionalPropertiesNumber
class TestAdditionalPropertiesNumber(unittest.TestCase):
@@ -30,9 +29,16 @@ class TestAdditionalPropertiesNumber(unittest.TestCase):
def testAdditionalPropertiesNumber(self):
"""Test AdditionalPropertiesNumber"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.additional_properties_number.AdditionalPropertiesNumber() # noqa: E501
pass
# can make model without additional properties
model = AdditionalPropertiesNumber()
# can make one with additional properties
model = AdditionalPropertiesNumber(some_key=11.3)
assert model['some_key'] == 11.3
# type checking works on additional properties
with self.assertRaises(petstore_api.ApiTypeError) as exc:
model = AdditionalPropertiesNumber(some_key=10)
if __name__ == '__main__':

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.additional_properties_object import AdditionalPropertiesObject # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.additional_properties_object import AdditionalPropertiesObject
class TestAdditionalPropertiesObject(unittest.TestCase):
@@ -30,9 +29,21 @@ class TestAdditionalPropertiesObject(unittest.TestCase):
def testAdditionalPropertiesObject(self):
"""Test AdditionalPropertiesObject"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.additional_properties_object.AdditionalPropertiesObject() # noqa: E501
pass
# can make model without additional properties
model = AdditionalPropertiesObject()
# can make one with additional properties
some_val = {}
model = AdditionalPropertiesObject(some_key=some_val)
assert model['some_key'] == some_val
import datetime
some_val = {'a': True, 'b': datetime.date(1970,1,1), 'c': datetime.datetime(1970,1,1), 'd': {}, 'e': 3.1, 'f': 1, 'g': [], 'h': 'hello'}
model = AdditionalPropertiesObject(some_key=some_val)
assert model['some_key'] == some_val
# type checking works on additional properties
with self.assertRaises(petstore_api.ApiTypeError) as exc:
model = AdditionalPropertiesObject(some_key='some string')
if __name__ == '__main__':

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.additional_properties_string import AdditionalPropertiesString # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.additional_properties_string import AdditionalPropertiesString
class TestAdditionalPropertiesString(unittest.TestCase):
@@ -30,9 +29,16 @@ class TestAdditionalPropertiesString(unittest.TestCase):
def testAdditionalPropertiesString(self):
"""Test AdditionalPropertiesString"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.additional_properties_string.AdditionalPropertiesString() # noqa: E501
pass
# can make model without additional properties
model = AdditionalPropertiesString()
# can make one with additional properties
model = AdditionalPropertiesString(some_key='some_val')
assert model['some_key'] == 'some_val'
# type checking works on additional properties
with self.assertRaises(petstore_api.ApiTypeError) as exc:
model = AdditionalPropertiesString(some_key=True)
if __name__ == '__main__':

View File

@@ -11,13 +11,22 @@
from __future__ import absolute_import
import sys
import unittest
import datetime
import petstore_api
from petstore_api.models.animal import Animal # noqa: E501
from petstore_api.rest import ApiException
try:
from petstore_api.model import cat
except ImportError:
cat = sys.modules[
'petstore_api.model.cat']
try:
from petstore_api.model import dog
except ImportError:
dog = sys.modules[
'petstore_api.model.dog']
from petstore_api.model.animal import Animal
class TestAnimal(unittest.TestCase):
"""Animal unit test stubs"""
@@ -28,26 +37,11 @@ class TestAnimal(unittest.TestCase):
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test Animal
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.animal.Animal() # noqa: E501
if include_optional :
return Animal(
class_name = '0',
color = 'red'
)
else :
return Animal(
class_name = '0',
)
def testAnimal(self):
"""Test Animal"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
# FIXME: construct object with mandatory attributes with example values
# model = Animal() # noqa: E501
pass
if __name__ == '__main__':

View File

@@ -0,0 +1,43 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
try:
from petstore_api.model import animal
except ImportError:
animal = sys.modules[
'petstore_api.model.animal']
from petstore_api.model.animal_farm import AnimalFarm
class TestAnimalFarm(unittest.TestCase):
"""AnimalFarm unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testAnimalFarm(self):
"""Test AnimalFarm"""
# FIXME: construct object with mandatory attributes with example values
# model = AnimalFarm() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -5,7 +5,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
@@ -16,20 +16,19 @@ import unittest
import petstore_api
from petstore_api.api.another_fake_api import AnotherFakeApi # noqa: E501
from petstore_api.rest import ApiException
class TestAnotherFakeApi(unittest.TestCase):
"""AnotherFakeApi unit test stubs"""
def setUp(self):
self.api = petstore_api.api.another_fake_api.AnotherFakeApi() # noqa: E501
self.api = AnotherFakeApi() # noqa: E501
def tearDown(self):
pass
def test_test_special_tags(self):
"""Test case for test_special_tags
def test_call_123_test_special_tags(self):
"""Test case for call_123_test_special_tags
To test special tags # noqa: E501
"""

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.api_response import ApiResponse # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.api_response import ApiResponse
class TestApiResponse(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestApiResponse(unittest.TestCase):
def testApiResponse(self):
"""Test ApiResponse"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.api_response.ApiResponse() # noqa: E501
# model = ApiResponse() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly
class TestArrayOfArrayOfNumberOnly(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestArrayOfArrayOfNumberOnly(unittest.TestCase):
def testArrayOfArrayOfNumberOnly(self):
"""Test ArrayOfArrayOfNumberOnly"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.array_of_array_of_number_only.ArrayOfArrayOfNumberOnly() # noqa: E501
# model = ArrayOfArrayOfNumberOnly() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.array_of_number_only import ArrayOfNumberOnly
class TestArrayOfNumberOnly(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestArrayOfNumberOnly(unittest.TestCase):
def testArrayOfNumberOnly(self):
"""Test ArrayOfNumberOnly"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.array_of_number_only.ArrayOfNumberOnly() # noqa: E501
# model = ArrayOfNumberOnly() # noqa: E501
pass

View File

@@ -5,18 +5,22 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.array_test import ArrayTest # noqa: E501
from petstore_api.rest import ApiException
try:
from petstore_api.model import read_only_first
except ImportError:
read_only_first = sys.modules[
'petstore_api.model.read_only_first']
from petstore_api.model.array_test import ArrayTest
class TestArrayTest(unittest.TestCase):
@@ -31,7 +35,7 @@ class TestArrayTest(unittest.TestCase):
def testArrayTest(self):
"""Test ArrayTest"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.array_test.ArrayTest() # noqa: E501
# model = ArrayTest() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.capitalization import Capitalization # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.capitalization import Capitalization
class TestCapitalization(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestCapitalization(unittest.TestCase):
def testCapitalization(self):
"""Test Capitalization"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.capitalization.Capitalization() # noqa: E501
# model = Capitalization() # noqa: E501
pass

View File

@@ -11,13 +11,22 @@
from __future__ import absolute_import
import sys
import unittest
import datetime
import petstore_api
from petstore_api.models.cat import Cat # noqa: E501
from petstore_api.rest import ApiException
try:
from petstore_api.model import animal
except ImportError:
animal = sys.modules[
'petstore_api.model.animal']
try:
from petstore_api.model import cat_all_of
except ImportError:
cat_all_of = sys.modules[
'petstore_api.model.cat_all_of']
from petstore_api.model.cat import Cat
class TestCat(unittest.TestCase):
"""Cat unit test stubs"""
@@ -28,24 +37,11 @@ class TestCat(unittest.TestCase):
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test Cat
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.cat.Cat() # noqa: E501
if include_optional :
return Cat(
declawed = True
)
else :
return Cat(
)
def testCat(self):
"""Test Cat"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
# FIXME: construct object with mandatory attributes with example values
# model = Cat() # noqa: E501
pass
if __name__ == '__main__':

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.cat_all_of import CatAllOf # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.cat_all_of import CatAllOf
class TestCatAllOf(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestCatAllOf(unittest.TestCase):
def testCatAllOf(self):
"""Test CatAllOf"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.cat_all_of.CatAllOf() # noqa: E501
# model = CatAllOf() # noqa: E501
pass

View File

@@ -11,13 +11,12 @@
from __future__ import absolute_import
import sys
import unittest
import datetime
import petstore_api
from petstore_api.models.category import Category # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.category import Category
class TestCategory(unittest.TestCase):
"""Category unit test stubs"""
@@ -28,26 +27,11 @@ class TestCategory(unittest.TestCase):
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 """
# model = petstore_api.models.category.Category() # noqa: E501
if include_optional :
return Category(
id = 56,
name = 'default-name'
)
else :
return Category(
name = 'default-name',
)
def testCategory(self):
"""Test Category"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
# FIXME: construct object with mandatory attributes with example values
# model = Category() # noqa: E501
pass
if __name__ == '__main__':

View File

@@ -0,0 +1,153 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
try:
from petstore_api.model import child_all_of
except ImportError:
child_all_of = sys.modules[
'petstore_api.model.child_all_of']
try:
from petstore_api.model import parent
except ImportError:
parent = sys.modules[
'petstore_api.model.parent']
from petstore_api.model.child import Child
class TestChild(unittest.TestCase):
"""Child unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testChild(self):
"""Test Child"""
# make an instance of Child, a composed schema model
radio_waves = True
tele_vision = True
inter_net = True
child = Child(
radio_waves=radio_waves,
tele_vision=tele_vision,
inter_net=inter_net
)
# check its properties
self.assertEqual(child.radio_waves, radio_waves)
self.assertEqual(child.tele_vision, tele_vision)
self.assertEqual(child.inter_net, inter_net)
# access them with keys
self.assertEqual(child['radio_waves'], radio_waves)
self.assertEqual(child['tele_vision'], tele_vision)
self.assertEqual(child['inter_net'], inter_net)
# access them with getattr
self.assertEqual(getattr(child, 'radio_waves'), radio_waves)
self.assertEqual(getattr(child, 'tele_vision'), tele_vision)
self.assertEqual(getattr(child, 'inter_net'), inter_net)
# check the model's to_dict result
self.assertEqual(
child.to_dict(),
{
'radio_waves': radio_waves,
'tele_vision': tele_vision,
'inter_net': inter_net,
}
)
# setting a value that doesn't exist raises an exception
# with a key
with self.assertRaises(petstore_api.ApiAttributeError):
child['invalid_variable'] = 'some value'
# with setattr
with self.assertRaises(petstore_api.ApiAttributeError):
setattr(child, 'invalid_variable', 'some value')
# with hasattr
self.assertFalse(hasattr(child, 'invalid_variable'))
# getting a value that doesn't exist raises an exception
# with a key
with self.assertRaises(petstore_api.ApiAttributeError):
invalid_variable = child['invalid_variable']
# with getattr
self.assertEqual(getattr(child, 'invalid_variable', 'some value'), 'some value')
with self.assertRaises(petstore_api.ApiAttributeError):
invalid_variable = getattr(child, 'invalid_variable')
# make sure that the ModelComposed class properties are correct
# model.composed_schemas() stores the anyOf/allOf/oneOf info
self.assertEqual(
child._composed_schemas,
{
'anyOf': [],
'allOf': [
child_all_of.ChildAllOf,
parent.Parent,
],
'oneOf': [],
}
)
# model._composed_instances is a list of the instances that were
# made from the anyOf/allOf/OneOf classes in model._composed_schemas()
for composed_instance in child._composed_instances:
if composed_instance.__class__ == parent.Parent:
parent_instance = composed_instance
elif composed_instance.__class__ == child_all_of.ChildAllOf:
child_allof_instance = composed_instance
self.assertEqual(
child._composed_instances,
[child_allof_instance, parent_instance]
)
# model._var_name_to_model_instances maps the variable name to the
# model instances which store that variable
self.assertEqual(
child._var_name_to_model_instances,
{
'radio_waves': [child, parent_instance],
'tele_vision': [child, parent_instance],
'inter_net': [child, child_allof_instance]
}
)
# model._additional_properties_model_instances stores a list of
# models which have the property additional_properties_type != None
self.assertEqual(
child._additional_properties_model_instances, []
)
# if we modify one of the properties owned by multiple
# model_instances we get an exception when we try to access that
# property because the retrieved values are not all the same
child_allof_instance.inter_net = False
with self.assertRaises(petstore_api.ApiValueError):
inter_net = child.inter_net
# including extra parameters raises an exception
with self.assertRaises(petstore_api.ApiValueError):
child = Child(
radio_waves=radio_waves,
tele_vision=tele_vision,
inter_net=inter_net,
unknown_property='some value')
if __name__ == '__main__':
unittest.main()

View File

@@ -11,16 +11,15 @@
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.big_cat import BigCat # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.child_all_of import ChildAllOf
class TestBigCat(unittest.TestCase):
"""BigCat unit test stubs"""
class TestChildAllOf(unittest.TestCase):
"""ChildAllOf unit test stubs"""
def setUp(self):
pass
@@ -28,10 +27,10 @@ class TestBigCat(unittest.TestCase):
def tearDown(self):
pass
def testBigCat(self):
"""Test BigCat"""
def testChildAllOf(self):
"""Test ChildAllOf"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.big_cat.BigCat() # noqa: E501
# model = ChildAllOf() # noqa: E501
pass

View File

@@ -0,0 +1,48 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
try:
from petstore_api.model import child_cat_all_of
except ImportError:
child_cat_all_of = sys.modules[
'petstore_api.model.child_cat_all_of']
try:
from petstore_api.model import parent_pet
except ImportError:
parent_pet = sys.modules[
'petstore_api.model.parent_pet']
from petstore_api.model.child_cat import ChildCat
class TestChildCat(unittest.TestCase):
"""ChildCat unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testChildCat(self):
"""Test ChildCat"""
# FIXME: construct object with mandatory attributes with example values
# model = ChildCat() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -11,16 +11,15 @@
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.big_cat_all_of import BigCatAllOf # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.child_cat_all_of import ChildCatAllOf
class TestBigCatAllOf(unittest.TestCase):
"""BigCatAllOf unit test stubs"""
class TestChildCatAllOf(unittest.TestCase):
"""ChildCatAllOf unit test stubs"""
def setUp(self):
pass
@@ -28,10 +27,10 @@ class TestBigCatAllOf(unittest.TestCase):
def tearDown(self):
pass
def testBigCatAllOf(self):
"""Test BigCatAllOf"""
def testChildCatAllOf(self):
"""Test ChildCatAllOf"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.big_cat_all_of.BigCatAllOf() # noqa: E501
# model = ChildCatAllOf() # noqa: E501
pass

View File

@@ -0,0 +1,48 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
try:
from petstore_api.model import child_dog_all_of
except ImportError:
child_dog_all_of = sys.modules[
'petstore_api.model.child_dog_all_of']
try:
from petstore_api.model import parent_pet
except ImportError:
parent_pet = sys.modules[
'petstore_api.model.parent_pet']
from petstore_api.model.child_dog import ChildDog
class TestChildDog(unittest.TestCase):
"""ChildDog unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testChildDog(self):
"""Test ChildDog"""
# FIXME: construct object with mandatory attributes with example values
# model = ChildDog() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -5,22 +5,21 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.outer_enum import OuterEnum # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.child_dog_all_of import ChildDogAllOf
class TestOuterEnum(unittest.TestCase):
"""OuterEnum unit test stubs"""
class TestChildDogAllOf(unittest.TestCase):
"""ChildDogAllOf unit test stubs"""
def setUp(self):
pass
@@ -28,10 +27,10 @@ class TestOuterEnum(unittest.TestCase):
def tearDown(self):
pass
def testOuterEnum(self):
"""Test OuterEnum"""
def testChildDogAllOf(self):
"""Test ChildDogAllOf"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.outer_enum.OuterEnum() # noqa: E501
# model = ChildDogAllOf() # noqa: E501
pass

View File

@@ -0,0 +1,48 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
try:
from petstore_api.model import child_lizard_all_of
except ImportError:
child_lizard_all_of = sys.modules[
'petstore_api.model.child_lizard_all_of']
try:
from petstore_api.model import parent_pet
except ImportError:
parent_pet = sys.modules[
'petstore_api.model.parent_pet']
from petstore_api.model.child_lizard import ChildLizard
class TestChildLizard(unittest.TestCase):
"""ChildLizard unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testChildLizard(self):
"""Test ChildLizard"""
# FIXME: construct object with mandatory attributes with example values
# model = ChildLizard() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -5,22 +5,21 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.outer_composite import OuterComposite # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.child_lizard_all_of import ChildLizardAllOf
class TestOuterComposite(unittest.TestCase):
"""OuterComposite unit test stubs"""
class TestChildLizardAllOf(unittest.TestCase):
"""ChildLizardAllOf unit test stubs"""
def setUp(self):
pass
@@ -28,10 +27,10 @@ class TestOuterComposite(unittest.TestCase):
def tearDown(self):
pass
def testOuterComposite(self):
"""Test OuterComposite"""
def testChildLizardAllOf(self):
"""Test ChildLizardAllOf"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.outer_composite.OuterComposite() # noqa: E501
# model = ChildLizardAllOf() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.class_model import ClassModel # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.class_model import ClassModel
class TestClassModel(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestClassModel(unittest.TestCase):
def testClassModel(self):
"""Test ClassModel"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.class_model.ClassModel() # noqa: E501
# model = ClassModel() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.client import Client # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.client import Client
class TestClient(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestClient(unittest.TestCase):
def testClient(self):
"""Test Client"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.client.Client() # noqa: E501
# model = Client() # noqa: E501
pass

View File

@@ -5,18 +5,27 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.dog import Dog # noqa: E501
from petstore_api.rest import ApiException
try:
from petstore_api.model import animal
except ImportError:
animal = sys.modules[
'petstore_api.model.animal']
try:
from petstore_api.model import dog_all_of
except ImportError:
dog_all_of = sys.modules[
'petstore_api.model.dog_all_of']
from petstore_api.model.dog import Dog
class TestDog(unittest.TestCase):
@@ -30,10 +39,113 @@ class TestDog(unittest.TestCase):
def testDog(self):
"""Test Dog"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.dog.Dog() # noqa: E501
pass
# make an instance of dog, a composed schema model
class_name = 'Dog'
color = 'white'
breed = 'Jack Russel Terrier'
dog = Dog(
class_name=class_name,
color=color,
breed=breed
)
# check its properties
self.assertEqual(dog.class_name, class_name)
self.assertEqual(dog.color, color)
self.assertEqual(dog.breed, breed)
# access them with keys
self.assertEqual(dog['class_name'], class_name)
self.assertEqual(dog['color'], color)
self.assertEqual(dog['breed'], breed)
# access them with getattr
self.assertEqual(getattr(dog, 'class_name'), class_name)
self.assertEqual(getattr(dog, 'color'), color)
self.assertEqual(getattr(dog, 'breed'), breed)
# check the model's to_dict result
self.assertEqual(
dog.to_dict(),
{
'class_name': class_name,
'color': color,
'breed': breed,
}
)
# setting a value that doesn't exist raises an exception
# with a key
with self.assertRaises(AttributeError):
dog['invalid_variable'] = 'some value'
# with setattr
with self.assertRaises(AttributeError):
setattr(dog, 'invalid_variable', 'some value')
# getting a value that doesn't exist raises an exception
# with a key
with self.assertRaises(AttributeError):
invalid_variable = dog['invalid_variable']
# with getattr
self.assertEqual(getattr(dog, 'invalid_variable', 'some value'), 'some value')
with self.assertRaises(AttributeError):
invalid_variable = getattr(dog, 'invalid_variable')
# make sure that the ModelComposed class properties are correct
# model.composed_schemas() stores the anyOf/allOf/oneOf info
self.assertEqual(
dog._composed_schemas,
{
'anyOf': [],
'allOf': [
animal.Animal,
dog_all_of.DogAllOf,
],
'oneOf': [],
}
)
# model._composed_instances is a list of the instances that were
# made from the anyOf/allOf/OneOf classes in model._composed_schemas()
for composed_instance in dog._composed_instances:
if composed_instance.__class__ == animal.Animal:
animal_instance = composed_instance
elif composed_instance.__class__ == dog_all_of.DogAllOf:
dog_allof_instance = composed_instance
self.assertEqual(
dog._composed_instances,
[animal_instance, dog_allof_instance]
)
# model._var_name_to_model_instances maps the variable name to the
# model instances which store that variable
self.assertEqual(
dog._var_name_to_model_instances,
{
'breed': [dog, dog_allof_instance],
'class_name': [dog, animal_instance],
'color': [dog, animal_instance]
}
)
# model._additional_properties_model_instances stores a list of
# models which have the property additional_properties_type != None
self.assertEqual(
dog._additional_properties_model_instances, []
)
# if we modify one of the properties owned by multiple
# model_instances we get an exception when we try to access that
# property because the retrieved values are not all the same
dog_allof_instance.breed = 'Golden Retriever'
with self.assertRaises(petstore_api.ApiValueError):
breed = dog.breed
# including extra parameters raises an exception
with self.assertRaises(petstore_api.ApiValueError):
dog = Dog(
class_name=class_name,
color=color,
breed=breed,
unknown_property='some value'
)
if __name__ == '__main__':
unittest.main()

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.dog_all_of import DogAllOf # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.dog_all_of import DogAllOf
class TestDogAllOf(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestDogAllOf(unittest.TestCase):
def testDogAllOf(self):
"""Test DogAllOf"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.dog_all_of.DogAllOf() # noqa: E501
# model = DogAllOf() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.enum_arrays import EnumArrays # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.enum_arrays import EnumArrays
class TestEnumArrays(unittest.TestCase):
@@ -28,12 +27,136 @@ class TestEnumArrays(unittest.TestCase):
def tearDown(self):
pass
def testEnumArrays(self):
"""Test EnumArrays"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.enum_arrays.EnumArrays() # noqa: E501
pass
def test_enumarrays_init(self):
#
# Check various combinations of valid values.
#
fish_or_crab = EnumArrays(just_symbol=">=")
self.assertEqual(fish_or_crab.just_symbol, ">=")
# if optional property is unset we raise an exception
with self.assertRaises(petstore_api.ApiAttributeError) as exc:
self.assertEqual(fish_or_crab.array_enum, None)
fish_or_crab = EnumArrays(just_symbol="$", array_enum=["fish"])
self.assertEqual(fish_or_crab.just_symbol, "$")
self.assertEqual(fish_or_crab.array_enum, ["fish"])
fish_or_crab = EnumArrays(just_symbol=">=", array_enum=["fish"])
self.assertEqual(fish_or_crab.just_symbol, ">=")
self.assertEqual(fish_or_crab.array_enum, ["fish"])
fish_or_crab = EnumArrays(just_symbol="$", array_enum=["crab"])
self.assertEqual(fish_or_crab.just_symbol, "$")
self.assertEqual(fish_or_crab.array_enum, ["crab"])
#
# Check if setting invalid values fails
#
with self.assertRaises(petstore_api.ApiValueError) as exc:
fish_or_crab = EnumArrays(just_symbol="<=")
with self.assertRaises(petstore_api.ApiValueError) as exc:
fish_or_crab = EnumArrays(just_symbol="$", array_enum=["dog"])
with self.assertRaises(petstore_api.ApiTypeError) as exc:
fish_or_crab = EnumArrays(just_symbol=["$"], array_enum=["crab"])
def test_enumarrays_setter(self):
#
# Check various combinations of valid values
#
fish_or_crab = EnumArrays()
fish_or_crab.just_symbol = ">="
self.assertEqual(fish_or_crab.just_symbol, ">=")
fish_or_crab.just_symbol = "$"
self.assertEqual(fish_or_crab.just_symbol, "$")
fish_or_crab.array_enum = []
self.assertEqual(fish_or_crab.array_enum, [])
fish_or_crab.array_enum = ["fish"]
self.assertEqual(fish_or_crab.array_enum, ["fish"])
fish_or_crab.array_enum = ["fish", "fish", "fish"]
self.assertEqual(fish_or_crab.array_enum, ["fish", "fish", "fish"])
fish_or_crab.array_enum = ["crab"]
self.assertEqual(fish_or_crab.array_enum, ["crab"])
fish_or_crab.array_enum = ["crab", "fish"]
self.assertEqual(fish_or_crab.array_enum, ["crab", "fish"])
fish_or_crab.array_enum = ["crab", "fish", "crab", "fish"]
self.assertEqual(fish_or_crab.array_enum, ["crab", "fish", "crab", "fish"])
#
# Check if setting invalid values fails
#
fish_or_crab = EnumArrays()
with self.assertRaises(petstore_api.ApiValueError) as exc:
fish_or_crab.just_symbol = "!="
with self.assertRaises(petstore_api.ApiTypeError) as exc:
fish_or_crab.just_symbol = ["fish"]
with self.assertRaises(petstore_api.ApiValueError) as exc:
fish_or_crab.array_enum = ["cat"]
with self.assertRaises(petstore_api.ApiValueError) as exc:
fish_or_crab.array_enum = ["fish", "crab", "dog"]
with self.assertRaises(petstore_api.ApiTypeError) as exc:
fish_or_crab.array_enum = "fish"
def test_todict(self):
#
# Check if dictionary serialization works
#
dollar_fish_crab_dict = {
'just_symbol': "$",
'array_enum': ["fish", "crab"]
}
dollar_fish_crab = EnumArrays(
just_symbol="$", array_enum=["fish", "crab"])
self.assertEqual(dollar_fish_crab_dict, dollar_fish_crab.to_dict())
#
# Sanity check for different arrays
#
dollar_crab_fish_dict = {
'just_symbol': "$",
'array_enum': ["crab", "fish"]
}
dollar_fish_crab = EnumArrays(
just_symbol="$", array_enum=["fish", "crab"])
self.assertNotEqual(dollar_crab_fish_dict, dollar_fish_crab.to_dict())
def test_equals(self):
#
# Check if object comparison works
#
fish1 = EnumArrays(just_symbol="$", array_enum=["fish"])
fish2 = EnumArrays(just_symbol="$", array_enum=["fish"])
self.assertEqual(fish1, fish2)
fish = EnumArrays(just_symbol="$", array_enum=["fish"])
crab = EnumArrays(just_symbol="$", array_enum=["crab"])
self.assertNotEqual(fish, crab)
dollar = EnumArrays(just_symbol="$")
greater = EnumArrays(just_symbol=">=")
self.assertNotEqual(dollar, greater)
if __name__ == '__main__':
unittest.main()

View File

@@ -11,13 +11,12 @@
from __future__ import absolute_import
import sys
import unittest
import datetime
import petstore_api
from petstore_api.models.enum_class import EnumClass # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.enum_class import EnumClass
class TestEnumClass(unittest.TestCase):
"""EnumClass unit test stubs"""
@@ -28,23 +27,11 @@ class TestEnumClass(unittest.TestCase):
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test EnumClass
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.enum_class.EnumClass() # noqa: E501
if include_optional :
return EnumClass(
)
else :
return EnumClass(
)
def testEnumClass(self):
"""Test EnumClass"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
# FIXME: construct object with mandatory attributes with example values
# model = EnumClass() # noqa: E501
pass
if __name__ == '__main__':

View File

@@ -5,18 +5,22 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.enum_test import EnumTest # noqa: E501
from petstore_api.rest import ApiException
try:
from petstore_api.model import string_enum
except ImportError:
string_enum = sys.modules[
'petstore_api.model.string_enum']
from petstore_api.model.enum_test import EnumTest
class TestEnumTest(unittest.TestCase):
@@ -31,7 +35,7 @@ class TestEnumTest(unittest.TestCase):
def testEnumTest(self):
"""Test EnumTest"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.enum_test.EnumTest() # noqa: E501
# model = EnumTest() # noqa: E501
pass

View File

@@ -5,7 +5,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
@@ -16,38 +16,78 @@ import unittest
import petstore_api
from petstore_api.api.fake_api import FakeApi # noqa: E501
from petstore_api.rest import ApiException
class TestFakeApi(unittest.TestCase):
"""FakeApi unit test stubs"""
def setUp(self):
self.api = petstore_api.api.fake_api.FakeApi() # noqa: E501
self.api = FakeApi() # noqa: E501
def tearDown(self):
pass
def test_fake_outer_boolean_serialize(self):
"""Test case for fake_outer_boolean_serialize
def test_create_xml_item(self):
"""Test case for create_xml_item
creates an XmlItem # noqa: E501
"""
pass
def test_fake_outer_composite_serialize(self):
"""Test case for fake_outer_composite_serialize
def test_boolean(self):
"""Test case for boolean
"""
pass
endpoint = self.api.boolean
assert endpoint.openapi_types['body'] == (bool,)
assert endpoint.settings['response_type'] == (bool,)
def test_fake_outer_number_serialize(self):
"""Test case for fake_outer_number_serialize
def test_string(self):
"""Test case for string
"""
pass
endpoint = self.api.string
assert endpoint.openapi_types['body'] == (str,)
assert endpoint.settings['response_type'] == (str,)
def test_fake_outer_string_serialize(self):
"""Test case for fake_outer_string_serialize
def test_object_model_with_ref_props(self):
"""Test case for object_model_with_ref_props
"""
from petstore_api.model import object_model_with_ref_props
endpoint = self.api.object_model_with_ref_props
assert endpoint.openapi_types['body'] == (object_model_with_ref_props.ObjectModelWithRefProps,)
assert endpoint.settings['response_type'] == (object_model_with_ref_props.ObjectModelWithRefProps,)
def test_string_enum(self):
"""Test case for string_enum
"""
from petstore_api.model import string_enum
endpoint = self.api.string_enum
assert endpoint.openapi_types['body'] == (string_enum.StringEnum,)
assert endpoint.settings['response_type'] == (string_enum.StringEnum,)
def test_array_model(self):
"""Test case for array_model
"""
from petstore_api.model import animal_farm
endpoint = self.api.array_model
assert endpoint.openapi_types['body'] == (animal_farm.AnimalFarm,)
assert endpoint.settings['response_type'] == (animal_farm.AnimalFarm,)
def test_number_with_validations(self):
"""Test case for number_with_validations
"""
from petstore_api.model import number_with_validations
endpoint = self.api.number_with_validations
assert endpoint.openapi_types['body'] == (number_with_validations.NumberWithValidations,)
assert endpoint.settings['response_type'] == (number_with_validations.NumberWithValidations,)
def test_test_body_with_file_schema(self):
"""Test case for test_body_with_file_schema
"""
pass
@@ -65,18 +105,77 @@ class TestFakeApi(unittest.TestCase):
"""
pass
def test_test_endpoint_enums_length_one(self):
"""Test case for test_endpoint_enums_length_one
"""
# when we omit the required enums of length one, they are still set
endpoint = self.api.test_endpoint_enums_length_one
import six
if six.PY3:
from unittest.mock import patch
else:
from mock import patch
with patch.object(endpoint, 'call_with_http_info') as call_with_http_info:
endpoint()
call_with_http_info.assert_called_with(
_check_input_type=True,
_check_return_type=True,
_host_index=None,
_preload_content=True,
_request_timeout=None,
_return_http_data_only=True,
async_req=False,
header_number=1.234,
path_integer=34,
path_string='hello',
query_integer=3,
query_string='brillig'
)
def test_test_endpoint_parameters(self):
"""Test case for test_endpoint_parameters
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
"""
pass
# check that we can access the endpoint's validations
endpoint = self.api.test_endpoint_parameters
assert endpoint.validations[('number',)] == {
'inclusive_maximum': 543.2,
'inclusive_minimum': 32.1,
}
# make sure that an exception is thrown on an invalid value
keyword_args = dict(
number=544, # invalid
double=100,
pattern_without_delimiter="abc",
byte='sample string'
)
with self.assertRaises(petstore_api.ApiValueError):
self.api.test_endpoint_parameters(**keyword_args)
def test_test_enum_parameters(self):
"""Test case for test_enum_parameters
To test enum parameters # noqa: E501
"""
# check that we can access the endpoint's allowed_values
endpoint = self.api.test_enum_parameters
assert endpoint.allowed_values[('enum_query_string',)] == {
"_ABC": "_abc",
"-EFG": "-efg",
"(XYZ)": "(xyz)"
}
# make sure that an exception is thrown on an invalid value
keyword_args = dict(enum_query_string="bad value")
with self.assertRaises(petstore_api.ApiValueError):
self.api.test_enum_parameters(**keyword_args)
def test_test_group_parameters(self):
"""Test case for test_group_parameters
Fake endpoint to test group parameters (optional) # noqa: E501
"""
pass
def test_test_inline_additional_properties(self):

View File

@@ -5,25 +5,24 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.api.fake_classname_tags_123_api import FakeClassnameTags123Api # noqa: E501
from petstore_api.rest import ApiException
class TestFakeClassnameTags123Api(unittest.TestCase):
"""FakeClassnameTags123Api unit test stubs"""
def setUp(self):
self.api = petstore_api.api.fake_classname_tags_123_api.FakeClassnameTags123Api() # noqa: E501
self.api = FakeClassnameTags123Api() # noqa: E501
def tearDown(self):
pass

View File

@@ -11,13 +11,12 @@
from __future__ import absolute_import
import sys
import unittest
import datetime
import petstore_api
from petstore_api.models.file import File # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.file import File
class TestFile(unittest.TestCase):
"""File unit test stubs"""
@@ -28,24 +27,11 @@ class TestFile(unittest.TestCase):
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test File
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.file.File() # noqa: E501
if include_optional :
return File(
source_uri = '0'
)
else :
return File(
)
def testFile(self):
"""Test File"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
# FIXME: construct object with mandatory attributes with example values
# model = File() # noqa: E501
pass
if __name__ == '__main__':

View File

@@ -11,13 +11,17 @@
from __future__ import absolute_import
import sys
import unittest
import datetime
import petstore_api
from petstore_api.models.file_schema_test_class import FileSchemaTestClass # noqa: E501
from petstore_api.rest import ApiException
try:
from petstore_api.model import file
except ImportError:
file = sys.modules[
'petstore_api.model.file']
from petstore_api.model.file_schema_test_class import FileSchemaTestClass
class TestFileSchemaTestClass(unittest.TestCase):
"""FileSchemaTestClass unit test stubs"""
@@ -28,29 +32,11 @@ class TestFileSchemaTestClass(unittest.TestCase):
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test FileSchemaTestClass
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.file_schema_test_class.FileSchemaTestClass() # noqa: E501
if include_optional :
return FileSchemaTestClass(
file = petstore_api.models.file.File(
source_uri = '0', ),
files = [
petstore_api.models.file.File(
source_uri = '0', )
]
)
else :
return FileSchemaTestClass(
)
def testFileSchemaTestClass(self):
"""Test FileSchemaTestClass"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
# FIXME: construct object with mandatory attributes with example values
# model = FileSchemaTestClass() # noqa: E501
pass
if __name__ == '__main__':

View File

@@ -11,59 +11,143 @@
from __future__ import absolute_import
import sys
import unittest
import datetime
import petstore_api
from petstore_api.models.format_test import FormatTest # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.format_test import FormatTest
class TestFormatTest(unittest.TestCase):
"""FormatTest unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test FormatTest
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.format_test.FormatTest() # noqa: E501
if include_optional :
return FormatTest(
integer = 1E+1,
int32 = 2E+1,
int64 = 56,
number = 32.1,
float = 54.3,
double = 67.8,
string = 'a',
byte = 'YQ==',
binary = 'bytes',
date = datetime.datetime.strptime('1975-12-30', '%Y-%m-%d').date(),
date_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
uuid = '72f98069-206d-4f12-9f12-3d1e525a8e84',
password = '0123456789',
big_decimal = 1
)
else :
return FormatTest(
number = 32.1,
byte = 'YQ==',
date = datetime.datetime.strptime('1975-12-30', '%Y-%m-%d').date(),
password = '0123456789',
import datetime
self.required_named_args = dict(
number=40.1,
byte='what',
date=datetime.date(2019, 3, 23),
password='rainbowtable'
)
def testFormatTest(self):
"""Test FormatTest"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
def test_integer(self):
var_name = 'integer'
validations = FormatTest.validations[(var_name,)]
keyword_args = {}
keyword_args.update(self.required_named_args)
key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)]
for key, adder in key_adder_pairs:
# value outside the bounds throws an error
with self.assertRaises(petstore_api.ApiValueError):
keyword_args[var_name] = validations[key] + adder
FormatTest(**keyword_args)
# value inside the bounds works
keyword_args[var_name] = validations[key]
assert (getattr(FormatTest(**keyword_args), var_name) ==
validations[key])
def test_int32(self):
var_name = 'int32'
validations = FormatTest.validations[(var_name,)]
keyword_args = {}
keyword_args.update(self.required_named_args)
key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)]
for key, adder in key_adder_pairs:
# value outside the bounds throws an error
with self.assertRaises(petstore_api.ApiValueError):
keyword_args[var_name] = validations[key] + adder
FormatTest(**keyword_args)
# value inside the bounds works
keyword_args[var_name] = validations[key]
assert (getattr(FormatTest(**keyword_args), var_name) ==
validations[key])
def test_number(self):
var_name = 'number'
validations = FormatTest.validations[(var_name,)]
keyword_args = {}
keyword_args.update(self.required_named_args)
key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)]
for key, adder in key_adder_pairs:
# value outside the bounds throws an error
with self.assertRaises(petstore_api.ApiValueError):
keyword_args[var_name] = validations[key] + adder
FormatTest(**keyword_args)
# value inside the bounds works
keyword_args[var_name] = validations[key]
assert (getattr(FormatTest(**keyword_args), var_name) ==
validations[key])
def test_float(self):
var_name = 'float'
validations = FormatTest.validations[(var_name,)]
keyword_args = {}
keyword_args.update(self.required_named_args)
key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)]
for key, adder in key_adder_pairs:
# value outside the bounds throws an error
with self.assertRaises(petstore_api.ApiValueError):
keyword_args[var_name] = validations[key] + adder
FormatTest(**keyword_args)
# value inside the bounds works
keyword_args[var_name] = validations[key]
assert (getattr(FormatTest(**keyword_args), var_name) ==
validations[key])
def test_double(self):
var_name = 'double'
validations = FormatTest.validations[(var_name,)]
keyword_args = {}
keyword_args.update(self.required_named_args)
key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)]
for key, adder in key_adder_pairs:
# value outside the bounds throws an error
with self.assertRaises(petstore_api.ApiValueError):
keyword_args[var_name] = validations[key] + adder
FormatTest(**keyword_args)
# value inside the bounds works
keyword_args[var_name] = validations[key]
assert (getattr(FormatTest(**keyword_args), var_name) ==
validations[key])
def test_password(self):
var_name = 'password'
validations = FormatTest.validations[(var_name,)]
keyword_args = {}
keyword_args.update(self.required_named_args)
key_adder_pairs = [('max_length', 1), ('min_length', -1)]
for key, adder in key_adder_pairs:
# value outside the bounds throws an error
with self.assertRaises(petstore_api.ApiValueError):
keyword_args[var_name] = 'a'*(validations[key] + adder)
FormatTest(**keyword_args)
# value inside the bounds works
keyword_args[var_name] = 'a'*validations[key]
assert (getattr(FormatTest(**keyword_args), var_name) ==
'a'*validations[key])
def test_string(self):
var_name = 'string'
validations = FormatTest.validations[(var_name,)]
keyword_args = {}
keyword_args.update(self.required_named_args)
values_invalid = ['abc3', '1', '.', ' ', 'مرحبا', '']
for value_invalid in values_invalid:
# invalid values throw exceptions
with self.assertRaises(petstore_api.ApiValueError):
keyword_args[var_name] = value_invalid
FormatTest(**keyword_args)
# valid value works
value_valid = 'abcdz'
keyword_args[var_name] = value_valid
assert getattr(FormatTest(**keyword_args), var_name) == value_valid
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,38 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.model.grandparent import Grandparent
class TestGrandparent(unittest.TestCase):
"""Grandparent unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testGrandparent(self):
"""Test Grandparent"""
# FIXME: construct object with mandatory attributes with example values
# model = Grandparent() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,58 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
try:
from petstore_api.model import child_cat
except ImportError:
child_cat = sys.modules[
'petstore_api.model.child_cat']
try:
from petstore_api.model import child_dog
except ImportError:
child_dog = sys.modules[
'petstore_api.model.child_dog']
try:
from petstore_api.model import child_lizard
except ImportError:
child_lizard = sys.modules[
'petstore_api.model.child_lizard']
try:
from petstore_api.model import parent_pet
except ImportError:
parent_pet = sys.modules[
'petstore_api.model.parent_pet']
from petstore_api.model.grandparent_animal import GrandparentAnimal
class TestGrandparentAnimal(unittest.TestCase):
"""GrandparentAnimal unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testGrandparentAnimal(self):
"""Test GrandparentAnimal"""
# FIXME: construct object with mandatory attributes with example values
# model = GrandparentAnimal() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.has_only_read_only import HasOnlyReadOnly # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.has_only_read_only import HasOnlyReadOnly
class TestHasOnlyReadOnly(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestHasOnlyReadOnly(unittest.TestCase):
def testHasOnlyReadOnly(self):
"""Test HasOnlyReadOnly"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.has_only_read_only.HasOnlyReadOnly() # noqa: E501
# model = HasOnlyReadOnly() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.list import List # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.list import List
class TestList(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestList(unittest.TestCase):
def testList(self):
"""Test List"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.list.List() # noqa: E501
# model = List() # noqa: E501
pass

View File

@@ -11,13 +11,17 @@
from __future__ import absolute_import
import sys
import unittest
import datetime
import petstore_api
from petstore_api.models.map_test import MapTest # noqa: E501
from petstore_api.rest import ApiException
try:
from petstore_api.model import string_boolean_map
except ImportError:
string_boolean_map = sys.modules[
'petstore_api.model.string_boolean_map']
from petstore_api.model.map_test import MapTest
class TestMapTest(unittest.TestCase):
"""MapTest unit test stubs"""
@@ -28,38 +32,94 @@ class TestMapTest(unittest.TestCase):
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test MapTest
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.map_test.MapTest() # noqa: E501
if include_optional :
return MapTest(
map_map_of_string = {
'key' : {
'key' : '0'
}
},
map_of_enum_string = {
'UPPER' : 'UPPER'
},
direct_map = {
'key' : True
},
indirect_map = {
'key' : True
}
)
else :
return MapTest(
)
def test_maptest_init(self):
#
# Test MapTest construction with valid values
#
up_or_low_dict = {
'UPPER': "UP",
'lower': "low"
}
map_enum_test = MapTest(map_of_enum_string=up_or_low_dict)
def testMapTest(self):
"""Test MapTest"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
self.assertEqual(map_enum_test.map_of_enum_string, up_or_low_dict)
map_of_map_of_strings = {
'valueDict': up_or_low_dict
}
map_enum_test = MapTest(map_map_of_string=map_of_map_of_strings)
self.assertEqual(map_enum_test.map_map_of_string, map_of_map_of_strings)
#
# Make sure that the init fails for invalid enum values
#
black_or_white_dict = {
'black': "UP",
'white': "low"
}
with self.assertRaises(petstore_api.ApiValueError):
MapTest(map_of_enum_string=black_or_white_dict)
def test_maptest_setter(self):
#
# Check with some valid values
#
map_enum_test = MapTest()
up_or_low_dict = {
'UPPER': "UP",
'lower': "low"
}
map_enum_test.map_of_enum_string = up_or_low_dict
self.assertEqual(map_enum_test.map_of_enum_string, up_or_low_dict)
#
# Check if the setter fails for invalid enum values
#
map_enum_test = MapTest()
black_or_white_dict = {
'black': "UP",
'white': "low"
}
with self.assertRaises(petstore_api.ApiValueError):
map_enum_test.map_of_enum_string = black_or_white_dict
def test_todict(self):
#
# Check dictionary serialization
#
map_enum_test = MapTest()
up_or_low_dict = {
'UPPER': "UP",
'lower': "low"
}
map_of_map_of_strings = {
'valueDict': up_or_low_dict
}
indirect_map = string_boolean_map.StringBooleanMap(**{
'option1': True
})
direct_map = {
'option2': False
}
map_enum_test.map_of_enum_string = up_or_low_dict
map_enum_test.map_map_of_string = map_of_map_of_strings
map_enum_test.indirect_map = indirect_map
map_enum_test.direct_map = direct_map
self.assertEqual(map_enum_test.map_of_enum_string, up_or_low_dict)
self.assertEqual(map_enum_test.map_map_of_string, map_of_map_of_strings)
self.assertEqual(map_enum_test.indirect_map, indirect_map)
self.assertEqual(map_enum_test.direct_map, direct_map)
expected_dict = {
'map_of_enum_string': up_or_low_dict,
'map_map_of_string': map_of_map_of_strings,
'indirect_map': indirect_map.to_dict(),
'direct_map': direct_map
}
self.assertEqual(map_enum_test.to_dict(), expected_dict)
if __name__ == '__main__':
unittest.main()

View File

@@ -11,13 +11,17 @@
from __future__ import absolute_import
import sys
import unittest
import datetime
import petstore_api
from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass # noqa: E501
from petstore_api.rest import ApiException
try:
from petstore_api.model import animal
except ImportError:
animal = sys.modules[
'petstore_api.model.animal']
from petstore_api.model.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass
class TestMixedPropertiesAndAdditionalPropertiesClass(unittest.TestCase):
"""MixedPropertiesAndAdditionalPropertiesClass unit test stubs"""
@@ -28,30 +32,11 @@ class TestMixedPropertiesAndAdditionalPropertiesClass(unittest.TestCase):
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test MixedPropertiesAndAdditionalPropertiesClass
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass() # noqa: E501
if include_optional :
return MixedPropertiesAndAdditionalPropertiesClass(
uuid = '0',
date_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
map = {
'key' : petstore_api.models.animal.Animal(
class_name = '0',
color = 'red', )
}
)
else :
return MixedPropertiesAndAdditionalPropertiesClass(
)
def testMixedPropertiesAndAdditionalPropertiesClass(self):
"""Test MixedPropertiesAndAdditionalPropertiesClass"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
# FIXME: construct object with mandatory attributes with example values
# model = MixedPropertiesAndAdditionalPropertiesClass() # noqa: E501
pass
if __name__ == '__main__':

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.model200_response import Model200Response # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.model200_response import Model200Response
class TestModel200Response(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestModel200Response(unittest.TestCase):
def testModel200Response(self):
"""Test Model200Response"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.model200_response.Model200Response() # noqa: E501
# model = Model200Response() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.model_return import ModelReturn # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.model_return import ModelReturn
class TestModelReturn(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestModelReturn(unittest.TestCase):
def testModelReturn(self):
"""Test ModelReturn"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.model_return.ModelReturn() # noqa: E501
# model = ModelReturn() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.name import Name # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.name import Name
class TestName(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestName(unittest.TestCase):
def testName(self):
"""Test Name"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.name.Name() # noqa: E501
# model = Name() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.number_only import NumberOnly # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.number_only import NumberOnly
class TestNumberOnly(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestNumberOnly(unittest.TestCase):
def testNumberOnly(self):
"""Test NumberOnly"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.number_only.NumberOnly() # noqa: E501
# model = NumberOnly() # noqa: E501
pass

View File

@@ -0,0 +1,45 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.model.number_with_validations import NumberWithValidations
class TestNumberWithValidations(unittest.TestCase):
"""NumberWithValidations unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testNumberWithValidations(self):
"""Test NumberWithValidations"""
valid_values = [10.0, 15.0, 20.0]
for valid_value in valid_values:
model = NumberWithValidations(valid_value)
assert model.value == valid_value
invalid_values = [9.0, 21.0]
for invalid_value in invalid_values:
with self.assertRaises(petstore_api.ApiValueError):
NumberWithValidations(invalid_value)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,49 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
try:
from petstore_api.model import number_with_validations
except ImportError:
number_with_validations = sys.modules[
'petstore_api.model.number_with_validations']
from petstore_api.model.object_model_with_ref_props import ObjectModelWithRefProps
class TestObjectModelWithRefProps(unittest.TestCase):
"""ObjectModelWithRefProps unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testObjectModelWithRefProps(self):
"""Test ObjectModelWithRefProps"""
from petstore_api.model.number_with_validations import NumberWithValidations
self.assertEqual(
ObjectModelWithRefProps.openapi_types,
{
'my_number': (NumberWithValidations,),
'my_string': (str,),
'my_boolean': (bool,),
}
)
if __name__ == '__main__':
unittest.main()

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.order import Order # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.order import Order
class TestOrder(unittest.TestCase):
@@ -30,9 +29,12 @@ class TestOrder(unittest.TestCase):
def testOrder(self):
"""Test Order"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.order.Order() # noqa: E501
pass
order = Order()
order.status = "placed"
self.assertEqual("placed", order.status)
with self.assertRaises(petstore_api.ApiValueError):
order.status = "invalid"
if __name__ == '__main__':

View File

@@ -0,0 +1,48 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
try:
from petstore_api.model import grandparent
except ImportError:
grandparent = sys.modules[
'petstore_api.model.grandparent']
try:
from petstore_api.model import parent_all_of
except ImportError:
parent_all_of = sys.modules[
'petstore_api.model.parent_all_of']
from petstore_api.model.parent import Parent
class TestParent(unittest.TestCase):
"""Parent unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testParent(self):
"""Test Parent"""
# FIXME: construct object with mandatory attributes with example values
# model = Parent() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,38 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.model.parent_all_of import ParentAllOf
class TestParentAllOf(unittest.TestCase):
"""ParentAllOf unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testParentAllOf(self):
"""Test ParentAllOf"""
# FIXME: construct object with mandatory attributes with example values
# model = ParentAllOf() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,58 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
try:
from petstore_api.model import child_cat
except ImportError:
child_cat = sys.modules[
'petstore_api.model.child_cat']
try:
from petstore_api.model import child_dog
except ImportError:
child_dog = sys.modules[
'petstore_api.model.child_dog']
try:
from petstore_api.model import child_lizard
except ImportError:
child_lizard = sys.modules[
'petstore_api.model.child_lizard']
try:
from petstore_api.model import grandparent_animal
except ImportError:
grandparent_animal = sys.modules[
'petstore_api.model.grandparent_animal']
from petstore_api.model.parent_pet import ParentPet
class TestParentPet(unittest.TestCase):
"""ParentPet unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testParentPet(self):
"""Test ParentPet"""
# FIXME: construct object with mandatory attributes with example values
# model = ParentPet() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -11,13 +11,22 @@
from __future__ import absolute_import
import sys
import unittest
import datetime
import petstore_api
from petstore_api.models.pet import Pet # noqa: E501
from petstore_api.rest import ApiException
try:
from petstore_api.model import category
except ImportError:
category = sys.modules[
'petstore_api.model.category']
try:
from petstore_api.models import tag
except ImportError:
tag = sys.modules[
'petstore_api.model.tag']
from petstore_api.model.pet import Pet
class TestPet(unittest.TestCase):
"""Pet unit test stubs"""
@@ -28,41 +37,52 @@ class TestPet(unittest.TestCase):
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 """
# model = petstore_api.models.pet.Pet() # noqa: E501
if include_optional :
return Pet(
id = 56,
category = petstore_api.models.category.Category(
id = 56,
name = 'default-name', ),
name = 'doggie',
photo_urls = [
'0'
],
tags = [
petstore_api.models.tag.Tag(
id = 56,
name = '0', )
],
status = 'available'
)
else :
return Pet(
name = 'doggie',
photo_urls = [
'0'
],
)
def test_to_str(self):
pet = Pet(name="test name", photo_urls=["string"])
pet.id = 1
pet.status = "available"
cate = category.Category()
cate.id = 1
cate.name = "dog"
pet.category = cate
tag1 = tag.Tag()
tag1.id = 1
pet.tags = [tag1]
def testPet(self):
"""Test Pet"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
data = ("{'category': {'id': 1, 'name': 'dog'},\n"
" 'id': 1,\n"
" 'name': 'test name',\n"
" 'photo_urls': ['string'],\n"
" 'status': 'available',\n"
" 'tags': [{'id': 1}]}")
self.assertEqual(data, pet.to_str())
def test_equal(self):
pet1 = Pet(name="test name", photo_urls=["string"])
pet1.id = 1
pet1.status = "available"
cate1 = category.Category()
cate1.id = 1
cate1.name = "dog"
tag1 = tag.Tag()
tag1.id = 1
pet1.tags = [tag1]
pet2 = Pet(name="test name", photo_urls=["string"])
pet2.id = 1
pet2.status = "available"
cate2 = category.Category()
cate2.id = 1
cate2.name = "dog"
tag2 = tag.Tag()
tag2.id = 1
pet2.tags = [tag2]
self.assertTrue(pet1 == pet2)
# reset pet1 tags to empty array so that object comparison returns false
pet1.tags = []
self.assertFalse(pet1 == pet2)
if __name__ == '__main__':

View File

@@ -5,25 +5,24 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.api.pet_api import PetApi # noqa: E501
from petstore_api.rest import ApiException
class TestPetApi(unittest.TestCase):
"""PetApi unit test stubs"""
def setUp(self):
self.api = petstore_api.api.pet_api.PetApi() # noqa: E501
self.api = PetApi() # noqa: E501
def tearDown(self):
pass
@@ -84,6 +83,13 @@ class TestPetApi(unittest.TestCase):
"""
pass
def test_upload_file_with_required_file(self):
"""Test case for upload_file_with_required_file
uploads an image (required) # noqa: E501
"""
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,44 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.model.player import Player
class TestPlayer(unittest.TestCase):
"""Player unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testPlayer(self):
"""Test Player"""
# we can make a player without an enemy_player property
jane = Player(name="Jane")
# we can make a player with an enemy_player
sally = Player(name="Sally", enemy_player=jane)
# we can make a player with an inline enemy_player
jim = Player(
name="Jim",
enemy_player=Player(name="Sam")
)
if __name__ == '__main__':
unittest.main()

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.read_only_first import ReadOnlyFirst # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.read_only_first import ReadOnlyFirst
class TestReadOnlyFirst(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestReadOnlyFirst(unittest.TestCase):
def testReadOnlyFirst(self):
"""Test ReadOnlyFirst"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.read_only_first.ReadOnlyFirst() # noqa: E501
# model = ReadOnlyFirst() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.special_model_name import SpecialModelName # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.special_model_name import SpecialModelName
class TestSpecialModelName(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestSpecialModelName(unittest.TestCase):
def testSpecialModelName(self):
"""Test SpecialModelName"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.special_model_name.SpecialModelName() # noqa: E501
# model = SpecialModelName() # noqa: E501
pass

View File

@@ -5,7 +5,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
@@ -16,14 +16,13 @@ import unittest
import petstore_api
from petstore_api.api.store_api import StoreApi # noqa: E501
from petstore_api.rest import ApiException
class TestStoreApi(unittest.TestCase):
"""StoreApi unit test stubs"""
def setUp(self):
self.api = petstore_api.api.store_api.StoreApi() # noqa: E501
self.api = StoreApi() # noqa: E501
def tearDown(self):
pass

View File

@@ -0,0 +1,38 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.model.string_boolean_map import StringBooleanMap
class TestStringBooleanMap(unittest.TestCase):
"""StringBooleanMap unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testStringBooleanMap(self):
"""Test StringBooleanMap"""
# FIXME: construct object with mandatory attributes with example values
# model = StringBooleanMap() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,49 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.model.string_enum import StringEnum
class TestStringEnum(unittest.TestCase):
"""StringEnum unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testStringEnum(self):
"""Test StringEnum"""
"""Test OuterEnum"""
# make sure that we can access its allowed_values
assert StringEnum.allowed_values[('value',)] == {
'PLACED': "placed",
'APPROVED': "approved",
'DELIVERED': "delivered"
}
# make sure that an exception is thrown on an invalid value
with self.assertRaises(petstore_api.ApiValueError):
StringEnum('bad_value')
# make sure valid value works
valid_value = StringEnum.allowed_values[('value',)]['PLACED']
assert valid_value == StringEnum(valid_value).value
if __name__ == '__main__':
unittest.main()

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.tag import Tag # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.tag import Tag
class TestTag(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestTag(unittest.TestCase):
def testTag(self):
"""Test Tag"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.tag.Tag() # noqa: E501
# model = Tag() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.type_holder_default import TypeHolderDefault # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.type_holder_default import TypeHolderDefault
class TestTypeHolderDefault(unittest.TestCase):
@@ -32,15 +31,8 @@ class TestTypeHolderDefault(unittest.TestCase):
"""Test TypeHolderDefault"""
# required_vars are set to None now until swagger-parser/swagger-core fixes
# https://github.com/swagger-api/swagger-parser/issues/971
required_vars = ['number_item', 'integer_item', 'array_item']
sample_values = [5.67, 4, [-5, 2, -6]]
assigned_variables = {}
for index, required_var in enumerate(required_vars):
with self.assertRaises(ValueError):
model = TypeHolderDefault(**assigned_variables)
assigned_variables[required_var] = sample_values[index]
# assigned_variables is fully set, all required variables passed in
model = TypeHolderDefault(**assigned_variables)
array_item = [1, 2, 3]
model = TypeHolderDefault(array_item=array_item)
self.assertEqual(model.string_item, 'what')
self.assertEqual(model.bool_item, True)

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.type_holder_example import TypeHolderExample # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.type_holder_example import TypeHolderExample
class TestTypeHolderExample(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestTypeHolderExample(unittest.TestCase):
def testTypeHolderExample(self):
"""Test TypeHolderExample"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.type_holder_example.TypeHolderExample() # noqa: E501
# model = TypeHolderExample() # noqa: E501
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.user import User # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.user import User
class TestUser(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestUser(unittest.TestCase):
def testUser(self):
"""Test User"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.user.User() # noqa: E501
# model = User() # noqa: E501
pass

View File

@@ -5,7 +5,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
@@ -16,14 +16,13 @@ import unittest
import petstore_api
from petstore_api.api.user_api import UserApi # noqa: E501
from petstore_api.rest import ApiException
class TestUserApi(unittest.TestCase):
"""UserApi unit test stubs"""
def setUp(self):
self.api = petstore_api.api.user_api.UserApi() # noqa: E501
self.api = UserApi() # noqa: E501
def tearDown(self):
pass

View File

@@ -5,18 +5,17 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import sys
import unittest
import petstore_api
from petstore_api.models.xml_item import XmlItem # noqa: E501
from petstore_api.rest import ApiException
from petstore_api.model.xml_item import XmlItem
class TestXmlItem(unittest.TestCase):
@@ -31,7 +30,7 @@ class TestXmlItem(unittest.TestCase):
def testXmlItem(self):
"""Test XmlItem"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.xml_item.XmlItem() # noqa: E501
# model = XmlItem() # noqa: E501
pass