def test_csv_nested_repeat_output(self):
path = os.path.join(self.fixture_dir, 'double_repeat.xls')
self._publish_xls_file(path)
path = os.path.join(self.fixture_dir, 'instance.xml')
self._make_submission(
path, forced_submission_time=self._submission_time)
self.maxDiff = None
dd = 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'
]
self.assertEquals(dd.xpaths(repeat_iterations=2), xpaths)
# test csv
export = generate_export(Export.CSV_EXPORT, 'csv', self.user.username,
'double_repeat')
storage = get_storage_class()()
self.assertTrue(storage.exists(export.filepath))
path, ext = os.path.splitext(export.filename)
self.assertEqual(ext, '.csv')
with open(os.path.join(self.fixture_dir, 'export.csv')) as f1:
with storage.open(export.filepath) as f2:
expected_content = f1.read()
actual_content = f2.read()
self.assertEquals(actual_content, expected_content)
评论列表
文章目录