def test_retrieving_pending_export(self): self._create_user_and_login() self._publish_transportation_form() export = Export(xform=self.xform, export_type=Export.CSV_EXPORT, options={}, task_id="abcsde") export.save() test_export = check_pending_export(self.xform, Export.CSV_EXPORT, {}) self.assertEqual(export, test_export) test_export = check_pending_export(self.xform, Export.XLS_EXPORT, {}) self.assertIsNone(test_export) export.created_on = export.created_on - timedelta(minutes=6) export.save() test_export = check_pending_export(self.xform, Export.CSV_EXPORT, {}) self.assertIsNone(test_export)
def test_retrieving_pending_export(self): self._create_user_and_login() self._publish_transportation_form() export = Export( xform=self.xform, export_type=Export.CSV_EXPORT, options={}, task_id="abcsde") export.save() test_export = check_pending_export(self.xform, Export.CSV_EXPORT, {}) self.assertEqual(export, test_export) test_export = check_pending_export(self.xform, Export.XLS_EXPORT, {}) self.assertIsNone(test_export) export.created_on = export.created_on - timedelta(minutes=6) export.save() test_export = check_pending_export(self.xform, Export.CSV_EXPORT, {}) self.assertIsNone(test_export)
def _create_export_async(xform, export_type, query=None, force_xlsx=False, options=None): """ Creates async exports :param xform: :param export_type: :param query: :param force_xlsx: :param options: :return: job_uuid generated """ export = check_pending_export(xform, export_type, options) if export: return export.task_id try: export, async_result = viewer_task.create_async_export(xform, export_type, query, force_xlsx, options=options) except ExportConnectionError: raise ServiceUnavailable return async_result.task_id
def _create_export_async(xform, export_type, query=None, force_xlsx=False, options=None): """ Creates async exports :param xform: :param export_type: :param query: :param force_xlsx: :param options: :return: job_uuid generated """ export = check_pending_export(xform, export_type, options) if export: return export.task_id export, async_result \ = viewer_task.create_async_export(xform, export_type, query, force_xlsx, options=options) return async_result.task_id