Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 24073 - validate date and handle time offset #3050

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,8 @@ def validate_business_in_colin(filing_json: dict, filing_type: str) -> list:
elif legal_name != response_json['business']['legalName']:
msg.append({'error': 'Legal name does not match with company legal name from Colin.',
'path': business_legal_name_path})
else:
# Check if founding date is None
if founding_date is None:
msg.append({
'error': 'Founding date is missing in the filing data.',
'path': business_founding_date_path
})
else:
if dt.fromisoformat(founding_date) != dt.fromisoformat(response_json['business']['foundingDate']):
msg.append({
'error': (
f"Founding date does not match with founding date from Colin. "
f"Filing founding_date: {founding_date}, "
f"Colin API founding_date: {response_json['business']['foundingDate']}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for removing the debugging code.

),
'path': business_founding_date_path
})
elif founding_date != response_json['business']['foundingDate']:
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
msg.append({'error': 'Founding date does not match with founding date from Colin.',
'path': business_founding_date_path})

return msg
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def test_validate_business_in_colin_founding_date_mismatch(mocker, app, session)
'identifier': 'A0077779',
'legalName': 'Test Company Inc.',
# Different founding date to trigger validation error
'foundingDate': '2010-01-01T18:00:00-00:00'
'foundingDate': '2010-01-01T18:21:13-00:00'
}
}
))
Expand All @@ -763,6 +763,35 @@ def test_validate_business_in_colin_founding_date_mismatch(mocker, app, session)
assert err[0]['path'] == '/filing/continuationIn/business/foundingDate'


def test_validate_business_in_colin_founding_date_match(mocker, app, session):
"""Assert continuation EXPRO business with matching founding date."""
filing = {'filing': {}}
filing['filing']['header'] = {'name': 'continuationIn', 'date': '2019-04-08',
'certifiedBy': 'full name', 'email': 'no_one@never.get', 'filingId': 1}
filing['filing']['continuationIn'] = copy.deepcopy(CONTINUATION_IN)

# Add the EXPRO business data with a matching founding date
filing['filing']['continuationIn']['business'] = {
'identifier': 'A0077779',
'legalName': 'Test Company Inc.',
'foundingDate': '2009-07-23T18:31:24-00:00'
}

mocker.patch('legal_api.services.colin.query_business', return_value=mocker.Mock(
status_code=HTTPStatus.OK,
json=lambda: {
'business': {
'identifier': 'A0077779',
'legalName': 'Test Company Inc.',
'foundingDate': '2009-07-23T18:31:24-00:00'
}
}
))

err = validate_business_in_colin(filing, 'continuationIn')
assert len(err) == 0


def test_validate_foreign_jurisdiction_incorporation_date(mocker, app, session):
"""Assert that an error is raised if the incorporation date is set to a future date."""
# Prepare a filing JSON with a future incorporation date
Expand Down
Loading