Skip to content

Commit

Permalink
Update tests to pretty print json check
Browse files Browse the repository at this point in the history
  • Loading branch information
georgetarazevich committed Nov 23, 2023
1 parent a5de95e commit f85545b
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 30 deletions.
33 changes: 32 additions & 1 deletion CLI/Issues/1289/1289.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,36 @@ setup() {

[ "$status" -eq 1 ]

assert_output --partial '"featuresReport":{"informationDict":{"entry":{"key":"Title","value":"REPORT BY THE INDEPENDENT SCRUTINY PANEL"},"entry":{"key":"Author","value":"Sandra McDougall"},"entry":{"key":"Creator","value":"Acrobat PDFMaker 8.0 for Word"},"entry":{"key":"Producer","value":"Acrobat Distiller 8.0.0 (Windows)"},"entry":{"key":"CreationDate","value":"2008-01-14T10:41:15.000Z"},"entry":{"key":"ModDate","value":"2008-01-14T10:41:30.000Z"},"entry":{"key":"Company","value":" "}}}'
assert_output --partial '"featuresReport":{
"informationDict" : {
"entry" : {
"key" : "Title",
"value" : "REPORT BY THE INDEPENDENT SCRUTINY PANEL"
},
"entry" : {
"key" : "Author",
"value" : "Sandra McDougall"
},
"entry" : {
"key" : "Creator",
"value" : "Acrobat PDFMaker 8.0 for Word"
},
"entry" : {
"key" : "Producer",
"value" : "Acrobat Distiller 8.0.0 (Windows)"
},
"entry" : {
"key" : "CreationDate",
"value" : "2008-01-14T10:41:15.000Z"
},
"entry" : {
"key" : "ModDate",
"value" : "2008-01-14T10:41:30.000Z"
},
"entry" : {
"key" : "Company",
"value" : " "
}
}
}'
}
67 changes: 53 additions & 14 deletions CLI/Issues/1290/1290.bats
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,57 @@ setup() {
run verapdf/verapdf $BATS_TEST_DIRNAME/inputs/. --debug --format json

[ "$status" -eq 0 ]
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Japanese-日本.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Chinese-中國人.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Česká republika.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Русский.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Deutschland.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Arabic-عربي.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Hebrew-עִברִית.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./čeština.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Hindi-हिन्दी.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Română.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Magyarország.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Greek_Ελληνικά.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Japanese-日本.pdf"
assert_output --partial "{\"itemDetails\":{\"name\":\"$BATS_TEST_DIRNAME/inputs/./file-Slovensko.pdf"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Japanese-日本.pdf\",
\"size\" : 909
}"

assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Chinese-中國人.pdf\",
\"size\" : 909
}"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Česká republika.pdf\",
\"size\" : 909
}"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Русский.pdf\",
\"size\" : 909
}"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Deutschland.pdf\",
\"size\" : 909
}"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Arabic-عربي.pdf\",
\"size\" : 909
}"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Hebrew-עִברִית.pdf\",
\"size\" : 909
}"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./čeština.pdf\",
\"size\" : 25683
}"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Hindi-हिन्दी.pdf\",
\"size\" : 909
}"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Română.pdf\",
\"size\" : 909
}"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Magyarország.pdf\",
\"size\" : 909
}"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Greek_Ελληνικά.pdf\",
\"size\" : 909
}"
assert_output --partial "{\"itemDetails\":{
\"name\" : \"$BATS_TEST_DIRNAME/inputs/./file-Slovensko.pdf\",
\"size\" : 909
}"
}
10 changes: 6 additions & 4 deletions CLI/Issues/1308/1308.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ setup() {
run verapdf/verapdf --extract page --format json --off $BATS_TEST_DIRNAME/6.1.3-01-fail-5.pdf

[ "$status" -eq 0 ]
assert_output --partial '"orderNumber":"1"'
assert_output --partial '"width":"300.000"'
assert_output --partial '"height":"400.000"'
assert_output --partial '"rotation":"0"'

assert_output --partial '"orderNumber" : "1",
"width" : "300.000",
"height" : "400.000",'

assert_output --partial '"rotation" : "0"'
}
9 changes: 7 additions & 2 deletions CLI/Issues/1336/1336.bats
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ setup() {

run $BATS_TEST_TMPDIR/verapdf $FILE_PATH/corruptionOneByteMissing.pdf --format json

assert_output --partial '"taskException":'
assert_output --partial "\"executed\":true,\"success\":false,\"exceptionMessage\":\"Exception: Couldn't parse stream caused by exception: Pages not found\""
assert_output --partial "\"taskException\":{
\"exception\" : \"Couldn't parse stream\","

assert_output --partial "\"executed\" : true,
\"success\" : false,
\"exceptionMessage\" : \"Exception: Couldn't parse stream caused by exception: Pages not found\""

[ "$status" -eq 7 ]
}

Expand Down
12 changes: 10 additions & 2 deletions CLI/Options/addlogs/addlogs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,16 @@ logs_mrr_check() {
logs_json_check() {
echo "Running: $1" >&3
run verapdf/verapdf $FILE_PATH/$1 --addlogs --format json
assert_output --partial '{"occurrences":2,"level":"WARNING","message":"Value of ID is not an array of two byte strings"}'
assert_output --partial '{"occurrences":2,"level":"SEVERE","message":"Value of ID key is not a string. Ignoring ID"}'
assert_output --partial '{
"occurrences" : 2,
"level" : "SEVERE",
"message" : "Value of ID key is not a string. Ignoring ID"
}'
assert_output --partial '{
"occurrences" : 2,
"level" : "WARNING",
"message" : "Value of ID is not an array of two byte strings"
}'
[ "$status" -eq 0 ]
}

Expand Down
9 changes: 5 additions & 4 deletions CLI/Options/format/format.bats
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ format_html() {
format_json() {
echo "Running: $1" >&3
run verapdf/verapdf $FILE_PATH/$1 --format json
assert_output --partial '"jobEndStatus":"normal"'
assert_output --partial '"profileName":"PDF/A-2B validation profile"'
assert_output --partial '"statement":"PDF file is compliant with Validation Profile requirements."'
assert_output --partial '"compliant":true'
assert_output --partial '"jobEndStatus" : "normal",
"profileName" : "PDF/A-2B validation profile",
"statement" : "PDF file is compliant with Validation Profile requirements.",
"compliant" : true'

[ "$status" -eq 0 ]
}
4 changes: 2 additions & 2 deletions CLI/Options/processes/processes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ setup() {
processes_check() {
echo "Running: $1" >&3
run verapdf/verapdf $BATS_TEST_DIRNAME/a1.$1 $BATS_TEST_DIRNAME/a2.$1 $BATS_TEST_DIRNAME/a3.$1 $BATS_TEST_DIRNAME/a4.$1 --processes 2 --format json
assert_output --partial '"multiJob":false'
refute_output --partial '"multiJob":true' # expected is not present when using --processes
assert_output --partial '"multiJob" : false'
refute_output --partial '"multiJob" : true' # expected is not present when using --processes
[ "$status" -eq 1 ]
}
2 changes: 1 addition & 1 deletion CLI/Options/stdin/stdin.bats
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ setup() {
@test "— Reading pdf from stdin & --format json option" {

run echo $(cat $FILE_PATH/a.pdf | verapdf/verapdf --format json)
assert_output --partial '"jobs":[{"itemDetails":{"name":"STDIN","size":-1}'
assert_output --partial '"name" : "STDIN",'
}

0 comments on commit f85545b

Please sign in to comment.