From c45005437dff68f7303d34272fffff101f653d46 Mon Sep 17 00:00:00 2001 From: Martin Weick Date: Tue, 19 Jan 2021 09:44:20 +0100 Subject: [PATCH] #3 add full test script --- iotclient/iot_client.py | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/iotclient/iot_client.py b/iotclient/iot_client.py index 2c00154..adb6723 100644 --- a/iotclient/iot_client.py +++ b/iotclient/iot_client.py @@ -4,7 +4,7 @@ import requests import json import time from datetime import datetime -import sys, getopt +import sys, getopt, random def build_post_payload(identifier, metadata_payload, file_payload): return { @@ -249,9 +249,32 @@ def test_script(argv): testscriptData.clear() testscriptData.append(True) testCommands.append("deleteall") - #testCommands.append("fetchall") - testCommands.append("trigger") + for i in range(2): + testCommands.append("trigger") + testCommands.append("fetchall") + testCommands.append("delete") + testCommands.append("fetchall") + for i in range(3): + testCommands.append("trigger") + testCommands.append("update") + testCommands.append("fetchall") + for i in range(2): + testCommands.append("trigger") + testCommands.append("update") testCommands.append("trigger") + testCommands.append("delete") + testCommands.append("fetchall") + for i in range(3): + testCommands.append("trigger") + testCommands.append("update") + testCommands.append("fetchall") + for i in range(2): + testCommands.append("trigger") + testCommands.append("fetchall") + testCommands.append("delete") + testCommands.append("fetchall") + for i in range(5): + testCommands.append("trigger") testCommands.append("fetchall") testCommands.append("exit") testscriptData.append(len(testCommands)) @@ -263,12 +286,17 @@ def test_script(argv): # main input loop command = "dummy" test_script(sys.argv[1:]) -i=0 +i = 0 while (command.lower() not in ["exit", "quit", "end"]): try: if testscriptData[0] and i < testscriptData[1]: - command=testCommands[i] + command = testCommands[i] + if i > 0: + time.sleep(random.randrange(5, 60)) + print(datetime.now()) + if command == "delete" or command == "update": + index -= 1 i+=1 else: command = input("Please enter command: ")