28 lines
984 B
Python
28 lines
984 B
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 InsertCompany
|
|
|
|
|
|
requester_dict = lambda data: {"endpoint": "/company/create", "data": data}
|
|
|
|
|
|
def get_company_from_json():
|
|
read_files_json, with_pydantic = read_json_file(json_file="companies"), []
|
|
read_files = read_files_json.get("companies")
|
|
for row in read_files:
|
|
pydantic_row = InsertCompany(**row)
|
|
with_pydantic.append(pydantic_row.model_dump())
|
|
if not with_pydantic:
|
|
raise Exception("No data found")
|
|
return with_pydantic
|
|
|
|
|
|
def migrate_company(requester: BothAPIS):
|
|
for response_data in get_company_from_json():
|
|
response_data["company_tag"] = response_data["formal_name"]
|
|
response = requester.local_api.post(**requester_dict(data=response_data))
|
|
print("response", response.text)
|
|
return
|