def test_create_document(self, mock): self.get_mock(mock, 'drc_openapi') self.post_mock(mock, 'drc_enkelvoudiginformatieobject_create') signal = SignalFactoryWithImage() CaseSignalFactory(signal=signal) create_document(signal)
def test_create_document_already_exists(self, mock): self.get_mock(mock, 'drc_openapi') self.post_mock(mock, 'drc_enkelvoudiginformatieobject_create') signal = SignalFactoryWithImage() case_signal = CaseSignalFactory(signal=signal) CaseDocumentFactory(case_signal=case_signal) create_document(signal)
def test_create_document_not_created_exception(self, mock): self.get_mock(mock, 'drc_openapi') self.post_error_mock(mock, 'drc_enkelvoudiginformatieobject_create') signal = SignalFactoryWithImage() CaseSignalFactory(signal=signal) with self.assertRaises(DocumentNotCreatedException): create_document(signal)
def test_add_document_to_case_already_connected(self, mock): self.get_mock(mock, 'drc_openapi') self.post_mock(mock, 'drc_enkelvoudiginformatieobject_create') self.post_mock(mock, 'drc_objectinformatieobject_create') signal = SignalFactoryWithImage() CaseSignalFactory(signal=signal) case_document = create_document(signal) case_document.connected_in_external_system = True add_document_to_case(signal, case_document)
def test_add_document_to_case_with_error(self, mock): self.get_mock(mock, 'drc_openapi') self.post_mock(mock, 'drc_enkelvoudiginformatieobject_create') self.post_error_mock(mock, 'drc_objectinformatieobject_create') signal = SignalFactoryWithImage() CaseSignalFactory(signal=signal) case_document = create_document(signal) with self.assertRaises(DocumentConnectionException): add_document_to_case(signal, case_document)
def sync_document(self, signal): """ Push all the images that are connected to the signal to the ZDS components. If the document already exists, set signal sync to completed. """ if signal.image: try: case_document = create_document(signal) try: add_document_to_case(signal, case_document) signal.case.sync_completed = True signal.case.save() except DocumentConnectionException as document_exception: logger.exception(document_exception) self.stderr.write(repr(document_exception)) except DocumentNotCreatedException as document_exception: logger.exception(document_exception) self.stderr.write(repr(document_exception))
def test_create_document_with_error(self, mock): signal = SignalFactory() with self.assertRaises(ObjectDoesNotExist): create_document(signal)