Skip to content

Instantly share code, notes, and snippets.

@dorey
Created June 15, 2015 17:59
Show Gist options
  • Save dorey/58b5a2db8879a6579113 to your computer and use it in GitHub Desktop.
Save dorey/58b5a2db8879a6579113 to your computer and use it in GitHub Desktop.
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