From dd036edd37fc3a5550c3a621b7b6d751d6674570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Martin?= Date: Fri, 26 Feb 2021 15:06:46 -0800 Subject: [PATCH] Use file-csv prefix for csv external instances --- pyxform/survey.py | 3 ++- pyxform/tests_v1/test_external_instances.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pyxform/survey.py b/pyxform/survey.py index fe5df228..28b0aa23 100644 --- a/pyxform/survey.py +++ b/pyxform/survey.py @@ -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( diff --git a/pyxform/tests_v1/test_external_instances.py b/pyxform/tests_v1/test_external_instances.py index e036c0a5..b8d527ab 100644 --- a/pyxform/tests_v1/test_external_instances.py +++ b/pyxform/tests_v1/test_external_instances.py @@ -32,7 +32,7 @@ def test_can__output_single_external_csv_item(self): | | type | name | label | | | csv-external | mydata | | """, - model__contains=[''], + model__contains=[''], ) def test_cannot__use_same_external_xml_id_in_same_section(self): @@ -78,8 +78,8 @@ def test_can__use_unique_external_csv_in_same_section(self): | | csv-external | mydata2 | | """, model__contains=[ - '', - '', + '', + '', ], ) @@ -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=['',], + model__contains=[''], ) def test_can__use_all_types_together_with_unique_ids(self):