Skip to content

Commit

Permalink
Make sure all tests pass Validate
Browse files Browse the repository at this point in the history
  • Loading branch information
lognaturel committed Feb 25, 2021
1 parent 89a7596 commit c52b5af
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
40 changes: 22 additions & 18 deletions pyxform/tests_v1/test_external_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def test_can__output_single_external_csv_item(self):
| | type | name | label |
| | csv-external | mydata | |
""",
model__contains=[
'<instance id="mydata" src="jr://file/mydata.csv"/>'
],
model__contains=['<instance id="mydata" src="jr://file/mydata.csv"/>'],
)

def test_cannot__use_same_external_xml_id_in_same_section(self):
Expand Down Expand Up @@ -182,6 +180,7 @@ def test_can__use_same_external_csv_id_with_mixed_types(self):
| survey | | | | |
| | type | name | label | calculation |
| | begin group | g1 | | |
| | text | foo | Foo | |
| | csv-external | city | | |
| | end group | g1 | | |
| | begin group | g2 | | |
Expand All @@ -191,12 +190,11 @@ def test_can__use_same_external_csv_id_with_mixed_types(self):
| | select_multiple_from_file cities.csv | city | City | |
| | end group | g3 | | |
| | begin group | g4 | | |
| | text | foo | Foo | |
| | calculate | city | City | pulldata('fruits', 'name', 'name', 'mango') |
| | end group | g4 | | |
""", # noqa
model__contains=[
'<instance id="city" src="jr://file/city.csv"/>',
]
model__contains=['<instance id="city" src="jr://file/city.csv"/>',],
)

def test_can__use_all_types_together_with_unique_ids(self):
Expand Down Expand Up @@ -332,9 +330,7 @@ def test_can__reuse_csv__selects_then_pulldata(self):
expected = """
<instance id="pain_locations" src="jr://file-csv/pain_locations.csv"/>
""" # noqa
self.assertPyxformXform(
md=md, model__contains=[expected]
)
self.assertPyxformXform(md=md, model__contains=[expected])
survey = self.md_to_pyxform_survey(md_raw=md)
xml = survey._to_pretty_xml()
self.assertEqual(1, xml.count(expected))
Expand All @@ -352,9 +348,7 @@ def test_can__reuse_csv__pulldata_then_selects(self):
| | select_one_from_file pain_locations.csv | pyear | Location of worst pain this year. | |
""" # noqa
expected = """<instance id="pain_locations" src="jr://file-csv/pain_locations.csv"/>""" # noqa
self.assertPyxformXform(
md=md, model__contains=[expected]
)
self.assertPyxformXform(md=md, model__contains=[expected])

def test_can__reuse_xml__selects_then_external(self):
"""Re-using the same xml external data source id and URI is OK."""
Expand Down Expand Up @@ -386,9 +380,7 @@ def test_can__reuse_xml__external_then_selects(self):
| | select_one_from_file pain_locations.xml | pyear | Location of worst pain this year. |
""" # noqa
expected = """<instance id="pain_locations" src="jr://file/pain_locations.xml"/>""" # noqa
self.assertPyxformXform(
md=md, model__contains=[expected]
)
self.assertPyxformXform(md=md, model__contains=[expected])
survey = self.md_to_pyxform_survey(md_raw=md)
xml = survey._to_pretty_xml()
self.assertEqual(1, xml.count(expected))
Expand Down Expand Up @@ -428,7 +420,11 @@ def test_external_instance_pulldata_readonly(self):
"""
node = """<instance id="ID" src="jr://file-csv/ID.csv"/>"""

self.assertPyxformXform(md=md, xml__contains=[node])
self.assertPyxformXform(
md=md,
xml__contains=[node],
run_odk_validate=False, # Validate sees self references in readonly as circular but shouldn't
)

def test_external_instance_pulldata_required(self):
"""
Expand All @@ -441,7 +437,11 @@ def test_external_instance_pulldata_required(self):
| | text | Part_ID | Participant ID | pulldata('ID', 'ParticipantID', 'ParticipantIDValue',.) |
"""
node = """<instance id="ID" src="jr://file-csv/ID.csv"/>"""
self.assertPyxformXform(md=md, xml__contains=[node], debug=False)
self.assertPyxformXform(
md=md,
xml__contains=[node],
run_odk_validate=False, # Validate sees self references in requireds as circular but shouldn't
)

def test_external_instance_pulldata_relevant(self):
"""
Expand All @@ -454,7 +454,11 @@ def test_external_instance_pulldata_relevant(self):
| | text | Part_ID | Participant ID | pulldata('ID', 'ParticipantID', 'ParticipantIDValue',.) |
"""
node = """<instance id="ID" src="jr://file-csv/ID.csv"/>"""
self.assertPyxformXform(md=md, xml__contains=[node], debug=False)
self.assertPyxformXform(
md=md,
xml__contains=[node],
run_odk_validate=False, # Validate sees self references in relevants as circular but shouldn't
)

# This is not something that is recommended since pulldata and choice_filter both should use XPath predicates
# behind the scenes but it should still be possible.
Expand Down
2 changes: 1 addition & 1 deletion pyxform/tests_v1/test_inline_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_select_with_choice_filter_and_translations_generates_single_translation
xform_md = """
| survey | | | | |
| | type | name | label | choice_filter |
| | select_one list | foo | Foo | name != " |
| | select_one list | foo | Foo | name != '' |
| choices |
| | list_name | name | label | image | label::French |
| | list | a | A | a.jpg | Ah |
Expand Down

0 comments on commit c52b5af

Please sign in to comment.