Skip to content

Commit

Permalink
Merge pull request #104 from kimetrica/87-external-instances-validation
Browse files Browse the repository at this point in the history
Fix #87 validation of external instances
  • Loading branch information
ukanga authored Mar 29, 2017
2 parents daee65c + de377ef commit df76208
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pyxform/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _generate_from_file_instances(self):
file_id, file_extension = os.path.splitext(itemset)
yield node(
"instance",
node("root", node("item", node("name"), node("label"))),
node("root", node("item", node("name", "_"), node("label", "_"))),
id=file_id,
src="jr://file-%s/%s" % (file_extension[1:], itemset)
)
Expand Down
27 changes: 15 additions & 12 deletions pyxform/tests_v1/test_support_external_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def test_external_csv_instances(self):
"""<instance id="cities" src="jr://file-csv/cities.csv">
<root>
<item>
<name/>
<label/>
<name>_</name>
<label>_</label>
</item>
</root>
</instance>""", # noqa
Expand All @@ -26,14 +26,15 @@ def test_external_csv_instances(self):
"""<instance id="neighbourhoods" src="jr://file-csv/neighbourhoods.csv">
<root>
<item>
<name/>
<label/>
<name>_</name>
<label>_</label>
</item>
</root>
</instance>""", # noqa
'<select ref="/ecsv/neighbourhoods">',
'<itemset nodeset="instance(\'neighbourhoods\')/root/item">',
],
run_odk_validate=True,
)

def test_external_csv_instances_w_choice_filter(self):
Expand All @@ -50,23 +51,24 @@ def test_external_csv_instances_w_choice_filter(self):
"""<instance id="cities" src="jr://file-csv/cities.csv">
<root>
<item>
<name/>
<label/>
<name>_</name>
<label>_</label>
</item>
</root>
</instance>""", # noqa
'<select1 ref="/ecsv/city">',
"""<instance id="neighbourhoods" src="jr://file-csv/neighbourhoods.csv">
<root>
<item>
<name/>
<label/>
<name>_</name>
<label>_</label>
</item>
</root>
</instance>""", # noqa
'<select ref="/ecsv/neighbourhoods">',
'<itemset nodeset="instance(\'neighbourhoods\')/root/item[city= /ecsv/city ]">', # noqa
],
run_odk_validate=True,
)


Expand All @@ -85,8 +87,8 @@ def test_external_xml_instances(self):
"""<instance id="cities" src="jr://file-xml/cities.xml">
<root>
<item>
<name/>
<label/>
<name>_</name>
<label>_</label>
</item>
</root>
</instance>""", # noqa
Expand All @@ -95,14 +97,15 @@ def test_external_xml_instances(self):
"""<instance id="neighbourhoods" src="jr://file-xml/neighbourhoods.xml">
<root>
<item>
<name/>
<label/>
<name>_</name>
<label>_</label>
</item>
</root>
</instance>""", # noqa
'<select ref="/exml/neighbourhoods">',
'<itemset nodeset="instance(\'neighbourhoods\')/root/item">',
],
run_odk_validate=True,
)


Expand Down

0 comments on commit df76208

Please sign in to comment.