32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from service_app_test.api_configs import BothAPIS
|
|
from service_app_test.test_application.migrate_old_data.reader_and_alchemy_bulk_actions import (
|
|
read_json_file,
|
|
)
|
|
from api_validations.validations_request import (
|
|
InsertAccountRecord,
|
|
)
|
|
|
|
|
|
def get_account_records_from_json():
|
|
read_files_json, with_pydantic = read_json_file(json_file="account_records"), []
|
|
read_files = read_files_json.get("account_records")
|
|
for row in read_files:
|
|
if not row['bank_reference_code']:
|
|
row['bank_reference_code'] = "NOT FOUND"
|
|
pydantic_row = InsertAccountRecord(**row)
|
|
with_pydantic.append(pydantic_row.model_dump())
|
|
if not with_pydantic:
|
|
raise Exception("No data found")
|
|
return with_pydantic
|
|
|
|
|
|
|
|
def migrate_account_records(requester: BothAPIS):
|
|
account_records = get_account_records_from_json()
|
|
for account_record in account_records:
|
|
response = requester.local_api.post(
|
|
endpoint="/account/records/create", data=account_record
|
|
)
|
|
print('response.text', response.text)
|
|
print('response.status_code', response.json())
|