Skip to content

Commit

Permalink
chg: rename xml-data to xml-external as per comment on XLSForm#107
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsay-stevens committed Jan 2, 2018
1 parent 8950324 commit 6f1d80a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion pyxform/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def create_survey_element_from_dict(self, d):
d = self._sections[section_name]
full_survey = self.create_survey_element_from_dict(d)
return full_survey.children
elif d[u"type"] == u"xml-data":
elif d[u"type"] == u"xml-external":
return ExternalInstance(**d)
else:
return self._create_question_from_dict(
Expand Down
2 changes: 1 addition & 1 deletion pyxform/question_type_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ def generate_new_dict():
"type": "binary"
}
},
"xml-data": {
"xml-external": {
# Only effect is to add an external instance.
}
}
4 changes: 2 additions & 2 deletions pyxform/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,14 @@ def _generate_instances(self):
Instance names used for the id attribute are generated as follows:
- xml-data: item name value (for type==xml-data)
- xml-external: item name value (for type==xml-external)
- pulldata: first arg to calculation->pulldata()
- select from file: file name arg to type->itemset
- choices: list_name (for type==select_*)
Validation and business rules for output of instances:
- xml-data item name must be unique across the XForm and the form is
- xml-external item name must be unique across the XForm and the form is
considered invalid if there is a duplicate name. This differs from
other item types which allow duplicates if not in the same group.
- for all instance sources, if the same instance name is encountered,
Expand Down
88 changes: 44 additions & 44 deletions pyxform/tests_v1/test_xmldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def test_can__output_single_external_xml_item(self):
"""Simplest possible example to include an external instance."""
self.assertPyxformXform(
md="""
| survey | | | |
| | type | name | label |
| | xml-data | mydata | |
| survey | | | |
| | type | name | label |
| | xml-external | mydata | |
""",
model__contains=[
'<instance id="mydata" src="jr://file/mydata.xml">'
Expand All @@ -28,10 +28,10 @@ def test_cannot__use_same_external_xml_id_in_same_section(self):
with self.assertRaises(PyxformTestError) as ctx:
self.assertPyxformXform(
md="""
| survey | | | |
| | type | name | label |
| | xml-data | mydata | |
| | xml-data | mydata | |
| survey | | | |
| | type | name | label |
| | xml-external | mydata | |
| | xml-external | mydata | |
""",
model__contains=[])
# This is caught first by existing validation rule.
Expand All @@ -42,10 +42,10 @@ def test_can__use_unique_external_xml_in_same_section(self):
"""Two unique external instances in the same section is OK."""
self.assertPyxformXform(
md="""
| survey | | | |
| | type | name | label |
| | xml-data | mydata | |
| | xml-data | mydata2 | |
| survey | | | |
| | type | name | label |
| | xml-external | mydata | |
| | xml-external | mydata2 | |
""",
model__contains=[
'<instance id="mydata" src="jr://file/mydata.xml">',
Expand All @@ -59,15 +59,15 @@ def test_cannot__use_same_external_xml_id_across_groups(self):
with self.assertRaises(PyxformTestError) as ctx:
self.assertPyxformXform(
md="""
| survey | | | |
| | type | name | label |
| | xml-data | mydata | |
| | begin group | g1 | |
| | xml-data | mydata | |
| | end group | g1 | |
| | begin group | g2 | |
| | xml-data | mydata | |
| | end group | g2 | |
| survey | | | |
| | type | name | label |
| | xml-external | mydata | |
| | begin group | g1 | |
| | xml-external | mydata | |
| | end group | g1 | |
| | begin group | g2 | |
| | xml-external | mydata | |
| | end group | g2 | |
""",
model__contains=[])
self.assertIn("Instance names must be unique", repr(ctx.exception))
Expand All @@ -78,21 +78,21 @@ def test_can__use_unique_external_xml_across_groups(self):
"""Unique external instances anywhere is OK."""
self.assertPyxformXform(
md="""
| survey | | | |
| | type | name | label |
| | xml-data | mydata | |
| | begin group | g1 | |
| | xml-data | mydata1 | |
| | note | note1 | It's note-able |
| | end group | g1 | |
| | begin group | g2 | |
| | note | note2 | It's note-able |
| | xml-data | mydata2 | |
| | end group | g2 | |
| | begin group | g3 | |
| | note | note3 | It's note-able |
| | xml-data | mydata3 | |
| | end group | g3 | |
| survey | | | |
| | type | name | label |
| | xml-external | mydata | |
| | begin group | g1 | |
| | xml-external | mydata1 | |
| | note | note1 | It's note-able |
| | end group | g1 | |
| | begin group | g2 | |
| | note | note2 | It's note-able |
| | xml-external | mydata2 | |
| | end group | g2 | |
| | begin group | g3 | |
| | note | note3 | It's note-able |
| | xml-external | mydata3 | |
| | end group | g3 | |
""",
model__contains=[
'<instance id="mydata" src="jr://file/mydata.xml">',
Expand All @@ -111,9 +111,9 @@ def test_cannot__use_same_external_xml_id_with_mixed_types(self):
| survey | | | |
| | type | name | label | calculation |
| | begin group | g1 | | |
| | xml-data | city | | |
| | xml-external | city | | |
| | end group | g1 | | |
| | xml-data | city | | |
| | xml-external | city | | |
| | begin group | g2 | | |
| | select_one_from_file cities.csv | city | City | |
| | end group | g2 | | |
Expand All @@ -135,7 +135,7 @@ def test_can__use_all_types_together_with_unique_ids(self):
| survey | | | | |
| | type | name | label | calculation | choice_filter |
| | begin group | g1 | | | |
| | xml-data | city1 | | | |
| | xml-external | city1 | | | |
| | note | note1 | Note | | |
| | end group | g1 | | | |
| | begin group | g2 | | | |
Expand Down Expand Up @@ -209,12 +209,12 @@ def test_cannot__use_different_src_same_id__select_then_internal(self):
)

def test_cannot__use_different_src_same_id__external_then_pulldata(self):
"""Duplicate instance from pulldata after xml-data raises an error."""
"""Duplicate instance from pulldata after xml-external raises an error."""
md = """
| survey | | | | |
| | type | name | label | calculation |
| | begin group | g1 | | |
| | xml-data | fruits | | |
| | xml-external | fruits | | |
| | calculate | f_csv | City | pulldata('fruits', 'name', 'name', 'mango') |
| | note | note | Fruity! ${f_csv} | |
| | end group | g1 | | |
Expand All @@ -231,13 +231,13 @@ def test_cannot__use_different_src_same_id__external_then_pulldata(self):
)

def test_cannot__use_different_src_same_id__pulldata_then_external(self):
"""Duplicate instance from xml-data after pulldata raises an error."""
"""Duplicate instance from xml-external after pulldata raises an error."""
md = """
| survey | | | | |
| | type | name | label | calculation |
| | begin group | g1 | | |
| | calculate | f_csv | City | pulldata('fruits', 'name', 'name', 'mango') |
| | xml-data | fruits | | |
| | xml-external | fruits | | |
| | note | note | Fruity! ${f_csv} | |
| | end group | g1 | | |
"""
Expand Down Expand Up @@ -316,7 +316,7 @@ def test_can__reuse_xml__selects_then_external(self):
| | select_one_from_file pain_locations.xml | pweek | Location of worst pain this week. |
| | select_one_from_file pain_locations.xml | pmonth | Location of worst pain this month. |
| | select_one_from_file pain_locations.xml | pyear | Location of worst pain this year. |
| | xml-data | pain_locations | |
| | xml-external | pain_locations | |
"""
expected = \
"""
Expand All @@ -338,7 +338,7 @@ def test_can__reuse_xml__external_then_selects(self):
md = """
| survey | | | |
| | type | name | label |
| | xml-data | pain_locations | |
| | xml-external | pain_locations | |
| | select_multiple_from_file pain_locations.xml | plocs | Locations of pain this week. |
| | select_one_from_file pain_locations.xml | pweek | Location of worst pain this week. |
| | select_one_from_file pain_locations.xml | pmonth | Location of worst pain this month. |
Expand Down

0 comments on commit 6f1d80a

Please sign in to comment.