In Python, I am writing a script that will simulate a customer placing an order. It will consist of creating the order, adding lines to it, and then checking out. I am currently doing it with something like:
api = ['login', 'createOrder', 'scanBarCode', 'addLine', 'checkout']
for apiName in apiList:
#call API
I am designing this more as a framework so it would be easy to add new APIs in case things change. My design question is this: How can I code it so that I can call scanBarCode and addLine N number of times? Something like:
api = ['login', 'createOrder', 'scanBarCode', 'addLine', 'checkout']
numberOfLines = (random number)
for apiName in apiList:
#call API
#if API name is scanBarCode, repeat this and the next API numberOfLines times, then continue with the rest of the flow
Something like the following should get you started: