46
46
LIMITS_PROPERTY = "limits"
47
47
ENV_PROPERTY = "env"
48
48
ARGS_PROPERTY = "args"
49
+ DATA_PROPERTY = "data"
49
50
50
51
51
52
class CommandConfigurationException (Exception ):
@@ -60,6 +61,11 @@ def check_call_config(call):
60
61
raise CommandConfigurationException ("call value not a dictionary: {}" .
61
62
format (call ))
62
63
64
+ for key in call .keys ():
65
+ if key not in [URI_PROPERTY , METHOD_PROPERTY , API_TIMEOUT_PROPERTY , ASYNC_API_TIMEOUT_PROPERTY ,
66
+ DATA_PROPERTY , HEADERS_PROPERTY ]:
67
+ raise CommandConfigurationException (f"unknown property { key } in call { call } " )
68
+
63
69
uri = call .get (URI_PROPERTY )
64
70
if not uri :
65
71
raise CommandConfigurationException (f"no '{ URI_PROPERTY } ' key present in { call } " )
@@ -90,6 +96,40 @@ def check_call_config(call):
90
96
raise CommandConfigurationException (f"{ ASYNC_API_TIMEOUT_PROPERTY } not an integer" , exc )
91
97
92
98
99
+ def check_command_config (command ):
100
+ """
101
+ :param command: dictionary with executable command configuration
102
+ """
103
+ if not isinstance (command , dict ):
104
+ raise CommandConfigurationException (f"command value not a dictionary: { command } " )
105
+
106
+ for key in command .keys ():
107
+ if key not in [ENV_PROPERTY , ARGS_PROPERTY , LIMITS_PROPERTY , ARGS_SUBST_PROPERTY ]:
108
+ raise CommandConfigurationException (f"unknown property { key } in command { command } " )
109
+
110
+ limits = command .get (LIMITS_PROPERTY )
111
+ if limits :
112
+ if not isinstance (command , dict ):
113
+ raise CommandConfigurationException (f"limits value is not a dictionary in { command } " )
114
+
115
+ args = command .get (ARGS_PROPERTY )
116
+ if not args :
117
+ raise CommandConfigurationException (f"empty/missing args property in { command } " )
118
+
119
+ if not isinstance (args , list ):
120
+ raise CommandConfigurationException (f"args property is not a list in { command } " )
121
+
122
+ args_subst = command .get (ARGS_SUBST_PROPERTY )
123
+ if args_subst :
124
+ if not isinstance (args_subst , dict ):
125
+ raise CommandConfigurationException (f"args_subst value is not a dictionary in { command } " )
126
+
127
+ env = command .get (ENV_PROPERTY )
128
+ if env :
129
+ if not isinstance (env , dict ):
130
+ raise CommandConfigurationException (f"env value is not a dictionary in { command } " )
131
+
132
+
93
133
def check_command_property (command ):
94
134
"""
95
135
Check if the 'commands' parameter of CommandSequenceBase() has the right structure
@@ -111,6 +151,9 @@ def check_command_property(command):
111
151
if call_value :
112
152
check_call_config (call_value )
113
153
154
+ if command_value :
155
+ check_command_config (command_value )
156
+
114
157
115
158
class ApiCall :
116
159
"""
@@ -129,7 +172,7 @@ def __init__(self, call_dict):
129
172
if not self .method :
130
173
self .method = "GET"
131
174
132
- self .data = call_dict .get ("data" )
175
+ self .data = call_dict .get (DATA_PROPERTY )
133
176
134
177
self .headers = call_dict .get (HEADERS_PROPERTY )
135
178
if not self .headers :
0 commit comments