def test_reply_received(self, send): mail = Mail(status=ReceptionStatusEnum.REPLY_RECEIVED) mail.save() send.return_value = None send_licence_data_to_hmrc.now() self.assertEqual( LicencePayload.objects.filter(is_processed=True).count(), 0)
def test_pending(self, send): mail = Mail(status=ReceptionStatusEnum.PENDING) mail.save() send.return_value = None send_licence_data_to_hmrc.now() self.assertEqual( LicencePayload.objects.filter(is_processed=True).count(), 0)
def test_licence_is_marked_as_processed_after_sending(self, send): send.return_value = None send_licence_data_to_hmrc.now() self.assertEqual(Mail.objects.count(), 1) self.single_siel_licence_payload.refresh_from_db() self.assertEqual(self.single_siel_licence_payload.is_processed, True)
def test_reply_sent_accepted(self, send): mail = Mail(status=ReceptionStatusEnum.REPLY_SENT, response_data="accepted") mail.save() send.return_value = None send_licence_data_to_hmrc.now() self.assertEqual( LicencePayload.objects.filter(is_processed=True).count(), 1)
def get(self, _): """ Force the task of sending licence data to HMRC (I assume for testing?) """ success = send_licence_data_to_hmrc.now() if success: return HttpResponse(status=HTTP_200_OK) else: return HttpResponse(status=HTTP_500_INTERNAL_SERVER_ERROR)
def test_exception(self, validator): validator.side_effect = EdifactValidationError() with self.assertRaises(EdifactValidationError): send_licence_data_to_hmrc.now()