Skip to content

Commit 8a4c137

Browse files
committed
refactor _BusinessHost.py to validate target_request parameter
1 parent a3dc836 commit 8a4c137

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/iop/_business_host.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ def send_multi_request_sync(self, target_request:list, timeout=-1, description=N
177177
"""
178178
# create a list of iris.Ens.CallStructure for each target_request
179179
call_list = []
180+
# sanity check
181+
if not isinstance(target_request,list):
182+
raise TypeError("The target_request parameter must be a list")
183+
if len(target_request) == 0:
184+
raise ValueError("The target_request parameter must not be empty")
185+
# check if the target_request is a list of tuple of 2 elements
186+
if not all(isinstance(item, tuple) and len(item) == 2 for item in target_request):
187+
raise TypeError("The target_request parameter must be a list of tuple of 2 elements")
188+
180189
for target,request in target_request:
181190
call = iris.cls("Ens.CallStructure")._New()
182191
call.TargetDispatchName = target

0 commit comments

Comments
 (0)