-
Notifications
You must be signed in to change notification settings - Fork 3
/
requests-tests.rn
29 lines (22 loc) · 1013 Bytes
/
requests-tests.rn
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
# API testing
const requests = Requests()
const json = Json()
# get request testing
const response_get = requests.get("https://jsonplaceholder.typicode.com/posts")
assert arr_len(json.loads(response_get)) == 100
# post request testing
const response_post = requests.post("https://jsonplaceholder.typicode.com/posts", {"title": "foo", "body": "bar", "userId": 1})
var value = json.loads(response_post)
assert value["id"] == 101
# put request testing
const response_put = requests.put("https://jsonplaceholder.typicode.com/posts/1", {"title": "foo", "body": "bar", "userId": 1})
value = json.loads(response_put)
assert value["id"] == 1
# patch request testing
const response_patch = requests.patch("https://jsonplaceholder.typicode.com/posts/52", {"title": "foo"})
value = json.loads(response_patch)
assert value["id"] == 52
# delete request testing
const response_delete = requests.delete("https://jsonplaceholder.typicode.com/posts/1")
assert json.loads(response_delete) == {}
print("API testing passed!")