def test_appends_a_status_to_a_beneficiary_import_with_existing_status( self): # given one_second = timedelta(seconds=1) now = datetime.utcnow() beneficiary_import = BeneficiaryImport() payment_status = BeneficiaryImportStatus() payment_status.status = ImportStatus.DUPLICATE payment_status.date = datetime.utcnow() beneficiary_import.statuses = [payment_status] # when beneficiary_import.setStatus(ImportStatus.REJECTED) # then assert len(beneficiary_import.statuses) == 2 assert beneficiary_import.currentStatus == ImportStatus.REJECTED # pylint: disable=comparison-with-callable assert beneficiary_import.detail is None assert now - one_second < beneficiary_import.statuses[ 1].date < now + one_second
def create_beneficiary_import( application_id: int = 99, date: datetime = datetime.utcnow(), detail: str = None, idx: int = None, source_id: int = settings.DMS_OLD_ENROLLMENT_PROCEDURE_ID, source: str = BeneficiaryImportSources.demarches_simplifiees.value, status: ImportStatus = ImportStatus.CREATED, user: User = None, ) -> BeneficiaryImport: import_status = BeneficiaryImportStatus() import_status.date = date import_status.detail = detail import_status.status = status beneficiary_import = BeneficiaryImport() beneficiary_import.id = idx beneficiary_import.beneficiary = user beneficiary_import.applicationId = application_id beneficiary_import.sourceId = source_id beneficiary_import.source = source beneficiary_import.statuses = [import_status] return beneficiary_import