Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
a test using the "pyxform_v1_test_case" format, as in https://github.com/XLSForm/pyxform/pull/28
from pyxform_test_case import PyxformTestCase
class TestSupportExternalInstances(PyxformTestCase):
def test_csv_externals(self):
# no choice filter
self.assertPyxformXform(
name="test_csv_externals",
md="""
#survey
| type | name | label | choice_filter |
| select_one_from_file countries.csv | country | Pick one country | |
""",
model__contains=[
'<instance id="cities" src="jr://file-csv/cities.csv" />',
],
body__contains=[
'''<itemset nodeset="instance('countries')/root/item">''',
'''<value ref="name" />''',
'''<label ref="label" />''',
'''</itemset>'''
],
)
def test_xml_externals(self):
# no choice filter
self.assertPyxformXform(
name="test_csv_externals",
md="""
#survey
| type | name | label | choice_filter |
| select_one_from_file countries.xml | country | Pick one country | |
""",
model__contains=[
'<instance id="cities" src="jr://file/cities.xml" />',
],
body__contains=[
'''<itemset nodeset="instance('countries')/root/item">''',
'''<value ref="name" />''',
'''<label ref="label" />''',
'''</itemset>'''
],
)
def test_csv_externals_with_choice_filter(self):
self.assertPyxformXform(
name="test_csv_externals",
md="""
#survey
| type | name | label | choice_filter |
| select_one_from_file countries.csv | country | Pick one country | country = ${country} |
""",
model__contains=[
'<instance id="cities" src="jr://file-csv/cities.csv" />',
],
body__contains=[
'''<itemset nodeset="instance('cities')/root/item[country= /myform/country ]">''',
],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment