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

Skip to content

Commit c476f11

Browse files
authored
34467 Colin API - snapshot appt dt fix (#4748)
Signed-off-by: Kial Jinnah <[email protected]>
1 parent 008e5f6 commit c476f11

3 files changed

Lines changed: 40 additions & 3 deletions

File tree

colin-api/src/colin_api/models/business_snapshot.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,14 @@ def _normalize_party(cls, party: Party) -> Dict:
116116
'officer': {**raw['officer'], 'id': raw['id'], 'email': None},
117117
'deliveryAddress': cls._normalize_address(raw['deliveryAddress']),
118118
'mailingAddress': cls._normalize_address(raw['mailingAddress']),
119-
'roles': raw['roles'] or [],
119+
'roles': [
120+
{
121+
'roleType': role.get('roleType'),
122+
'appointmentDate': cls._to_iso_date(role.get('appointmentDate')),
123+
'cessationDate': cls._to_iso_date(role.get('cessationDate')),
124+
}
125+
for role in (raw['roles'] or [])
126+
],
120127
}
121128

122129
@classmethod
@@ -201,3 +208,12 @@ def _to_iso_datetime(value: Optional[str]) -> Optional[str]:
201208
if value and value.endswith('-00:00'):
202209
return value[:-6] + '+00:00'
203210
return value
211+
212+
@staticmethod
213+
def _to_iso_date(value) -> Optional[str]:
214+
"""Coerce a role date to YYYY-MM-DD preserving None."""
215+
if value is None:
216+
return None
217+
if isinstance(value, datetime):
218+
return value.strftime('%Y-%m-%d')
219+
return str(value)[:10]

colin-api/src/colin_api/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
Development release segment: .devN
2323
"""
2424

25-
__version__ = '2.172.1' # pylint: disable=invalid-name
25+
__version__ = '2.172.2' # pylint: disable=invalid-name

colin-api/tests/unit/api/test_business_snapshot.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
# limitations under the License.
1414

1515
"""Tests to assure the business snapshot end-point."""
16+
from datetime import datetime
17+
1618
from colin_api.exceptions import BusinessNotFoundException, PartiesNotFoundException
1719
from colin_api.models import Business, Party, ShareObject
18-
from tests.unit import LEAR_ADDRESS, build_business, bypass_auth
20+
from tests.unit import LEAR_ADDRESS, build_business, build_director, bypass_auth
1921

2022

2123
SNAPSHOT_URL = '/api/v1/businesses/BC0870226/snapshot'
@@ -109,6 +111,25 @@ def test_get_snapshot_reports_future_effective_filing(client, mocker, authorized
109111
assert 'effective_dt' in mock_db.cursor.execute.call_args.args[0]
110112

111113

114+
def test_get_snapshot_normalizes_role_dates(client, mocker, authorized, mock_db,
115+
mock_lookups): # pylint: disable=unused-argument
116+
"""Assert a raw datetime role date (the founding-date fallback) is normalized to YYYY-MM-DD."""
117+
director = build_director()
118+
director.roles = [{
119+
'roleType': 'Director',
120+
'appointmentDate': datetime(2013, 4, 24, 0, 0),
121+
'cessationDate': None
122+
}]
123+
mocker.patch.object(Party, 'get_current', return_value=[director])
124+
125+
rv = client.get(SNAPSHOT_URL)
126+
127+
assert rv.status_code == 200
128+
assert rv.json['parties'][0]['roles'] == [
129+
{'roleType': 'Director', 'appointmentDate': '2013-04-24', 'cessationDate': None}
130+
]
131+
132+
112133
def test_get_snapshot_without_parties(client, mocker, authorized, mock_db,
113134
mock_lookups): # pylint: disable=unused-argument
114135
"""Assert a corp with no current directors on file still returns a snapshot."""

0 commit comments

Comments
 (0)