Skip to content

Commit bfde15b

Browse files
committed
chore: improve tests for GET/PUT by inspecting response body
1 parent adaeef1 commit bfde15b

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

tests/crud.robot

+17-6
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,26 @@ POST should create an object
1919
Dictionary Should Contain Item ${response.json()} counter 1
2020

2121
GET should return a value
22-
${response}= Get Request api /v1/categories/count
23-
Status Should Be 200 ${response}
24-
Dictionary Should Contain Item ${response.json()} counter 1
22+
${response}= Get Request api /v1/categories/1
23+
${body}= Set Variable ${response.json()}
24+
Status Should Be 200 ${response}
25+
Should Be Equal ${response.headers['Content-Type']} application/json; charset=utf-8
26+
&{expected}= Create Dictionary id=${1} name=Sport name_ru=${null} slug=sport
27+
Dictionaries Should Be Equal ${body} ${expected}
2528

2629

2730
PUT should update an object
28-
&{payload}= Create Dictionary name=Fauna nameRu=Фауна slug=fauna userId=1
29-
${response}= Put Request api /v1/categories/1 json=${payload}
30-
Status Should Be 204 ${response}
31+
&{payload}= Create Dictionary name=Fauna nameRu=Фауна slug=fauna userId=1
32+
${response}= Put Request api /v1/categories/1 json=${payload}
33+
Status Should Be 204 ${response}
34+
# checks that it was updated
35+
${response}= Get Request api /v1/categories/1
36+
${body}= Set Variable ${response.json()}
37+
Status Should Be 200 ${response}
38+
Should Be Equal ${response.headers['Content-Type']} application/json; charset=utf-8
39+
Dictionary Should Contain Item ${body} name Fauna
40+
Dictionary Should Contain Item ${body} name_ru Фауна
41+
Dictionary Should Contain Item ${body} slug fauna
3142

3243
DELETE should remove an object
3344
${response}= Delete Request api /v1/categories/1

0 commit comments

Comments
 (0)