def test_bad_file_type(self): with self.assertRaises(ValueError) as error: seed_data( self.api_factory, ["portfolios", "instruments", "transactions"], self.scope, Path(__file__).parent.joinpath("data/seed_sample_data/sample_data.xml"), file_type="xml", ) self.assertEqual( error.exception.args[0], "Unsupported file type, please upload one of the following: ['csv', 'xlsx']", )
def test_bad_file_type(self): with self.assertRaises(ValueError) as error: seed_data( self.api_factory, ["bad_file_type"], self.scope, seed_sample_data_override_csv, file_type="csv", ) self.assertEqual( error.exception.args[0], "The provided file_type of bad_file_type has no associated mapping", )
def setUpClass(cls) -> None: cls.scope = create_scope_id().replace("-", "_") cls.api_factory = lusid.utilities.ApiClientFactory( api_secrets_filename=secrets_file) cls.test_dataframe = pd.read_csv(sample_data_csv) cls.sample_data = pd.read_csv(sample_data_csv) seed_data( cls.api_factory, ["portfolios", "instruments", "transactions"], cls.scope, cls.test_dataframe, sub_holding_keys=[f"Transaction/{cls.scope}/strategy"], file_type="DataFrame", )
def test_inconsistent_file_extensions(self): self.file_extension = "xlsx" with self.assertRaises(ValueError) as error: seed_data( self.api_factory, ["portfolios", "instruments", "transactions"], self.scope, seed_sample_data_override_csv, file_type=self.file_extension, ) self.assertEqual( error.exception.args[0], f"""Inconsistent file and file extensions passed: {seed_sample_data_override_csv} does not have file extension {self.file_extension}""", )
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_excel( Path(__file__).parent.joinpath( "data/seed_sample_data/sample_data_excel.xlsx")) seed_data( cls.api_factory, ["portfolios", "instruments", "transactions"], cls.scope, Path(__file__).parent.joinpath( "data/seed_sample_data/sample_data_excel.xlsx"), sub_holding_keys=[f"Transaction/{cls.scope}/strategy"], file_type="xlsx", )
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", )
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)