-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_main.http
111 lines (80 loc) · 2.94 KB
/
test_main.http
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Test your FastAPI endpoints
### Test Get UserId
GET http://127.0.0.1:8000/
Accept: application/json
> {%
client.test("Request executed successfully", function() {
client.assert(response.status === 200, "Response status is not 200");
});
client.test("Response content-type is json", function() {
var type = response.contentType.mimeType;
client.assert(type === "application/json", "Expected 'application/json' but received '" + type + "'");
});
client.test("UserId option exists", function() {
client.assert(response.body.hasOwnProperty("userid"), "Cannot find 'userid' option in response");
});
client.test("Message option exists", function() {
client.assert(response.body.hasOwnProperty("message"), "Cannot find 'message' option in response");
});
client.global.set("userid", response.body.userid);
%}
### Test Fibonacci
POST http://127.0.0.1:8000/calculate/
Accept: application/json
Content-Type: application/json
{
"upto": 10,
"userId": "{{ userid }}"
}
> {%
client.test("Request executed successfully", function() {
client.assert(response.status === 200, "Response status is not 200");
});
client.test("Response content-type is json", function() {
var type = response.contentType.mimeType;
client.assert(type === "application/json", "Expected 'application/json' but received '" + type + "'");
});
client.test("results option exists", function() {
client.assert(response.body.hasOwnProperty("results"), "Cannot find 'results' option in response");
});
%}
### Test Create Transaction
POST http://127.0.0.1:8000/transaction/
accept: application/json
content-type: application/json
{ "user_id": "{{ userid }}",
"amount": 100.00,
"currency": "USD",
"description": "Test transaction",
"type": "debit",
"category": "Test"
}
> {%
client.test("Request executed successfully", function() {
client.assert(response.status === 201, "Response status is not 201, received " + response.status);
});
client.test("Response content-type is json", function() {
var type = response.contentType.mimeType;
client.assert(type === "application/json", "Expected 'application/json' but received '" + type + "'");
});
client.test("id option exists", function() {
client.assert(response.body.hasOwnProperty("id"), "Cannot find 'id' option in response");
});
client.global.set("transactionId", response.body.id);
%}
### Test Get Transaction
GET http://127.0.0.1:8000/transaction/query/id/{{transactionId}}
accept: application/json
content-type: application/json
> {%
client.test("Request executed successfully", function() {
client.assert(response.status === 200, "Response status is not 200");
});
client.test("Response content-type is json", function() {
var type = response.contentType.mimeType;
client.assert(type === "application/json", "Expected 'application/json' but received '" + type + "'");
});
client.test("results option exists", function() {
client.assert(response.body.hasOwnProperty("results"), "Cannot find 'results' option in response");
});
%}