def test_override_with_custom_mapping(self): result = seed_data( self.api_factory, ["portfolios", "instruments", "transactions"], self.scope, seed_sample_data_override_csv, mappings=dict( load_json_file( Path(__file__).parent.parent.parent.joinpath( "integration", "cocoon", "data", "seed_sample_data", "seed_sample_data_override.json", ) ) ), sub_holding_keys=[f"Transaction/{self.scope}/strategy"], file_type="csv", ) self.assertEqual(len(result["portfolios"][0]["portfolios"]["success"]), 1) self.assertEqual(len(result["instruments"][0]["instruments"]["success"]), 1) self.assertEqual(len(result["transactions"][0]["transactions"]["success"]), 1)
def setUpClass(cls) -> None: cls.scope = create_scope_id().replace("-", "_") cls.api_factory = lusid.utilities.ApiClientFactory( api_secrets_filename=secrets_file) cls.sample_data = pd.read_csv(seed_sample_data_override_csv) seed_data( cls.api_factory, ["portfolios", "instruments", "transactions"], cls.scope, seed_sample_data_override_csv, mappings=dict( load_json_file( Path(__file__).parent.parent.parent.joinpath( "integration", "cocoon", "data", "seed_sample_data", "seed_sample_data_override.json", ))), sub_holding_keys=[f"Transaction/{cls.scope}/strategy"], file_type="csv", )
import pandas as pd from lusidtools.cocoon.cocoon import load_from_data_frame from lusidtools.cocoon.utilities import load_json_file import logging from pathlib import Path logger = logging.getLogger() default_mappings = dict(load_json_file("config/seed_sample_data.json")) def seed_data( api_factory, domains, scope: str, transaction_file: str, file_type: str, mappings: dict = default_mappings, sub_holding_keys=[], ): """ This function allows users to seed their LUSID environment with some core data (e.g. instruments, portfolios, and transaction) from one file. Parameters ---------- api_factory : lusid.utilities.ApiClientFactory The api factory to use domains : list[str] A list of the file_types for upload. scope : str