Skip to content

Commit d0601a6

Browse files
authored
Merge pull request #10 from jfollmann/master
feat: Added jsonplaceholder example
2 parents a3e7622 + d4cf631 commit d0601a6

File tree

11 files changed

+9577
-0
lines changed

11 files changed

+9577
-0
lines changed

jsonplaceholder-api/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export BASE_URL=https://jsonplaceholder.typicode.com

jsonplaceholder-api/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Jsonplaceholder REST API
2+
3+
[jsonplaceholder.typicode.com](https://jsonplaceholder.typicode.com) is a fake online REST API for testing and prototyping.
4+
5+
## Run
6+
7+
Requirements:
8+
- [ScanAPI](https://pypi.org/project/scanapi/)
9+
10+
```shell
11+
$ git clone [email protected]:scanapi/examples.git
12+
$ cd jsonplaceholder-api
13+
$ source .env
14+
$ scanapi run main.yaml
15+
```
16+
17+
The report will be available at `scanapi-report.html`

jsonplaceholder-api/main.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
endpoints:
2+
- name: Jsonplaceholder API Tests
3+
path: ${BASE_URL}
4+
endpoints:
5+
- name: user_actions
6+
path: users
7+
requests: !include resources/users.yaml
8+
endpoints:
9+
- name: user_todos
10+
path: ${userId}/todos
11+
requests: !include resources/todos.yaml
12+
13+
- name: user_album
14+
path: ${userId}/albums
15+
requests: !include resources/albums.yaml
16+
17+
- name: user_posts
18+
path: ${userId}/posts
19+
requests: !include resources/user_posts.yaml
20+
21+
- name: post_actions
22+
path: posts
23+
requests:
24+
!include resources/posts.yaml
25+
endpoints:
26+
- name: comments_by_post
27+
path: ${postId}/comments
28+
requests: !include resources/comments.yaml
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- name: get_all
2+
method: get
3+
vars:
4+
recordId: ${{ response.json()[0]["id"] }}
5+
body:
6+
tests:
7+
- name: status_code_is_200
8+
assert: ${{ response.status_code == 200 }}
9+
10+
- name: response_time_is_under_a_second
11+
assert: ${{ response.elapsed.total_seconds() < 1 }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- name: get_all
2+
method: get
3+
vars:
4+
recordId: ${{ response.json()[0]["id"] }}
5+
body:
6+
tests:
7+
- name: status_code_is_200
8+
assert: ${{ response.status_code == 200 }}
9+
10+
- name: response_time_is_under_a_second
11+
assert: ${{ response.elapsed.total_seconds() < 1 }}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
- name: get_all
2+
method: get
3+
vars:
4+
postId: ${{ response.json()[0]["id"] }}
5+
body:
6+
tests:
7+
- name: status_code_is_200
8+
assert: ${{ response.status_code == 200 }}
9+
10+
- name: response_time_is_under_a_second
11+
assert: ${{ response.elapsed.total_seconds() < 1 }}
12+
13+
- name: get_by_id
14+
path: ${postId}
15+
method: get
16+
body:
17+
tests:
18+
- name: status_code_is_200
19+
assert: ${{ response.status_code == 200 }}
20+
21+
- name: response_time_is_under_a_second
22+
assert: ${{ response.elapsed.total_seconds() < 1 }}
23+
24+
- name: get_with_filter
25+
params:
26+
userId: 1
27+
method: get
28+
body:
29+
tests:
30+
- name: status_code_is_200
31+
assert: ${{ response.status_code == 200 }}
32+
33+
- name: response_time_is_under_a_second
34+
assert: ${{ response.elapsed.total_seconds() < 1 }}
35+
36+
- name: create_new
37+
method: post
38+
vars:
39+
newRecordId: ${{ response.json()["id"] }}
40+
body:
41+
title: Post Title
42+
body: Post Body
43+
userId: 1
44+
tests:
45+
- name: status_code_is_201
46+
assert: ${{ response.status_code == 201 }}
47+
48+
- name: response_time_is_under_a_second
49+
assert: ${{ response.elapsed.total_seconds() < 1 }}
50+
51+
- name: update_with_put
52+
method: put
53+
path: ${newRecordId}
54+
body:
55+
id: ${newRecordId}
56+
title: Post Title - Update with PUT
57+
body: Post Body - Update with PUT
58+
userId: 1
59+
tests:
60+
- name: status_code_is_200
61+
assert: ${{ response.status_code == 200 }}
62+
63+
- name: response_time_is_under_a_second
64+
assert: ${{ response.elapsed.total_seconds() < 1 }}
65+
66+
- name: update_with_path
67+
method: patch
68+
path: ${newRecordId}
69+
body:
70+
title: Post Title - Update with Patch
71+
tests:
72+
- name: status_code_is_200
73+
assert: ${{ response.status_code == 200 }}
74+
75+
- name: response_time_is_under_a_second
76+
assert: ${{ response.elapsed.total_seconds() < 1 }}
77+
78+
- name: delete
79+
method: delete
80+
path: ${newRecordId}
81+
tests:
82+
- name: status_code_is_200
83+
assert: ${{ response.status_code == 200 }}
84+
85+
- name: response_time_is_under_a_second
86+
assert: ${{ response.elapsed.total_seconds() < 1 }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- name: get_all
2+
method: get
3+
vars:
4+
recordId: ${{ response.json()[0]["id"] }}
5+
body:
6+
tests:
7+
- name: status_code_is_200
8+
assert: ${{ response.status_code == 200 }}
9+
10+
- name: response_time_is_under_a_second
11+
assert: ${{ response.elapsed.total_seconds() < 1 }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- name: get_all
2+
method: get
3+
vars:
4+
recordId: ${{ response.json()[0]["id"] }}
5+
body:
6+
tests:
7+
- name: status_code_is_200
8+
assert: ${{ response.status_code == 200 }}
9+
10+
- name: response_time_is_under_a_second
11+
assert: ${{ response.elapsed.total_seconds() < 1 }}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
- name: get_all
2+
method: get
3+
vars:
4+
userId: ${{ response.json()[0]["id"] }}
5+
body:
6+
tests:
7+
- name: status_code_is_200
8+
assert: ${{ response.status_code == 200 }}
9+
10+
- name: response_time_is_under_a_second
11+
assert: ${{ response.elapsed.total_seconds() < 1 }}
12+
13+
- name: get_by_id
14+
path: ${userId}
15+
method: get
16+
body:
17+
tests:
18+
- name: status_code_is_200
19+
assert: ${{ response.status_code == 200 }}
20+
21+
- name: response_time_is_under_a_second
22+
assert: ${{ response.elapsed.total_seconds() < 1 }}
23+
24+
- name: get_with_filter
25+
params:
26+
userId: 1
27+
method: get
28+
body:
29+
tests:
30+
- name: status_code_is_200
31+
assert: ${{ response.status_code == 200 }}
32+
33+
- name: response_time_is_under_a_second
34+
assert: ${{ response.elapsed.total_seconds() < 1 }}
35+
36+
- name: create_new
37+
method: post
38+
vars:
39+
newRecordId: ${{ response.json()["id"] }}
40+
body:
41+
name: User Test
42+
username: user_test
43+
44+
address:
45+
street: Victor Plains
46+
suite: Suite 879
47+
city: Wisokyburgh
48+
zipcode: 90566-7771
49+
geo:
50+
lat: -43.9509
51+
lng: -34.4618
52+
tests:
53+
- name: status_code_is_201
54+
assert: ${{ response.status_code == 201 }}
55+
56+
- name: response_time_is_under_a_second
57+
assert: ${{ response.elapsed.total_seconds() < 1 }}
58+
59+
- name: update_with_put
60+
method: put
61+
path: ${newRecordId}
62+
body:
63+
name: User Test - PUT
64+
username: user_test_put
65+
66+
address:
67+
street: Victor Plains PUT
68+
suite: Suite 879 PUT
69+
city: Wisokyburgh PUT
70+
zipcode: 90566-7771
71+
geo:
72+
lat: -43.9509
73+
lng: -34.4618
74+
tests:
75+
- name: status_code_is_200
76+
assert: ${{ response.status_code == 200 }}
77+
78+
- name: response_time_is_under_a_second
79+
assert: ${{ response.elapsed.total_seconds() < 1 }}
80+
81+
- name: update_with_path
82+
method: patch
83+
path: ${newRecordId}
84+
body:
85+
name: User Test - Patch
86+
tests:
87+
- name: status_code_is_200
88+
assert: ${{ response.status_code == 200 }}
89+
90+
- name: response_time_is_under_a_second
91+
assert: ${{ response.elapsed.total_seconds() < 1 }}
92+
93+
- name: delete
94+
method: delete
95+
path: ${newRecordId}
96+
tests:
97+
- name: status_code_is_200
98+
assert: ${{ response.status_code == 200 }}
99+
100+
- name: response_time_is_under_a_second
101+
assert: ${{ response.elapsed.total_seconds() < 1 }}

0 commit comments

Comments
 (0)