-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
24 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
docker build --quiet --tag pyxform-http . >/dev/null | ||
docker run --detach --publish 5001:80 --name pyxform-http pyxform-http >/dev/null | ||
docker run --detach --publish 5001:80 --name pyxform-http-tester pyxform-http >/dev/null | ||
|
||
# wait for docker container to come up | ||
sleep 1 | ||
|
||
test_failed=true | ||
test_failed="false" | ||
|
||
test_1_actual=$(curl --silent --request POST --header "X-XlsForm-FormId-Fallback: pyxform-clean" --header 'Transfer-Encoding: chunked' --data-binary @test/pyxform-clean.xlsx http://127.0.0.1:5001/api/v1/convert) | ||
test_1_expected='{"error":null,"itemsets":null,"result":"<?xml version=\"1.0\"?><h:html xmlns=\"http://www.w3.org/2002/xforms\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:h=\"http://www.w3.org/1999/xhtml\" xmlns:jr=\"http://openrosa.org/javarosa\" xmlns:odk=\"http://www.opendatakit.org/xforms\" xmlns:orx=\"http://openrosa.org/xforms\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><h:head><h:title>pyxform-clean</h:title><model odk:xforms-version=\"1.0.0\"><instance><data id=\"pyxform-clean\"><name/><age/><meta><instanceID/></meta></data></instance><bind nodeset=\"/data/name\" type=\"string\"/><bind nodeset=\"/data/age\" type=\"int\"/><bind jr:preload=\"uid\" nodeset=\"/data/meta/instanceID\" readonly=\"true()\" type=\"string\"/></model></h:head><h:body><input ref=\"/data/name\"><label>what is your name</label></input><input ref=\"/data/age\"><label>what is your age</label></input></h:body></h:html>","status":200,"warnings":[]}' | ||
|
@@ -38,27 +42,30 @@ if [ "$test_5_actual" != "$test_5_expected" ]; then | |
echo "test 5 failed: form that converts (with external choices)" | ||
fi | ||
|
||
# test removes uuid from actual and expected | ||
test_6_actual=$(curl --silent --request POST --data-binary @test/pyxform-clean.xlsx http://127.0.0.1:5001/api/v1/convert | sed 's/[0-9a-f-]\{36\}//g') | ||
test_6_expected=$(echo '{"error":null,"itemsets":null,"result":"<?xml version=\"1.0\"?><h:html xmlns=\"http://www.w3.org/2002/xforms\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:h=\"http://www.w3.org/1999/xhtml\" xmlns:jr=\"http://openrosa.org/javarosa\" xmlns:odk=\"http://www.opendatakit.org/xforms\" xmlns:orx=\"http://openrosa.org/xforms\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><h:head><h:title>pyxform-clean</h:title><model odk:xforms-version=\"1.0.0\"><instance><data id=\"a126d83c-ac40-4fd1-b3b0-9f32affacd14\"><name/><age/><meta><instanceID/></meta></data></instance><bind nodeset=\"/data/name\" type=\"string\"/><bind nodeset=\"/data/age\" type=\"int\"/><bind jr:preload=\"uid\" nodeset=\"/data/meta/instanceID\" readonly=\"true()\" type=\"string\"/></model></h:head><h:body><input ref=\"/data/name\"><label>what is your name</label></input><input ref=\"/data/age\"><label>what is your age</label></input></h:body></h:html>","status":200,"warnings":[]}' | sed 's/[0-9a-f-]\{36\}//g') | ||
if [ "$test_6_actual" != "$test_6_expected" ]; then | ||
echo "test 6 failed: form that converts (with no id)" | ||
fi | ||
|
||
# test removes uuid from actual and expected | ||
test_7_actual=$(curl --silent --request POST --header "X-XlsForm-FormId-Fallback: example%40example.org" --data-binary @test/pyxform-clean.xlsx http://127.0.0.1:5001/api/v1/convert | sed 's/[0-9a-f-]\{36\}//g') | ||
test_7_expected=$(echo '{"error":null,"itemsets":null,"result":"<?xml version=\"1.0\"?><h:html xmlns=\"http://www.w3.org/2002/xforms\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:h=\"http://www.w3.org/1999/xhtml\" xmlns:jr=\"http://openrosa.org/javarosa\" xmlns:odk=\"http://www.opendatakit.org/xforms\" xmlns:orx=\"http://openrosa.org/xforms\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><h:head><h:title>pyxform-clean</h:title><model odk:xforms-version=\"1.0.0\"><instance><data id=\"[email protected]\"><name/><age/><meta><instanceID/></meta></data></instance><bind nodeset=\"/data/name\" type=\"string\"/><bind nodeset=\"/data/age\" type=\"int\"/><bind jr:preload=\"uid\" nodeset=\"/data/meta/instanceID\" readonly=\"true()\" type=\"string\"/></model></h:head><h:body><input ref=\"/data/name\"><label>what is your name</label></input><input ref=\"/data/age\"><label>what is your age</label></input></h:body></h:htmldd>","status":200,"warnings":[]}' | sed 's/[0-9a-f-]\{36\}//g') | ||
test_7_expected=$(echo '{"error":null,"itemsets":null,"result":"<?xml version=\"1.0\"?><h:html xmlns=\"http://www.w3.org/2002/xforms\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:h=\"http://www.w3.org/1999/xhtml\" xmlns:jr=\"http://openrosa.org/javarosa\" xmlns:odk=\"http://www.opendatakit.org/xforms\" xmlns:orx=\"http://openrosa.org/xforms\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><h:head><h:title>pyxform-clean</h:title><model odk:xforms-version=\"1.0.0\"><instance><data id=\"[email protected]\"><name/><age/><meta><instanceID/></meta></data></instance><bind nodeset=\"/data/name\" type=\"string\"/><bind nodeset=\"/data/age\" type=\"int\"/><bind jr:preload=\"uid\" nodeset=\"/data/meta/instanceID\" readonly=\"true()\" type=\"string\"/></model></h:head><h:body><input ref=\"/data/name\"><label>what is your name</label></input><input ref=\"/data/age\"><label>what is your age</label></input></h:body></h:html>","status":200,"warnings":[]}' | sed 's/[0-9a-f-]\{36\}//g') | ||
if [ "$test_7_actual" != "$test_7_expected" ]; then | ||
echo "test 7 failed: form that converts (with percent encoded id)" | ||
fi | ||
|
||
# test removes uuid from actual and expected | ||
test_8_actual=$(curl --silent --request POST --data-binary @test/pyxform-clean.xls http://127.0.0.1:5001/api/v1/convert | sed 's/[0-9a-f-]\{36\}//g') | ||
test_8_expected=$(echo '{"error":null,"itemsets":null,"result":"<?xml version=\"1.0\"?><h:html xmlns=\"http://www.w3.org/2002/xforms\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:h=\"http://www.w3.org/1999/xhtml\" xmlns:jr=\"http://openrosa.org/javarosa\" xmlns:odk=\"http://www.opendatakit.org/xforms\" xmlns:orx=\"http://openrosa.org/xforms\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><h:head><h:title>pyxform-clean</h:title><model odk:xforms-version=\"1.0.0\"><instance><data id=\"bbf27b70-9eb7-4659-9933-c22cb9e1451b\"><name/><age/><meta><instanceID/></meta></data></instance><bind nodeset=\"/data/name\" type=\"string\"/><bind nodeset=\"/data/age\" type=\"int\"/><bind jr:preload=\"uid\" nodeset=\"/data/meta/instanceID\" readonly=\"true()\" type=\"string\"/></model></h:head><h:body><input ref=\"/data/name\"><label>what is your name</label></input><input ref=\"/data/age\"><label>what is your age</label></input></h:body></h:html>","status":200,"warnings":[]}' | sed 's/[0-9a-f-]\{36\}//g') | ||
if [ "$test_8_actual" != "$test_8_expected" ]; then | ||
echo "test 8 failed: form that converts (with no id, in XLS format)" | ||
fi | ||
|
||
docker container stop pyxform-http >/dev/null | ||
docker container rm pyxform-http >/dev/null | ||
docker container stop pyxform-http-tester >/dev/null | ||
docker container rm pyxform-http-tester >/dev/null | ||
|
||
if [ "$test_failed" = true ] ; then | ||
if [ "$test_failed" == "true" ] ; then | ||
exit 1 | ||
fi |