Skip to content

Commit

Permalink
Update tests to use 'data' as the default xml root node
Browse files Browse the repository at this point in the history
As of PyXForm v1.0.0 the name of the file is no longer used as the root
node. More Info: XLSForm/pyxform#375
  • Loading branch information
DavisRayM committed Feb 27, 2020
1 parent d572e96 commit bb3d9a7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions onadata/apps/main/tests/test_csv_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ def test_csv_nested_repeat_output(self):
self.maxDiff = None
data_dictionary = DataDictionary.objects.all()[0]
xpaths = [
u'/double_repeat/bed_net[1]/member[1]/name',
u'/double_repeat/bed_net[1]/member[2]/name',
u'/double_repeat/bed_net[2]/member[1]/name',
u'/double_repeat/bed_net[2]/member[2]/name',
u'/double_repeat/meta/instanceID'
u'/data/bed_net[1]/member[1]/name',
u'/data/bed_net[1]/member[2]/name',
u'/data/bed_net[2]/member[1]/name',
u'/data/bed_net[2]/member[2]/name',
u'/data/meta/instanceID'
]
self.assertEquals(data_dictionary.xpaths(repeat_iterations=2), xpaths)
# test csv
Expand Down
4 changes: 2 additions & 2 deletions onadata/apps/main/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def _download_xform(self):
uuid_nodes = [node for node in model_node.childNodes
if node.nodeType == Node.ELEMENT_NODE and
node.getAttribute("nodeset") ==
"/transportation/formhub/uuid"]
"/data/formhub/uuid"]
self.assertEqual(len(uuid_nodes), 1)
uuid_node = uuid_nodes[0]
uuid_node.setAttribute("calculate", "''")
Expand Down Expand Up @@ -560,7 +560,7 @@ def test_uuid_injection_in_cascading_select(self):
node.nodeType == Node.ELEMENT_NODE and
node.tagName == "bind" and
node.getAttribute("nodeset") ==
"/%s/formhub/uuid" % file_name]
"/data/formhub/uuid"]
self.assertEqual(len(calculate_bind_nodes), 1)
calculate_bind_node = calculate_bind_nodes[0]
self.assertEqual(
Expand Down
2 changes: 1 addition & 1 deletion onadata/apps/viewer/tests/test_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def _get_xls_data(self, filepath):
storage = get_storage_class()()
with storage.open(filepath) as f:
workbook = open_workbook(file_contents=f.read())
transportation_sheet = workbook.sheet_by_name("transportation")
transportation_sheet = workbook.sheet_by_name("data")
self.assertTrue(transportation_sheet.nrows > 1)
headers = transportation_sheet.row_values(0)
column1 = transportation_sheet.row_values(1)
Expand Down
2 changes: 1 addition & 1 deletion onadata/libs/tests/utils/fixtures/single.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" ?><tutorial id="tutorial" instanceID="uuid:uuid:fa7f34af-8e28-4d05-9085-b495f0bd9491" submissionDate="2014-09-04T12:08:04"><age>10</age><end_time>2014-09-04T15:07:17+03:00</end_time><formhub> <uuid>a55d89f9483a45c8a896d45de94499a9</uuid></formhub><gender>male</gender><imei>enketo.org:2gnoXEilHRGn6V5i</imei><location>83.3595 -32.8601 0 1</location><meta> <instanceID>uuid:fa7f34af-8e28-4d05-9085-b495f0bd9491</instanceID></meta><name>Name_1</name><phonenumber>no phonenumber property in enketo</phonenumber><photo>NA</photo><pizza_fan>no</pizza_fan><start_time>2014-09-04T15:06:01+03:00</start_time><test_location>83.3595 -32.8601 0 1</test_location><test_location.altitude>0</test_location.altitude><test_location.latitude>83.3595</test_location.latitude><test_location.longitude>-32.8601</test_location.longitude><test_location.precision>1</test_location.precision><test_location2>21.22474 -10.5601 50000 200</test_location2><test_location2.altitude>50000</test_location2.altitude><test_location2.latitude>21.22474</test_location2.latitude><test_location2.longitude>-10.5601</test_location2.longitude><test_location2.precision>200</test_location2.precision><today>2014-09-04</today></tutorial>
<?xml version="1.0" ?><data id="tutorial" instanceID="uuid:uuid:fa7f34af-8e28-4d05-9085-b495f0bd9491" submissionDate="2014-09-04T12:08:04"><age>10</age><end_time>2014-09-04T15:07:17+03:00</end_time><formhub> <uuid>a55d89f9483a45c8a896d45de94499a9</uuid></formhub><gender>male</gender><imei>enketo.org:2gnoXEilHRGn6V5i</imei><location>83.3595 -32.8601 0 1</location><meta> <instanceID>uuid:fa7f34af-8e28-4d05-9085-b495f0bd9491</instanceID></meta><name>Name_1</name><phonenumber>no phonenumber property in enketo</phonenumber><photo>NA</photo><pizza_fan>no</pizza_fan><start_time>2014-09-04T15:06:01+03:00</start_time><test_location>83.3595 -32.8601 0 1</test_location><test_location.altitude>0</test_location.altitude><test_location.latitude>83.3595</test_location.latitude><test_location.longitude>-32.8601</test_location.longitude><test_location.precision>1</test_location.precision><test_location2>21.22474 -10.5601 50000 200</test_location2><test_location2.altitude>50000</test_location2.altitude><test_location2.latitude>21.22474</test_location2.latitude><test_location2.longitude>-10.5601</test_location2.longitude><test_location2.precision>200</test_location2.precision><today>2014-09-04</today></data>
6 changes: 3 additions & 3 deletions onadata/libs/tests/utils/test_viewer_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_get_enketo_defaults_with_right_xform(self):
kwargs = {xform_variable_name: xform_variable_value}
defaults = generate_enketo_form_defaults(self.xform, **kwargs)

key = "defaults[/transportation/transport/{}]".format(
key = "defaults[/data/transport/{}]".format(
xform_variable_name)
self.assertEqual(defaults, {key: xform_variable_value})

Expand All @@ -87,9 +87,9 @@ def test_get_enketo_defaults_with_multiple_params(self):
defaults = generate_enketo_form_defaults(self.xform, **kwargs)

transportation_types_key = \
"defaults[/transportation/transport/{}]".format(
"defaults[/data/transport/{}]".format(
transportation_types)
frequency_key = "defaults[/transportation/transport/"\
frequency_key = "defaults[/data/transport/"\
"loop_over_transport_types_frequency/"\
"{}/{}]".format(transportation_types_value, frequency)
self.assertIn(transportation_types_key, defaults)
Expand Down

0 comments on commit bb3d9a7

Please sign in to comment.