-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
77 lines (68 loc) · 2.3 KB
/
Copy pathtest.py
File metadata and controls
77 lines (68 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
@author: Pradipta
"""
"""
This is a demo python application to demostrate the usage of RESTClientManagementTool
with different use-case.Currently this tool supports 5 methods. The below use cases will
demostrate the use of all five methods.
"""
#Import the application (RESTClientManagementTool)
import RESTClientManagementTool as RCMT
"""
Send method (For sending any request)
For more details of the method arguments refer to the README file
"""
#GET Request
RCMT.send(domain_name = "sample_environment",
url_params = {"post_id" : "1"},
request_name = "demo_GET",
filename = "GET_RESULT"
)
#POST Request
RCMT.send(domain_name = "sample_environment",
request_name = "demo_POST",
filename = "POST_RESULT"
)
"""
add_api method (used for adding API to the json files in the API directory)
"""
RCMT.add_api(name = "demo_ADD_API",
endpoint = "/posts/{post_id}",
method = "PUT",
header = { "Content-type": "application/json" },
payload = {"id": 1,
"title": 'Vegetables',
"body": 'Carrot,Pumpkin',
"userId": 1},
filename = "Sample.json")
"""
delete_api method (used for deleting API from the json files in the API directory)
"""
#Adding an api for delete demo
delete_api_name = "demo_API_For_delete"
RCMT.add_api(name = delete_api_name,
endpoint = "/comments",
method = "GET",
header = { "Content-type": "application/json" },
query_params = {"postId":"{post_id}"},
filename = "Sample.json")
#Deleting the above API
RCMT.delete_api(delete_api_name)
"""
search_api method (used for searching API in the API directory)
"""
#Getting all the API
print("\n\n\t\tSEARCH RESULT\n")
print("\nAll the avialable APIs\n")
search_result = RCMT.search_api()
print(search_result)
print("\nResult for specific API\n")
#Search specific api
search_result = RCMT.search_api("demo_POST")
print(search_result)
"""
get_payload method (used for fetching the payload for a specific API)
"""
print("\n\n\t\tPAYLOAD SEARCH RESULT\n")
payload = RCMT.get_payload("demo_POST")
print(payload)