Skip to content

Commit

Permalink
Use file-csv prefix for csv external instances
Browse files Browse the repository at this point in the history
  • Loading branch information
lognaturel committed Feb 26, 2021
1 parent c52b5af commit 7fe124c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pyxform/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ def _generate_external_instances(element):
if isinstance(element, ExternalInstance):
name = element["name"]
extension = element["type"].split("-")[0]
src = "jr://file/{}.{}".format(name, extension)
prefix = "file-csv" if extension == "csv" else "file"
src = "jr://{}/{}.{}".format(prefix, name, extension)
return InstanceInfo(
type="external",
context="[type: {t}, name: {n}]".format(
Expand Down
8 changes: 4 additions & 4 deletions pyxform/tests_v1/test_external_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +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-csv/mydata.csv"/>'],
)

def test_cannot__use_same_external_xml_id_in_same_section(self):
Expand Down Expand Up @@ -78,8 +78,8 @@ def test_can__use_unique_external_csv_in_same_section(self):
| | csv-external | mydata2 | |
""",
model__contains=[
'<instance id="mydata" src="jr://file/mydata.csv"/>',
'<instance id="mydata2" src="jr://file/mydata2.csv"/>',
'<instance id="mydata" src="jr://file-csv/mydata.csv"/>',
'<instance id="mydata2" src="jr://file-csv/mydata2.csv"/>',
],
)

Expand Down Expand Up @@ -194,7 +194,7 @@ def test_can__use_same_external_csv_id_with_mixed_types(self):
| | 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-csv/city.csv"/>']
)

def test_can__use_all_types_together_with_unique_ids(self):
Expand Down

0 comments on commit 7fe124c

Please sign in to comment.