11
11
from almdrlib .client import Config
12
12
from almdrlib .client import Operation
13
13
from alsdkdefs import OpenAPIKeyWord
14
-
14
+ from collections import OrderedDict
15
15
16
16
class TestSdk_open_api_support (unittest .TestCase ):
17
17
"""Tests for `python_boilerplate` package."""
@@ -32,54 +32,65 @@ def setUp(self):
32
32
def tearDown (self ):
33
33
"""Tear down test fixtures, if any."""
34
34
35
- def test_000_getting_schemas (self ):
36
- """Test listing services."""
37
- self .assertTrue (len (Session .get_service_api ("testapi" )))
38
- print (f"SCHEMA: { json .dumps (Session .get_service_api ('testapi' ))} " )
39
-
40
- def test_001_test_client_initialization (self ):
41
- """Test OpenAPI Client initialization."""
35
+ # def test_000_getting_schemas(self):
36
+ # """Test listing services."""
37
+ # self.assertTrue(len(Session.get_service_api("testapi")))
38
+ # print(f"SCHEMA: {json.dumps(Session.get_service_api('testapi'))}")
39
+ #
40
+ # def test_001_test_client_initialization(self):
41
+ # """Test OpenAPI Client initialization."""
42
+ # client = Client(self._service_name)
43
+ # self.assertIsInstance(client, Client)
44
+ # self.assertIsNotNone(client.description)
45
+ # self.assertNotEqual(client.name, "")
46
+ # self.assertIsNotNone(client.server)
47
+ # self.assertNotEqual(client.info, {})
48
+ # self.assertIsNotNone(client.operations)
49
+ # self.assertNotEqual(client.spec, {})
50
+ # self.assertNotEqual(client.operations, {})
51
+ #
52
+ # def test_002_test_operations_schema(self):
53
+ # """Test Operations Schema Validity."""
54
+ # client = Client(self._service_name)
55
+ #
56
+ # for t_operation_name, t_operation_schema in \
57
+ # self.test_data['operations'].items():
58
+ # operation = client.operations.get(t_operation_name)
59
+ # self.assertIsInstance(operation, Operation)
60
+ # self.assertEqual(operation.operation_id, t_operation_name)
61
+ # self.assertEqual(operation.description,
62
+ # t_operation_schema[OpenAPIKeyWord.DESCRIPTION])
63
+ #
64
+ # schema = operation.get_schema()
65
+ # self.assertIsNot(schema, {})
66
+ #
67
+ # t_operation_parameters = t_operation_schema[
68
+ # OpenAPIKeyWord.PARAMETERS]
69
+ #
70
+ # operation_parameters = schema[OpenAPIKeyWord.PARAMETERS]
71
+ # for name, value in t_operation_parameters.items():
72
+ # self.assertEqual(value, operation_parameters[name])
73
+ #
74
+ # if OpenAPIKeyWord.CONTENT in t_operation_schema:
75
+ # t_operation_content = t_operation_schema[
76
+ # OpenAPIKeyWord.CONTENT]
77
+ # operation_content = schema[OpenAPIKeyWord.CONTENT]
78
+ # for name, value in t_operation_content.items():
79
+ # self.assertEqual(value, operation_content[name])
80
+ #
81
+ # def test_003_default_objects_creation(self):
82
+ # """Checks initialisation at least happens"""
83
+ # self.assertIsInstance(Session(), Session)
84
+ # self.assertIsInstance(Config(), Config)
85
+ # self.assertIsInstance(Client(self._service_name), Client)
86
+
87
+ def test_004_test_operations_compound_schema (self ):
88
+ """Test request body properties are properly normalized when schema is compound at the top level"""
42
89
client = Client (self ._service_name )
43
- self .assertIsInstance (client , Client )
44
- self .assertIsNotNone (client .description )
45
- self .assertNotEqual (client .name , "" )
46
- self .assertIsNotNone (client .server )
47
- self .assertNotEqual (client .info , {})
48
- self .assertIsNotNone (client .operations )
49
- self .assertNotEqual (client .spec , {})
50
- self .assertNotEqual (client .operations , {})
51
-
52
- def test_002_test_operations_schema (self ):
53
- """Test Operations Schema Validity."""
54
- client = Client (self ._service_name )
55
-
56
- for t_operation_name , t_operation_schema in \
57
- self .test_data ['operations' ].items ():
58
- operation = client .operations .get (t_operation_name )
59
- self .assertIsInstance (operation , Operation )
60
- self .assertEqual (operation .operation_id , t_operation_name )
61
- self .assertEqual (operation .description ,
62
- t_operation_schema [OpenAPIKeyWord .DESCRIPTION ])
63
-
64
- schema = operation .get_schema ()
65
- self .assertIsNot (schema , {})
66
-
67
- t_operation_parameters = t_operation_schema [
68
- OpenAPIKeyWord .PARAMETERS ]
69
-
70
- operation_parameters = schema [OpenAPIKeyWord .PARAMETERS ]
71
- for name , value in t_operation_parameters .items ():
72
- self .assertEqual (value , operation_parameters [name ])
73
-
74
- if OpenAPIKeyWord .CONTENT in t_operation_schema :
75
- t_operation_content = t_operation_schema [
76
- OpenAPIKeyWord .CONTENT ]
77
- operation_content = schema [OpenAPIKeyWord .CONTENT ]
78
- for name , value in t_operation_content .items ():
79
- self .assertEqual (value , operation_content [name ])
80
-
81
- def test_003_default_objects_creation (self ):
82
- """Checks initialisation at least happens"""
83
- self .assertIsInstance (Session (), Session )
84
- self .assertIsInstance (Config (), Config )
85
- self .assertIsInstance (Client (self ._service_name ), Client )
90
+ operation = client .operations .get ('post_data_compound' )
91
+ self .assertEqual (OrderedDict ([('prop' ,
92
+ OrderedDict ([('oneOf' , [
93
+ OrderedDict ([('type' , 'integer' )]),
94
+ OrderedDict ([('type' , 'string' )])
95
+ ])]))]),
96
+ operation .body ._content ['application/json' ]._properties )
0 commit comments