From 40e2e404db82fe163c4e6f6e5457fd375cb63b78 Mon Sep 17 00:00:00 2001 From: amit-62 Date: Wed, 6 Jul 2022 22:10:41 +0530 Subject: [PATCH] updated test methods --- fri/test.py | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/fri/test.py b/fri/test.py index aabc5ac..aba9f95 100644 --- a/fri/test.py +++ b/fri/test.py @@ -1,16 +1,44 @@ import requests import os -url = "http://127.0.0.1:5000/multiple-files-upload" +# function to test upload() method. +def upload(): + url = "http://127.0.0.1:5000/upload/test?apikey=xyz" -path = os.path.abspath("example.py") + path = os.path.abspath("example.py") -payload={} -files=[ - ('files[]',('example.py',open( path,'rb'),'application/octet-stream')) -] -headers = {} + payload={} + files=[ + ('files[]',('example.py',open(path,'rb'),'application/octet-stream')) + ] + headers = {} -response = requests.request("POST", url, headers=headers, data=payload, files=files) + response = requests.request("POST", url, headers=headers, data=payload, files=files) + + return response.text + + +# # ******* + +# function to test execute() method. +def execute(): + url = "http://127.0.0.1:5000/execute/test?apikey=xyz" + + path = os.path.abspath("example.py") + + payload={} + files=[ + ('file',('example.py',open(path,'rb'),'application/octet-stream')) + ] + headers = {} + + response = requests.request("POST", url, headers=headers, data=payload, files=files) + + return response.text + + # ******** + # To Download call the url .../download/test?fetch=&apikey=xyz + +upload() +execute() -print(response.text)