From 93b5dcd3d72c46b8f564b0fd153623688d8e3af2 Mon Sep 17 00:00:00 2001 From: nukalasr Date: Wed, 26 Aug 2015 14:47:37 -0700 Subject: [PATCH 1/7] Create GenerateCurlScript.py Generates curl script from runscope tests. Run scope allows variables and scripting etc. This script needs to be updated to get make a curl equivalent of all runscope features. --- examples/backup-tests/GenerateCurlScript.py | 98 +++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 examples/backup-tests/GenerateCurlScript.py diff --git a/examples/backup-tests/GenerateCurlScript.py b/examples/backup-tests/GenerateCurlScript.py new file mode 100644 index 0000000..0ca62b1 --- /dev/null +++ b/examples/backup-tests/GenerateCurlScript.py @@ -0,0 +1,98 @@ +import json +import time +import requests +import os +import sys +import inspect + +# Global dictionary +g = {} + +# Retrieves list of buckets for the authed account +# https://www.runscope.com/docs/api/buckets#bucket-list +def get_bucket_list(): + return _api_get_request( '/buckets', 200 ) + +# Retrieves test list for a given bucket key +# https://www.runscope.com/docs/api/tests#list +def get_bucket_test_list( bucket_key ): + return _api_get_request( '/buckets/%s/tests' % bucket_key, 200 ) + +# Retrieves test details for a given test id in a bucket +# https://www.runscope.com/docs/api/tests#detail +def get_test_details( bucket_key,test_id ): + return _api_get_request( '/buckets/%s/tests/%s' % (bucket_key,test_id), 200 ) + +# Retrieves test results for a given test id in a bucket +#https://www.runscope.com/docs/api/results#test-run-detail +def get_test_run_details( bucket_key,test_id ): + return _api_get_request( '/buckets/%s/tests/%s/results/latest' % (bucket_key,test_id), 200 ) + +# Execute HTTP request +def _api_get_request( path, status ): + r = requests.get('%s/%s' % (g['base_url'],path), headers=g['headers']) + if (r.status_code != status): + _api_error_exit( r.status_code ) + return (json.loads(r.text))['data'] + +# Exits on API error, displaying status code and function +# name where error occurred. +def _api_error_exit( status_code ): + sys.exit('API error - HTTP status code %s in %s' % (status_code,inspect.stack()[1][3])) + + +def main(): + with open('config.json') as config_file: + config = json.load(config_file) + + g['headers'] = {'Authorization':'Bearer %s' % config["runscope"]["access_token"]} + g['base_url'] = 'https://api.runscope.com' + + # Timestamp used for directory name + today = time.strftime('%Y-%m-%dT%H:%M') + + # Set current directory as working directory where + # the backups will be saved + workdir = os.getcwd() +# test bucket id 80e4gnwm9xxi + # Fetch list of buckets for authed account + bucket_list = get_bucket_list() + + # Loop through bucket list + for bucket in bucket_list: + b = {} + b['name'] = bucket['name'] + b['key'] = bucket['key'] + b['path'] = "%s/%s_%s" % ( workdir, today,b['key'] ) + if (b['key'] == '80e4gnwm9xxi'): + # 'tfjt311xbrq9' + # Fetch list of tests in this bucket + bucket_test_list = get_bucket_test_list( b['key'] ) + + # If bucket has tests, create directory + if (len(bucket_test_list) > 0): + #os.mkdir(b['path']) + + # Loop through tests in bucket + for test in bucket_test_list: + test_id = test["id"] + test_name = test["name"] + + # Fetch details for this test and write to file + test_steps = get_test_details( b['key'], test_id ) + test_results = get_test_run_details(b['key'],test_id) + + steps = test_steps['steps'] + for testStep in steps: + #step = testStep["method"] + print testStep['method']," ", testStep['url'] + for key,value in testStep['headers'].iteritems(): + print key,":",str(str(value[0]).strip('[]')) + if (testStep['body'] == ""): + #if testStep['raw_body']: + print "" + else: + print testStep['body'] + + +if __name__ == "__main__": main() From 127eda630bd84b8ea4cb8f14ab8e3a6b1142deac Mon Sep 17 00:00:00 2001 From: nukalasr Date: Tue, 1 Sep 2015 16:16:21 -0700 Subject: [PATCH 2/7] Update GenerateCurlScript.py updated to generate one curl script per test case with test steps in it. --- examples/backup-tests/GenerateCurlScript.py | 101 ++++++++++++++++---- 1 file changed, 80 insertions(+), 21 deletions(-) diff --git a/examples/backup-tests/GenerateCurlScript.py b/examples/backup-tests/GenerateCurlScript.py index 0ca62b1..4c918c8 100644 --- a/examples/backup-tests/GenerateCurlScript.py +++ b/examples/backup-tests/GenerateCurlScript.py @@ -4,6 +4,7 @@ import os import sys import inspect +import re # Global dictionary g = {} @@ -16,30 +17,57 @@ def get_bucket_list(): # Retrieves test list for a given bucket key # https://www.runscope.com/docs/api/tests#list def get_bucket_test_list( bucket_key ): - return _api_get_request( '/buckets/%s/tests' % bucket_key, 200 ) + return _api_get_request( '/buckets/%s/tests?count=70' % bucket_key, 200 ) # Retrieves test details for a given test id in a bucket # https://www.runscope.com/docs/api/tests#detail def get_test_details( bucket_key,test_id ): - return _api_get_request( '/buckets/%s/tests/%s' % (bucket_key,test_id), 200 ) + Testdata=_api_get_request( '/buckets/%s/tests/%s' % (bucket_key,test_id), 200 ) + return Testdata + +# Retrieves test step details for a given test id in a bucket, test stepid +# https://www.runscope.com/docs/api/tests#detail +def get_test_step_details( bucket_key,test_id, step_id ): + testData=_api_get_request( '/buckets/%s/tests/%s/steps/%s' % (bucket_key,test_id,step_id), 200 ) + return testData + +# Retrieves shared test environment details for a given bucket +def get_shared_test_env( bucket_key ): + return _api_get_request( '/buckets/%s/environments' % (bucket_key), 200 ) # Retrieves test results for a given test id in a bucket #https://www.runscope.com/docs/api/results#test-run-detail def get_test_run_details( bucket_key,test_id ): return _api_get_request( '/buckets/%s/tests/%s/results/latest' % (bucket_key,test_id), 200 ) +# clean up file name using test case name +def cleanFileName( file_name): + #replace all non word chars + file_name = re.sub(r"[^\w\s]",'',file_name) + # replae spaces with one '_' + file_name = re.sub(r"\s+",'_',file_name) + return file_name + # Execute HTTP request def _api_get_request( path, status ): r = requests.get('%s/%s' % (g['base_url'],path), headers=g['headers']) if (r.status_code != status): - _api_error_exit( r.status_code ) + _api_error_exit(path, r.status_code ) return (json.loads(r.text))['data'] # Exits on API error, displaying status code and function # name where error occurred. -def _api_error_exit( status_code ): - sys.exit('API error - HTTP status code %s in %s' % (status_code,inspect.stack()[1][3])) +def _api_error_exit( path, status_code ): + sys.exit('API path %s - API error - HTTP status code %s in %s' % (path, status_code,inspect.stack()[1][3])) + +# print text after replacing variables defined in config.json and cleaning up +def replaceVariables(varlist,text): + for key, value in varlist.iteritems(): + varname = "{{" + key + "}}" + text = re.sub(varname, value,text) + text = re.sub("\\r\\n",'',text) + return text def main(): with open('config.json') as config_file: @@ -54,7 +82,6 @@ def main(): # Set current directory as working directory where # the backups will be saved workdir = os.getcwd() -# test bucket id 80e4gnwm9xxi # Fetch list of buckets for authed account bucket_list = get_bucket_list() @@ -64,35 +91,67 @@ def main(): b['name'] = bucket['name'] b['key'] = bucket['key'] b['path'] = "%s/%s_%s" % ( workdir, today,b['key'] ) - if (b['key'] == '80e4gnwm9xxi'): - # 'tfjt311xbrq9' + # Below confition is to test with smaller bucket of test cases + if (b['key'] != ' '): # Fetch list of tests in this bucket + print "----" + bucket['name'] + "----" bucket_test_list = get_bucket_test_list( b['key'] ) - # If bucket has tests, create directory + #future change - retrieve environment variables and insert them where they are used in testcases + #shared_test_env = get_shared_test_env(b['key']) + #print shared_test_env[0]['initial_variables'] + + # If bucket has tests if (len(bucket_test_list) > 0): - #os.mkdir(b['path']) # Loop through tests in bucket for test in bucket_test_list: test_id = test["id"] test_name = test["name"] - + print test_name + print "___________________" + print # Fetch details for this test and write to file test_steps = get_test_details( b['key'], test_id ) - test_results = get_test_run_details(b['key'],test_id) + + # no need to get test run details for this script + #test_results = get_test_run_details(b['key'],test_id) steps = test_steps['steps'] + test_file = open('%s.txt' % (cleanFileName(test_name)),'w') + test_file.truncate() for testStep in steps: - #step = testStep["method"] - print testStep['method']," ", testStep['url'] - for key,value in testStep['headers'].iteritems(): - print key,":",str(str(value[0]).strip('[]')) - if (testStep['body'] == ""): - #if testStep['raw_body']: - print "" - else: - print testStep['body'] + # don't need to retrieve test step details as test details has all needed info + #stepDetail = get_test_step_details(b['key'],test_id,testStep['id']) + + textBuffer ="\n\n" + if 'note' in testStep: + if testStep['note'] is not None: + textBuffer += "# " + testStep['note'] + "\n" + + #if your test site uses 3rd party cert you don't need --insecure flag + textBuffer += "curl --insecure -X" + if 'method' in testStep: + textBuffer += testStep['method']+" " + + if 'headers' in testStep: + for key,value in testStep['headers'].iteritems(): + textBuffer += " -H" + "'"+key+":"+ replaceVariables(config["runscope"], value[0]) + "' " + + formdata ="" + if 'form' in testStep: + for key1,value1 in testStep['form'].iteritems(): + formdata += key1+"="+value1[0] + '&' + if 'body' in testStep: + textBuffer += " -d " + "'" + testStep['body'] + #replaceVariables(config["runscope"],testStep['body']) + textBuffer += replaceVariables( config["runscope"], formdata) + "'" + if 'url' in testStep: + textBuffer += " " + replaceVariables(config["runscope"],testStep['url'] ) + "\n" + test_file.write(textBuffer) + test_file.close() + + if __name__ == "__main__": main() From f004f22a7259883bf714ecb9fecc02a6e211c11e Mon Sep 17 00:00:00 2001 From: nukalasr Date: Tue, 1 Sep 2015 16:21:08 -0700 Subject: [PATCH 3/7] Update README.md added curl generation script --- examples/backup-tests/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/backup-tests/README.md b/examples/backup-tests/README.md index 0658dcb..b0498da 100644 --- a/examples/backup-tests/README.md +++ b/examples/backup-tests/README.md @@ -1,10 +1,14 @@ -Runscope Test Backup +Runscope Test Backup - as is backup and generate curl script ============ Sample app that uses the Runscope API to back up your Runscope tests. The app will create new folders for each bucket and dump the contents of every test into a JSON file. +GenerateCurlScript - + +This script generates testcases in text files one for each test case. The file name is test case name with 1 curl command per test step + Requirements ------------ - Python @@ -24,6 +28,7 @@ To create an access token, login to your Runscope account and navigate to [https Running the App ------------ $ python backup.py +$ python ChangeLog ------------ From c30601e8590ff5bd422a41303a804f4c1b7ec760 Mon Sep 17 00:00:00 2001 From: nukalasr Date: Tue, 1 Sep 2015 16:22:01 -0700 Subject: [PATCH 4/7] Update README.md minor change to readme --- examples/backup-tests/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/backup-tests/README.md b/examples/backup-tests/README.md index b0498da..c719ce1 100644 --- a/examples/backup-tests/README.md +++ b/examples/backup-tests/README.md @@ -28,7 +28,7 @@ To create an access token, login to your Runscope account and navigate to [https Running the App ------------ $ python backup.py -$ python +$ python GenerateCurlScript.py ChangeLog ------------ From 1300c88b770f0e56afc2713595e2cca367ac294e Mon Sep 17 00:00:00 2001 From: nukalasr Date: Mon, 7 Sep 2015 20:34:46 -0700 Subject: [PATCH 5/7] Create GeneratePostmanScript.py This Script generates Postman json file. This json file can be imported into postman tool --- .../backup-tests/GeneratePostmanScript.py | 323 ++++++++++++++++++ 1 file changed, 323 insertions(+) create mode 100644 examples/backup-tests/GeneratePostmanScript.py diff --git a/examples/backup-tests/GeneratePostmanScript.py b/examples/backup-tests/GeneratePostmanScript.py new file mode 100644 index 0000000..0ce190d --- /dev/null +++ b/examples/backup-tests/GeneratePostmanScript.py @@ -0,0 +1,323 @@ +import requests # make sure this is installed +#from jsonschema import validate +#from jsonschema.exceptions import ValidationError + +from uuid import UUID +import uuid +import json +import time +import requests +import os +import sys +import inspect +import re + + +# Global dictionary +g = {} + +class PostmanCollection: + def __init__(self, colname): + self.name = colname + self.requests = [] + self.folders = [] + self.id = str(uuid.uuid4()) + self.name = "" + self.timestamp = 0 + self.owner = 0 + self.hasRequests = True + self.order = [] + + def addRequest(self, req): + self.requests.append(req) + req.collectionId = str(self.id) + #self.order.append(req.id) + return id + + def addFolder(self, folder): + self.folders.append(folder) + return id + + +class PostmanFolder: + def __init__(self, name): + self.name = name + self.id = str(uuid.uuid4()) + self.description = "" + self.collection_name = "" + self.collection_id = 0 + self.orderlist = [] + + def addRequestOrder(self, reqId): + self.orderlist.append(reqId) + return self.id + +class PostmanRequest: + def __init__(self, name): + self.name = name + self.id = str(uuid.uuid4()) + self.headers = "" + self.url = "" + self.pathvariables = {} + self.preRequestScript = "" + self.method = "POST" + self.data = [{}] + self.rawModeData="" + + self.datamode = "params" + self.descriptionFormat = "html" + self.description="" + self.time = 1440620734887 + self.version = 2 + + self.responses = [] + self.tests = "" + self.collectionId = "3838b6df-9d49-bdad-f99b-d6c83e9b83b1" + self.name = "" + self.folder = "" + +class PostmanCollectionEncoder(json.JSONEncoder): + def default(self, obj): + + if isinstance(obj, UUID): + return str(obj) + elif isinstance(obj, PostmanCollection): + collections = { } + collections.update({"id":str(obj.id)}) + collections.update({"name":obj.name}) + collections.update({"order":obj.order}) + foldersCol = [] + + requestsCol=[] + aFolder = PostmanFolder("test") + for aFolder in obj.folders: + folderCol={} + folderCol.update({"id": aFolder.id}) + folderCol.update({"name": aFolder.name}) + folderCol.update({"order":aFolder.orderlist}) + folderCol.update({"description":aFolder.description}) + folderCol.update({"collection_name":aFolder.collection_name}) + folderCol.update({"collection_id":aFolder.collection_id}) + folderCol.update({"collection":aFolder.collection_id}) + foldersCol.append(folderCol) + collections.update({"folders":foldersCol}) + + for aRequest in obj.requests: + requestCol={} + requestCol.update({"id":aRequest.id}) + requestCol.update({"headers":aRequest.headers}) + requestCol.update({"url":aRequest.url}) + requestCol.update({"pathVariables":{}}) + requestCol.update({"preRequestScript":""}) + requestCol.update({"method":aRequest.method}) + requestCol.update({"data":aRequest.data}) + requestCol.update({"dataMode":aRequest.datamode}) + requestCol.update({"descriptionFormat":"html"}) + requestCol.update({"timestamp":time.time()}) + requestCol.update({"version":2}) + requestCol.update({"responses":[]}) + requestCol.update({"tests":""}) + requestCol.update({"collectionId":aRequest.collectionId}) + requestCol.update({"name":aRequest.name}) + requestCol.update({"description":aRequest.description}) + requestCol.update({"folder":aRequest.folder}) + requestCol.update({"rawModeData":aRequest.rawModeData}) + + requestsCol.append(requestCol) + collections.update({"requests":requestsCol}) + #collectionsString = json.dumps(collections,indent=2) + return collections + else: + collectionString = "{ }" + return collectionString + return json.JSONEncoder.default(self, obj) + +# Add Postman collection +def add_postman_collection(postmanScript, id, name, order, folders, ): + postmanScript += json.dumps("{ ") + + +# Retrieves list of buckets for the authed account +# https://www.runscope.com/docs/api/buckets#bucket-list +def get_bucket_list(): + return _api_get_request('/buckets', 200) + + +# Retrieves test list for a given bucket key +# https://www.runscope.com/docs/api/tests#list +def get_bucket_test_list(bucket_key): + return _api_get_request('/buckets/%s/tests?count=70' % bucket_key, 200) + + +# Retrieves test details for a given test id in a bucket +# https://www.runscope.com/docs/api/tests#detail +def get_test_details(bucket_key, test_id): + Testdata = _api_get_request('/buckets/%s/tests/%s' % (bucket_key, test_id), 200) + return Testdata + + +# Retrieves test step details for a given test id in a bucket, test stepid +# https://www.runscope.com/docs/api/tests#detail +def get_test_step_details(bucket_key, test_id, step_id): + testData = _api_get_request('/buckets/%s/tests/%s/steps/%s' % (bucket_key, test_id, step_id), 200) + return testData + + +# Retrieves shared test environment details for a given bucket +def get_shared_test_env(bucket_key): + return _api_get_request('/buckets/%s/environments' % (bucket_key), 200) + + +# Retrieves test results for a given test id in a bucket +# https://www.runscope.com/docs/api/results#test-run-detail +def get_test_run_details(bucket_key, test_id): + return _api_get_request('/buckets/%s/tests/%s/results/latest' % (bucket_key, test_id), 200) + + +# clean up file name using test case name +def cleanFileName(file_name): + # replace all non word chars + file_name = re.sub(r"[^\w\s]", '', file_name) + # replae spaces with one '_' + file_name = re.sub(r"\s+", '_', file_name) + return file_name + + +# Execute HTTP request +def _api_get_request(path, status): + r = requests.get('%s/%s' % (g['base_url'], path), headers=g['headers']) + if r.status_code != status: + _api_error_exit(path, r.status_code) + return (json.loads(r.text))['data'] + + +# Exits on API error, displaying status code and function +# name where error occurred. +def _api_error_exit(path, status_code): + sys.exit('API path %s - API error - HTTP status code %s in %s' % (path, status_code, inspect.stack()[1][3])) + + +# print text after replacing variables defined in config.json and cleaning up +def replaceVariables(varlist, text): + for key, value in varlist.iteritems(): + varname = "{{" + key + "}}" + text = re.sub(varname, value, text) + text = re.sub("\\r\\n", '', text) + return text + + +def main(): + with open('config.json') as config_file: + config = json.load(config_file) + + g['headers'] = {'Authorization': 'Bearer %s' % config["runscope"]["access_token"]} + g['base_url'] = 'https://api.runscope.com' + + # Timestamp used for directory name + today = time.strftime('%Y-%m-%dT%H:%M') + + # Set current directory as working directory where + # the backups will be saved + workdir = os.getcwd() + # Fetch list of buckets for authed account + bucket_list = get_bucket_list() + + # Loop through bucket list + for bucket in bucket_list: + b = dict() + b['name'] = bucket['name'] + b['key'] = bucket['key'] + b['path'] = "%s/%s_%s" % (workdir, today, b['key']) + # Below condition is to test with smaller bucket of test cases + if b['key'] != ' ': + # Fetch list of tests in this bucket + print "----" + bucket['name'] + "----" + bucket_test_list = get_bucket_test_list(b['key']) + + # future change - retrieve environment variables and insert them where they are used in testcases + # shared_test_env = get_shared_test_env(b['key']) + # print shared_test_env[0]['initial_variables'] + # If bucket has tests + if len(bucket_test_list) > 0: + test_file = open('%s.json' % (cleanFileName(b['name'])), 'w') + test_file.truncate() + collection = PostmanCollection(b['name']) + collection.name = b['name'] + # Loop through tests in bucket + for test in bucket_test_list: + test_id = test["id"] + test_name = test["name"] + print test_name + print "___________________" + print + folder = PostmanFolder(test_name) + folder.description = test['description'] + + # Fetch details for this test and write to file + test_steps = get_test_details(b['key'], test_id) + + # no need to get test run details for this script + # test_results = get_test_run_details(b['key'],test_id) + + steps = test_steps['steps'] + # test_file = open('%s.txt' % (cleanFileName(test_name)),'w') + # test_fle.truncate() + + for testStep in steps: + # don't need to retrieve test step details as test details has all needed info + # stepDetail = get_test_step_details(b['key'],test_id,testStep['id']) + + Request = PostmanRequest("test") + if 'description' in testStep: + Request.description = testStep[''] + if 'descriptionFormat' in testStep: + Request.descriptionFormat = testStep['descriptionFormat'] + + textBuffer = "\n\n" + if 'note' in testStep: + if testStep['note'] is not None: + textBuffer += "# " + testStep['note'] + "\n" + Request.name = testStep['note'] + + if 'method' in testStep: + Request.method = testStep['method'] + + if 'headers' in testStep: + textBuffer += "" + for key, value in testStep['headers'].iteritems(): + textBuffer += key + ":" + replaceVariables(config["runscope"], value[0]) + "\n" + Request.headers = textBuffer + + formdata = "" + if 'form' in testStep: + dataForm = [] + for key1, value1 in testStep['form'].iteritems(): + dataForm.append({"key": key1, + "value": value1, + "type": "text", + "enabled": True}) + Request.data = dataForm + + if 'body' in testStep: + formdata = testStep['body'] + # replaceVariables(config["runscope"],testStep['body']) + textBuffer = replaceVariables(config["runscope"], formdata) + Request.datamode = "raw" + if textBuffer != '': + Request.rawModeData = textBuffer + + textBuffer = "" + if 'url' in testStep: + textBuffer += " " + replaceVariables(config["runscope"], testStep['url']) + "\n" + Request.url = textBuffer + Request.folder = folder.addRequestOrder(Request.id) + collection.addRequest(Request) + # test_file.write(json.dumps(Request)) + folder.collection_id = collection.addFolder(folder) + #collection.addFolder(folder) + json.dump(collection,fp=test_file,cls=PostmanCollectionEncoder,indent=2) + test_file.close() + + +if __name__ == "__main__": main() + From d2bf8af2048e18c3e2e0e707e731e33b5c07b739 Mon Sep 17 00:00:00 2001 From: nukalasr Date: Mon, 7 Sep 2015 20:39:59 -0700 Subject: [PATCH 6/7] Update README.md updated to include generate postman script information --- examples/backup-tests/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/backup-tests/README.md b/examples/backup-tests/README.md index c719ce1..fb5facd 100644 --- a/examples/backup-tests/README.md +++ b/examples/backup-tests/README.md @@ -9,6 +9,10 @@ GenerateCurlScript - This script generates testcases in text files one for each test case. The file name is test case name with 1 curl command per test step +GeneratePostmanScript.py + +This script generates Postman file that can be imorted into postman tool + Requirements ------------ - Python @@ -28,8 +32,11 @@ To create an access token, login to your Runscope account and navigate to [https Running the App ------------ $ python backup.py + $ python GenerateCurlScript.py +$ python GeneratePostmanScript.py + ChangeLog ------------ 2015-08-17 - Initial release. From 4a62471e5d3945c879b96231087012931029b755 Mon Sep 17 00:00:00 2001 From: nukalasr Date: Tue, 25 Oct 2016 15:16:54 -0700 Subject: [PATCH 7/7] Update GeneratePostmanScript.py Using API scope environment variables and put into generated postman script --- examples/backup-tests/GeneratePostmanScript.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/backup-tests/GeneratePostmanScript.py b/examples/backup-tests/GeneratePostmanScript.py index 0ce190d..fad5be2 100644 --- a/examples/backup-tests/GeneratePostmanScript.py +++ b/examples/backup-tests/GeneratePostmanScript.py @@ -229,7 +229,7 @@ def main(): b['key'] = bucket['key'] b['path'] = "%s/%s_%s" % (workdir, today, b['key']) # Below condition is to test with smaller bucket of test cases - if b['key'] != ' ': + if b['key'] == '80e4gnwm9xxi': # Fetch list of tests in this bucket print "----" + bucket['name'] + "----" bucket_test_list = get_bucket_test_list(b['key']) @@ -286,19 +286,21 @@ def main(): textBuffer += "" for key, value in testStep['headers'].iteritems(): textBuffer += key + ":" + replaceVariables(config["runscope"], value[0]) + "\n" + Request.headers = textBuffer formdata = "" if 'form' in testStep: dataForm = [] for key1, value1 in testStep['form'].iteritems(): - dataForm.append({"key": key1, - "value": value1, + dataForm.append({"key": replaceVariables(config["runscope"], key1), + "value": replaceVariables(config["runscope"], str(value1)), "type": "text", "enabled": True}) + Request.datamode = "params" Request.data = dataForm - if 'body' in testStep: + if 'body' in testStep and testStep['body'] != "": formdata = testStep['body'] # replaceVariables(config["runscope"],testStep['body']) textBuffer = replaceVariables(config["runscope"], formdata)