From 4198c46acaf32a63f7f1aa419b5b28394b64d192 Mon Sep 17 00:00:00 2001 From: Hongjing Chen Date: Mon, 17 Jun 2024 15:59:10 +0000 Subject: [PATCH] update COA processor to skip batch_processing entry that has trigger_date more than 60 days Signed-off-by: Hongjing Chen --- .../filing_processors/change_of_address.py | 4 +-- .../test_change_of_address.py | 25 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_address.py b/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_address.py index 79c8671612..bc0efce80b 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_address.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_address.py @@ -49,7 +49,7 @@ def process(business: Business, filing: Dict, filing_meta: FilingMeta, flag_on: if batch_processing.status not in [ BatchProcessing.BatchProcessingStatus.COMPLETED, BatchProcessing.BatchProcessingStatus.WITHDRAWN - ]: + ] and datetime.utcnow() + datedelta(days=60) > batch_processing.trigger_date: batch_processing.trigger_date = datetime.utcnow() + datedelta(days=62) batch_processing.meta_data = { **batch_processing.meta_data, @@ -58,4 +58,4 @@ def process(business: Business, filing: Dict, filing_meta: FilingMeta, flag_on: target_dissolution_date = date.fromisoformat(batch_processing.meta_data['targetDissolutionDate']) target_dissolution_date += datedelta(days=62) batch_processing.meta_data['targetDissolutionDate'] = target_dissolution_date.isoformat() - batch_processing.last_modified=datetime.utcnow() + batch_processing.last_modified = datetime.utcnow() diff --git a/queue_services/entity-filer/tests/unit/filing_processors/test_change_of_address.py b/queue_services/entity-filer/tests/unit/filing_processors/test_change_of_address.py index 0a6a4a59c5..4f70375f9d 100644 --- a/queue_services/entity-filer/tests/unit/filing_processors/test_change_of_address.py +++ b/queue_services/entity-filer/tests/unit/filing_processors/test_change_of_address.py @@ -59,33 +59,51 @@ def test_change_of_address_process(app, session): assert delivery_address.city == 'new delivery_address city' -@pytest.mark.parametrize('test_name, status, step, delay', [ +@pytest.mark.parametrize('test_name, status, step, trigger_date, delay', [ ( 'DELAY_IN_DISSOLUTION_STAGE_1', BatchProcessing.BatchProcessingStatus.PROCESSING, BatchProcessing.BatchProcessingStep.WARNING_LEVEL_1, + datetime.utcnow()+datedelta(days=42), True ), ( 'DELAY_IN_DISSOLUTION_STAGE_2', BatchProcessing.BatchProcessingStatus.PROCESSING, BatchProcessing.BatchProcessingStep.WARNING_LEVEL_2, + datetime.utcnow()+datedelta(days=42), True ), ( 'NO_DELAY_NOT_IN_DISSOLUTION_1', BatchProcessing.BatchProcessingStatus.COMPLETED, BatchProcessing.BatchProcessingStep.DISSOLUTION, + datetime.utcnow()+datedelta(days=42), False ), ( 'NO_DELAY_NOT_IN_DISSOLUTION_2', BatchProcessing.BatchProcessingStatus.WITHDRAWN, BatchProcessing.BatchProcessingStep.WARNING_LEVEL_1, + datetime.utcnow()+datedelta(days=42), + False + ), + ( + 'NO_DELAY_TRIGGER_DATE_MORE_THAN_60_DAYS_STAGE_1', + BatchProcessing.BatchProcessingStatus.PROCESSING, + BatchProcessing.BatchProcessingStep.WARNING_LEVEL_1, + datetime.utcnow()+datedelta(days=70), + False + ), + ( + 'NO_DELAY_TRIGGER_DATE_MORE_THAN_60_DAYS_STAGE_2', + BatchProcessing.BatchProcessingStatus.PROCESSING, + BatchProcessing.BatchProcessingStep.WARNING_LEVEL_1, + datetime.utcnow()+datedelta(days=70), False ) ]) -def test_change_of_address_delay_dissolution(app, session, test_name, status, step, delay): +def test_change_of_address_delay_dissolution(app, session, test_name, status, step, trigger_date, delay): """Assert that involuntary dissolution is delayed.""" identifier = 'CP1234567' business = create_business(identifier) @@ -94,7 +112,8 @@ def test_change_of_address_delay_dissolution(app, session, test_name, status, st business_id=business.id, identifier=business.identifier, status=status, - step=step) + step=step, + trigger_date=trigger_date) utc_now = datetime.utcnow() dissolution_date = utc_now + datedelta(days=72)