Skip to content

Commit 2b12aca

Browse files
committed
1. update readme
2. update keyword naming convention
1 parent e02ca0b commit 2b12aca

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,24 @@ pip install -U robotframework-jsonlibrary
3333

3434
# Example Test Case
3535

36-
*** Settings *** | | | | |
36+
|__\*** Settings \***__ | | | | |
3737
----------------- |-------------------- |----------------- |----------- |----------------- |
38-
Library | JSONLibrary | | | |
39-
*** Test Cases ***| | | | |
40-
${json_obj}= | Load JSON From File | example.json | | |
41-
${object_to_add}= | Create Dictionary | country=Thailand | | |
42-
${json_obj}= | Add Object To Json | ${json_obj} | $..address | ${object_to_add} |
43-
${value}= | Get Value From Json | ${json_obj} | $..country | |
38+
|Library | JSONLibrary | | | |
39+
|__\*** Test Cases \***__| | | | |
40+
|${json_obj}= | Load Json From File | example.json | | |
41+
|${object_to_add}= | Create Dictionary | country=Thailand | | |
42+
|${json_obj}= | Add Object To Json | ${json_obj} | $..address | ${object_to_add} |
43+
|${value}= | Get Value From Json | ${json_obj} | $..country | |
4444
|Should Be Equal As Strings | ${value[0]} | Thailand | | |
4545
|${value_to_update}=| Set Variable | Japan | | |
4646
|${json_obj}= | Update Value To Json | ${json_obj} | $..country | ${value_to_update}|
4747
|Should Be Equal As Strings | ${json_obj['country'] | ${value_to_update} | | |
4848
|Should Have Value In Json | ${json_obj} | $..isMarried |
4949
|Should Not Have Value In Json | ${json_obj} | $..hasSiblings |
50-
|Dump JSON To File | ${OUTPUT_DIR}${/}output.json | ${json} |
51-
50+
|Dump Json To File | ${OUTPUT_DIR}${/}output.json | ${json} |
51+
|${schema_json_obj}= | Load Json From File | ${CURDIR}${/}schema.json | | |
52+
|Validate Json By Schema | ${json_obj} | ${schema_json_obj} | | |
53+
|Validate Json By Schema File | ${json_obj} | ${CURDIR}${/}schema.json | | |
5254

5355
# Documentation
5456
For the detail keyword documentation. Go to this following link:

acceptance/JSONLibrary.robot

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Default Tags JSONLibrary
88

99
*** Keywords ***
1010
SetUp Test
11-
${json}= Load JSON From File ${CURDIR}${/}..${/}tests${/}json${/}example.json
11+
${json}= Load Json From File ${CURDIR}${/}..${/}tests${/}json${/}example.json
1212
Set Test Variable ${json_obj_input} ${json}
1313
Set Test Variable ${json_obj_orignal} ${json}
1414

@@ -33,7 +33,7 @@ TestGetValueByJSONPath
3333
Should Be Equal As Integers ${size} 0
3434

3535
TestErrorGetValueByJSONPath
36-
[Documentation] Check Get Value From JSON can fail if no match is found
36+
[Documentation] Check Get Value From Json can fail if no match is found
3737
Run Keyword And Expect Error *failed to find* Get Value From Json ${json_obj_input} $..errorField fail_on_empty=${True}
3838

3939
TestUpdateValueByJSONPath
@@ -79,44 +79,44 @@ TestDeleteArrayElementsByJSONPath
7979
Dictionaries Should Be Equal ${json_obj_orignal} ${json_obj_input}
8080

8181
TestConvertJSONToString
82-
[Documentation] Convert JSON To String
83-
${json_str}= Convert JSON To String ${json_obj_input}
82+
[Documentation] Convert Json To String
83+
${json_str}= Convert Json To String ${json_obj_input}
8484
Should Be String ${json_str}
8585

8686
TestDumpJSONToFile
87-
[Documentation] Dumps JSON to file
88-
Dump JSON to file ${TEMPDIR}/sample_dump.json ${json_obj_input}
87+
[Documentation] Dumps Json to file
88+
Dump Json to file ${TEMPDIR}/sample_dump.json ${json_obj_input}
8989
File Should Exist ${TEMPDIR}/sample_dump.json
9090

9191
TestValidateJsonBySchemaFile
92-
[Documentation] Validate JSON by schema file
92+
[Documentation] Validate Json by schema file
9393
Validate Json By Schema File ${json_obj_input} ${CURDIR}${/}..${/}tests${/}json${/}example_schema.json
9494

9595
TestValidateJsonBySchema
96-
[Documentation] Validate JSON by schema
96+
[Documentation] Validate Json by schema
9797
${schema} Load Json From File ${CURDIR}${/}..${/}tests${/}json${/}example_schema.json
9898
Validate Json By Schema ${json_obj_input} ${schema}
9999

100100
TestValidateJsonBySchemaFileFail
101-
[Documentation] Validate JSON by schema file and fail
101+
[Documentation] Validate Json by schema file and fail
102102
${new_json} Delete Object From Json ${json_obj_input} $..phoneNumbers
103103
Run Keyword And Expect Error Json does not match the schema: *
104104
... Validate Json By Schema File ${new_json} ${CURDIR}${/}..${/}tests${/}json${/}example_schema.json
105105

106106
TestValidateJsonBySchemaFail
107-
[Documentation] Validate JSON by schema and fail
107+
[Documentation] Validate Json by schema and fail
108108
${schema} Load Json From File ${CURDIR}${/}..${/}tests${/}json${/}example_schema.json
109109
${new_json} Delete Object From Json ${json_obj_input} $..phoneNumbers
110110
Run Keyword And Expect Error Json does not match the schema: *
111111
... Validate Json By Schema ${new_json} ${schema}
112112

113113
TestValidateJsonByInvalidSchemaFile
114-
[Documentation] Validate JSON by invalid schema file
114+
[Documentation] Validate Json by invalid schema file
115115
Run Keyword And Expect Error Json schema error: *
116116
... Validate Json By Schema File ${json_obj_input} ${CURDIR}${/}..${/}tests${/}json${/}broken_schema.json
117117

118118
TestValidateJsonByInvalidSchema
119-
[Documentation] Validate JSON by invalid schema
119+
[Documentation] Validate Json by invalid schema
120120
${schema} Load Json From File ${CURDIR}${/}..${/}tests${/}json${/}broken_schema.json
121121
Run Keyword And Expect Error Json schema error: *
122122
... Validate Json By Schema ${json_obj_input} ${schema}

0 commit comments

Comments
 (0)