Skip to content

Commit f0b7bd1

Browse files
committed
fix codacy issues by removing trail whitespaces
1 parent ad8f939 commit f0b7bd1

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/arguments/api_test.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class ApiTesting():
55
default_url = "https://127.0.0.1:8000"
66
default_headers = {}
7-
InvalidSchemaMessage = "Check whether the URL is valid or check if " + "the localhost server is active or not"
7+
InvalidSchemaMessage = "Check whether the URL is valid or check if" + "the localhost server is active or not"
88
# fetches the input data for making a request
99
@classmethod
1010
def fetch_input_url(cls):
@@ -43,15 +43,14 @@ def fetch_input_url(cls):
4343
"request_headers" : request_headers,
4444
}
4545

46-
#saves the json response into a file
46+
#saves the json response into a file
4747
@classmethod
48-
def save_response_data(cls,output_json):
48+
def save_response_data(cls,response_data):
4949
store_data = input('Store response data? (Y/N): ')
5050
if(store_data == 'Y' or store_data == 'y'):
5151
with open('response_data.json', 'w') as jsonFile:
5252
json.dump(response_data, jsonFile, indent=4)
5353
print("Response data stored in response_data.json")
54-
5554
# formats the response data and prints it in json on console
5655
@classmethod
5756
def print_response_json(cls,response):
@@ -61,7 +60,7 @@ def print_response_json(cls,response):
6160
output_json = highlight(parsed_json, lexers.JsonLexer(),
6261
formatters.TerminalFormatter())
6362
print(output_json)
64-
return output_json
63+
return output_json, response_data
6564

6665
# Make GET request
6766
@classmethod
@@ -70,23 +69,22 @@ def get_request(cls):
7069
# Make GET request and store the response in response_data.json
7170
try:
7271
response = requests.get(request_data["request_url"], headers= request_data["request_headers"])
73-
output_json = cls.print_response_json(response)
74-
cls.save_response_data(output_json)
72+
output_json, response_data = cls.print_response_json(response)
73+
cls.save_response_data(response_data)
7574

7675
except requests.exceptions.InvalidSchema:
7776
print(cls.InvalidSchemaMessage)
7877
except Exception as e:
7978
print(e)
80-
# Make a delete request
79+
# Make a delete request
8180
@classmethod
8281
def delete_endpoint_request(cls):
83-
8482
# request_data contains dictionary of inputs entered by user
8583
request_data = cls.fetch_input_url()
8684
try:
8785
response = requests.delete(request_data["request_url"], headers= request_data["request_headers"])
88-
output_json = cls.print_response_json(response)
89-
cls.save_response_data(output_json)
86+
output_json, response_data = cls.print_response_json(response)
87+
cls.save_response_data(response_data)
9088

9189
except requests.exceptions.InvalidSchema:
9290
print(cls.InvalidSchemaMessage)
@@ -105,5 +103,4 @@ def __check_protocol(cls, request_url):
105103
if(request_url[:4] == 'http'):
106104
return True
107105
else:
108-
return False
109-
106+
return False

0 commit comments

Comments
 (0)