Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 124611d

Browse files
authored
34080 - Remove Active CCO Validation and clean up code (#4561)
1 parent de7c52a commit 124611d

2 files changed

Lines changed: 4 additions & 43 deletions

File tree

legal-api/src/legal_api/services/filings/validations/continuation_out.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from flask_babel import _ as babel
1919

2020
from business_common.utils.legislation_datetime import LegislationDatetime
21-
from business_model.models import Business, ConsentContinuationOut
21+
from business_model.models import Business
2222
from legal_api.errors import Error
2323
from legal_api.services import flags
2424
from legal_api.services.filings.validations.common_validations import (
@@ -41,20 +41,13 @@ def validate(business: Business, filing: dict) -> Error | None:
4141
msg = []
4242
filing_type = "continuationOut"
4343

44-
is_valid_co_date = True
45-
is_valid_foreign_jurisdiction = True
4644

4745
if err := validate_continuation_out_date(filing, filing_type):
4846
msg.extend(err)
49-
is_valid_co_date = False
5047

5148
if err := validate_foreign_jurisdiction(filing["filing"][filing_type]["foreignJurisdiction"],
5249
f"/filing/{filing_type}/foreignJurisdiction"):
5350
msg.extend(err)
54-
is_valid_foreign_jurisdiction = False
55-
56-
if is_valid_co_date and is_valid_foreign_jurisdiction:
57-
msg.extend(validate_active_cco(business, filing, filing_type))
5851

5952
if court_order := filing.get("filing", {}).get(filing_type, {}).get("courtOrder", None):
6053
court_order_path: Final = f"/filing/{filing_type}/courtOrder"
@@ -67,34 +60,6 @@ def validate(business: Business, filing: dict) -> Error | None:
6760
return None
6861

6962

70-
def validate_active_cco(business: Business, filing: dict, filing_type: str) -> list:
71-
"""Validate active consent continuation out."""
72-
msg = []
73-
continuation_out_date_str = filing["filing"][filing_type]["continuationOutDate"]
74-
continuation_out_date = LegislationDatetime.as_legislation_timezone_from_date_str(continuation_out_date_str)
75-
76-
foreign_jurisdiction = filing["filing"][filing_type]["foreignJurisdiction"]
77-
country_code = foreign_jurisdiction.get("country")
78-
region = foreign_jurisdiction.get("region")
79-
80-
continuation_out_date_utc = LegislationDatetime.as_utc_timezone(continuation_out_date)
81-
ccos = ConsentContinuationOut.get_active_cco(business.id, continuation_out_date_utc, country_code, region)
82-
83-
active_consent = False
84-
# Make sure continuation_out_date is on or after consent filing effective date
85-
for consent in ccos:
86-
if continuation_out_date.date() >= \
87-
LegislationDatetime.as_legislation_timezone(consent.filing.effective_date).date():
88-
active_consent = True
89-
break
90-
91-
if not active_consent:
92-
msg.extend([{"error": "No active consent continuation out for this date and/or jurisdiction.",
93-
"path": f"/filing/{filing_type}/continuationOutDate"}])
94-
95-
return msg
96-
97-
9863
def validate_continuation_out_date(filing: dict, filing_type: str) -> list:
9964
"""Validate continuation out date."""
10065
msg = []

legal-api/tests/unit/services/filings/validations/test_continuation_out.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
date_format = '%Y-%m-%d'
3131
legal_name = 'Test name request'
32-
validate_active_cco_path = 'legal_api.services.filings.validations.continuation_out.validate_active_cco'
3332

3433

3534
def _create_consent_continuation_out(business, foreign_jurisdiction, effective_date=datetime.utcnow()):
@@ -56,7 +55,7 @@ def _create_consent_continuation_out(business, foreign_jurisdiction, effective_d
5655
'test_name, expected_code, message',
5756
[
5857
('FAIL_IN_FUTURE', HTTPStatus.BAD_REQUEST, 'Continuation out date must be today or past.'),
59-
('FAIL_NO_CCO', HTTPStatus.BAD_REQUEST, 'No active consent continuation out for this date and/or jurisdiction.'),
58+
('SUCCESS_NO_CCO', None, None),
6059
('SUCCESS', None, None)
6160
]
6261
)
@@ -77,7 +76,7 @@ def test_validate_continuation_out_date(session, test_name, expected_code, messa
7776
if test_name == 'FAIL_IN_FUTURE':
7877
filing['filing']['continuationOut']['continuationOutDate'] = \
7978
(LegislationDatetime.now() + datedelta.datedelta(days=1)).strftime(date_format)
80-
elif test_name == 'FAIL_NO_CCO':
79+
elif test_name == 'SUCCESS_NO_CCO':
8180
effective_date -= datedelta.datedelta(months=6, days=1)
8281

8382
_create_consent_continuation_out(business,
@@ -86,7 +85,7 @@ def test_validate_continuation_out_date(session, test_name, expected_code, messa
8685
err = validate(business, filing)
8786

8887
# validate outcomes
89-
if test_name != 'SUCCESS':
88+
if test_name == 'FAIL_IN_FUTURE':
9089
assert expected_code == err.code
9190
assert message == err.msg[0]['error']
9291
else:
@@ -127,7 +126,6 @@ def test_validate_foreign_jurisdiction(session, mocker, test_name, expected_code
127126
filing['filing']['continuationOut']['foreignJurisdiction']['country'] = 'US'
128127
filing['filing']['continuationOut']['foreignJurisdiction']['region'] = 'NONE'
129128

130-
mocker.patch(validate_active_cco_path, return_value=[])
131129
err = validate(business, filing)
132130

133131
# validate outcomes
@@ -148,7 +146,6 @@ def test_valid_foreign_jurisdiction(session, mocker, monkeypatch):
148146
business = factory_business(identifier='BC1234567', entity_type='BC', founding_date=datetime.utcnow())
149147
filing = copy.deepcopy(FILING_HEADER)
150148
filing['filing']['header']['name'] = 'continuationOut'
151-
mocker.patch(validate_active_cco_path, return_value=[])
152149

153150
for country in pycountry.countries:
154151
filing['filing']['continuationOut'] = copy.deepcopy(CONTINUATION_OUT)
@@ -192,7 +189,6 @@ def test_continuation_out_court_order(session, mocker, test_status, file_number,
192189
else:
193190
del filing['filing']['continuationOut']['courtOrder']['fileNumber']
194191

195-
mocker.patch(validate_active_cco_path, return_value=[])
196192
err = validate(business, filing)
197193

198194
# validate outcomes

0 commit comments

Comments
 (0)