def testAttachments(self): self.assertEqual(len(CommCareCase.get(self.case_id).case_attachments), 0) scan_path = os.path.join(os.path.dirname(__file__), "data", "vscan", "VH014466XK_000016_20130722T175057") files = self.pack_directory(scan_path) utils.attach_images_to_case(self.case_id, files) self.assertEqual(len(CommCareCase.get(self.case_id).case_attachments), 3)
def async_find_and_attach(upload_id): """ Task backend for Vscan upload """ case = None try: upload_doc = VscanUpload.get(upload_id) files = get_files_from_doc(upload_doc) case = match_case(upload_doc.scanner_serial, upload_doc.scan_id) if case: files = {} for f in upload_doc._attachments.keys(): files[f] = io.BytesIO(upload_doc.fetch_attachment(f)) attach_images_to_case(case._id, files) else: return -1 upload_doc.delete() except: # mark the case as having errored (if we know what it is) # but reraise the error since we don't want to hide it if case: submit_error_case(case._id) raise
def testAttachments(self): self.assertEqual(len(CommCareCase.get(self.case_id).case_attachments), 0) scan_path = os.path.join(os.path.dirname(__file__), 'data', 'vscan', 'VH014466XK_000016_20130722T175057') files = self.pack_directory(scan_path) utils.attach_images_to_case(self.case_id, files) self.assertEqual(len(CommCareCase.get(self.case_id).case_attachments), 3)