def test_add_image_handler_no_case(self): signal = SignalFactoryWithImage.create() add_image.send_robust( sender=self.__class__, signal_obj=signal, )
def test_add_image_handler(self, mocked_tasks): signal = SignalFactoryWithImage.create() CaseSignalFactory(signal=signal) add_image.send_robust( sender=self.__class__, signal_obj=signal, ) mocked_tasks.create_document.assert_called_once_with(signal) mocked_tasks.add_document_to_case.assert_called_once()
def test_create_initial_handler_with_image(self, mocked_tasks): signal = SignalFactoryWithImage.create() create_initial.send_robust( sender=self.__class__, signal_obj=signal, ) mocked_tasks.create_case.assert_called_once_with(signal=signal) mocked_tasks.connect_signal_to_case.assert_called_once_with(signal=signal) mocked_tasks.add_status_to_case.assert_called_once_with(signal=signal, status=signal.status) mocked_tasks.create_document.assert_called_once_with(signal) mocked_tasks.add_document_to_case.assert_called_once()
def test_create_initial_child_signals_copy_attachments( self, validate_address): parent_signal = SignalFactoryWithImage.create() signal_count = Signal.objects.count() parent_signal_count = Signal.objects.filter( parent_id__isnull=True).count() child_signal_count = Signal.objects.filter( parent_id__isnull=False).count() attachment_count = Attachment.objects.count() self.assertEqual(signal_count, 1) self.assertEqual(parent_signal_count, 1) self.assertEqual(child_signal_count, 0) self.assertEqual(attachment_count, 1) attachment = parent_signal.attachments.first() initial_data = [] for _ in range(2): data = copy.deepcopy(self.initial_data_base) data['parent'] = parent_signal.pk data['attachments'] = [ f'/signals/v1/private/signals/{attachment._signal_id}/attachments/{attachment.pk}', ] initial_data.append(data) response = self.client.post(self.list_endpoint, initial_data, format='json') self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(Signal.objects.count(), 3) self.assertEqual( Signal.objects.filter(parent_id__isnull=True).count(), 1) self.assertEqual( Signal.objects.filter(parent_id__isnull=False).count(), 2) self.assertEqual(Attachment.objects.count(), 3) # JSONSchema validation response_json = response.json() for response_signal in response_json: detail_response_json = self.client.get( response_signal['_links']['self']['href']).json() self.assertEqual(len(detail_response_json['attachments']), 1) self.assertJsonSchema(self.retrieve_signal_schema, detail_response_json)
def setUp(self): self.signal_list_endpoint = '/signals/auth/signal/' self.signal_with_image = SignalFactoryWithImage.create()