Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 765ffc2

Browse files
committed
Fixes python tests
1 parent 4554ac2 commit 765ffc2

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

samples/openapi3/client/petstore/python/tests_manual/test_additional_properties_class.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def test_additional_properties_class(self):
2323
with self.assertRaises(KeyError):
2424
inst["map_property"]
2525
assert inst.get("map_property", schemas.unset) is schemas.unset
26-
with self.assertRaises(AttributeError):
27-
inst.map_property
26+
assert inst.map_property is schemas.unset
2827

2928
inst = AdditionalPropertiesClass.validate({'map_property': {}})
3029
map_property = inst["map_property"]

samples/openapi3/client/petstore/python/tests_manual/test_animal.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,39 +38,40 @@ def testAnimal(self):
3838
inst = animal.Animal.validate({'className': 'Cat', 'color': 'black'})
3939
assert isinstance(inst, animal.AnimalDict)
4040
assert set(inst.keys()) == {'className', 'color'}
41-
assert inst.get_class_name == 'Cat'
41+
assert inst.className == 'Cat'
4242
assert inst["color"] == 'black'
4343
assert isinstance(inst["color"], str)
44-
assert isinstance(inst.get_class_name, str)
44+
assert isinstance(inst.className, str)
4545

4646
# pass in optional param
4747
inst = animal.Animal.validate({'className': 'Cat', 'color': 'black', 'declawed': True})
4848
assert isinstance(inst, animal.AnimalDict)
4949
assert set(inst.keys()) == {'className', 'color', 'declawed'}
50-
assert inst.get_class_name == 'Cat'
50+
assert inst.className == 'Cat'
5151
assert inst["color"] == 'black'
5252
assert inst["declawed"] is True
5353
assert isinstance(inst["color"], str)
54-
assert isinstance(inst.get_class_name, str)
54+
assert isinstance(inst.className, str)
5555
assert isinstance(inst["declawed"], bool)
5656

5757
# make a Dog
5858
inst = animal.Animal.validate({'className': 'Dog', 'color': 'black'})
5959
assert isinstance(inst, animal.AnimalDict)
6060
assert set(inst.keys()) == {'className', 'color'}
61-
assert inst.get_class_name == 'Dog'
61+
assert inst.className == 'Dog'
6262
assert inst["color"] == 'black'
6363
assert isinstance(inst["color"], str)
64-
assert isinstance(inst.get_class_name, str)
64+
assert isinstance(inst.className, str)
6565

6666
# pass in optional param
6767
inst = animal.Animal.validate({'className': 'Dog', 'color': 'black', 'breed':'Labrador'})
6868
assert isinstance(inst, animal.AnimalDict)
6969
assert set(inst.keys()) == {'className', 'color', 'breed'}
70-
assert inst.get_class_name == 'Dog'
70+
assert inst.className == 'Dog'
71+
assert inst.color == 'black'
7172
assert inst["color"] == 'black'
7273
assert inst["breed"] == 'Labrador'
73-
assert isinstance(inst.get_class_name, str)
74+
assert isinstance(inst.className, str)
7475
assert isinstance(inst["color"], str)
7576
assert isinstance(inst["breed"], str)
7677

samples/openapi3/client/petstore/python/tests_manual/test_deserialization.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ class ResponseFor200(api_client.OpenApiResponse[ApiResponse]):
241241
deserialized = ResponseFor200.deserialize(response, self.configuration)
242242
body = deserialized.body
243243
assert isinstance(body, banana.BananaDict)
244-
assert isinstance(body.get_length_cm, float)
245-
self.assertEqual(body.get_length_cm, 3.1415)
244+
assert isinstance(body.lengthCm, float)
245+
self.assertEqual(body.lengthCm, 3.1415)
246246

247247
"""
248248
Float value is serialized without decimal point
@@ -256,8 +256,8 @@ class ResponseFor200(api_client.OpenApiResponse[ApiResponse]):
256256
deserialized = ResponseFor200.deserialize(response, self.configuration)
257257
body = deserialized.body
258258
assert isinstance(body, banana.BananaDict)
259-
self.assertTrue(isinstance(body.get_length_cm, int))
260-
self.assertEqual(body.get_length_cm, 3)
259+
self.assertTrue(isinstance(body.lengthCm, int))
260+
self.assertEqual(body.lengthCm, 3)
261261

262262
def test_deserialize_fruit_null_value(self):
263263
"""

samples/openapi3/client/petstore/python/tests_manual/test_money.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_Money(self):
2424
'currency': 'usd',
2525
'amount': '10.99'
2626
})
27-
self.assertEqual(schemas.as_decimal_(price.get_amount), decimal.Decimal('10.99'))
27+
self.assertEqual(schemas.as_decimal_(price.amount), decimal.Decimal('10.99'))
2828
self.assertEqual(
2929
price,
3030
dict(currency='usd', amount='10.99')

samples/openapi3/client/petstore/python/tests_manual/test_no_additional_properties.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ def testNoAdditionalProperties(self):
3535
id_by_items = inst["id"]
3636
assert id_by_items == 1
3737
assert isinstance(id_by_items, int)
38-
id_by_property = inst.get_id
38+
id_by_property = inst.id
3939
assert id_by_property == 1
4040
assert isinstance(id_by_property, int)
4141
with self.assertRaises(KeyError):
4242
inst["petId"]
4343
assert inst.get("petId", schemas.unset) is schemas.unset
44-
assert inst.get_pet_id is schemas.unset
44+
assert inst.petId is schemas.unset
4545

4646
# works with required + optional
4747
arg: no_additional_properties.NoAdditionalPropertiesDictInput = {

samples/openapi3/client/petstore/python/tests_manual/test_obj_with_required_props.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ class TestObjWithRequiredProps(unittest.TestCase):
2323
configuration_ = schema_configuration.SchemaConfiguration()
2424
obj = obj_with_required_props.ObjWithRequiredProps.validate({'a': 'a', 'b': 'b'})
2525
assert isinstance(obj, obj_with_required_props.ObjWithRequiredPropsDict)
26-
assert isinstance(obj.get_a, str)
26+
assert isinstance(obj.a, str)
2727
assert isinstance(obj['b'], str)
28+
assert isinstance(obj.get_additional_property_('b'), str)
2829

2930

3031
if __name__ == '__main__':

samples/openapi3/client/petstore/python/tests_manual/test_object_model_with_arg_and_args_properties.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def test_ObjectModelWithArgAndArgsProperties(self):
2525
model = object_model_with_arg_and_args_properties.ObjectModelWithArgAndArgsProperties.validate({
2626
'arg': 'a', 'args': 'as'
2727
})
28-
assert model.get_arg == 'a'
29-
assert model.get_args == 'as'
28+
assert model.arg == 'a'
29+
assert model.args == 'as'
3030
assert model['arg'] == 'a'
3131
assert model['args'] == 'as'
3232
self.assertTrue(isinstance(model["arg"], str))

0 commit comments

Comments
 (0)