def test_read_holdings_bochk3(self): filename = get_current_path( ) + '\\samples\\short_position _ 03032017.xlsx' port_values = {} read_holdings_bochk(filename, port_values) self.assertEqual(port_values['holdings'][0]['sub_total'], -200000) self.assertEqual(port_values['holdings'][1]['sub_total'], -1600000)
def handle_bochk_position(bochk_position_file, source, output_dir): """ source: 'hk' or 'mc' to indicate which accounts they contain """ port_values = {} read_holdings_bochk(bochk_position_file, port_values) return port_values['holding_date'], \ write_holding_csv(port_values, output_dir, 'trustee_' + source + '_bochk_')
def test_get_date_from_file(self): cash_file = get_current_path() + '\\samples\\Cash _ 15112016.xls' holdings_file = get_current_path( ) + '\\samples\\Holding _ 12072016.xls' port_values = {} read_cash_bochk(cash_file, port_values) read_holdings_bochk(holdings_file, port_values) self.assertEqual(datetime(2016, 11, 15), port_values['cash_date']) self.assertEqual(datetime(2016, 7, 12), port_values['holding_date'])
def test_output_error(self): filename = get_current_path( ) + '\\samples\\sample_holdings_error11 _ 16112016.xls' port_values = {} read_holdings_bochk(filename, port_values) directory = get_current_path() + '\\samples' with self.assertRaises(InvestmentIdNotFound): write_holding_csv(port_values, directory, \ get_prefix_from_dir(get_input_directory()))
def test_cash_error4(self): holdings_file = get_current_path( ) + '\\samples\\sample_holdings2 _ 16112016.xls' cash_file = get_current_path( ) + '\\samples\\cash_error4 _ 16112016.xls' port_values = {} directory = get_current_path() + '\\samples' read_cash_bochk(cash_file, port_values) read_holdings_bochk(holdings_file, port_values) with self.assertRaises(InvalidCashAccountName): write_csv(port_values, directory)
def test_read_holdings_bochk4(self): # the in house fund holdings filename = get_current_path() + '\\samples\\Holding _ 31082017.xls' port_values = {} read_holdings_bochk(filename, port_values) self.assertEqual(port_values['holdings'][0]['sub_total'], 1000000) # the last position self.assertEqual(port_values['holdings'][10]['security_id'], 'XS1450332256') self.assertEqual(port_values['holdings'][10]['sub_total'], 5000000)
def test_err9(self): filename = get_current_path( ) + '\\samples\\sample_holdings_error9 _ 16112016.xls' port_values = {} with self.assertRaises(InconsistentPositionFieldsTotal): read_holdings_bochk(filename, port_values)
def test_err6(self): filename = get_current_path( ) + '\\samples\\sample_holdings_error6 _ 16112016.xls' port_values = {} with self.assertRaises(TypeError): read_holdings_bochk(filename, port_values)
def test_err(self): filename = get_current_path( ) + '\\samples\\sample_holdings_error _ 16112016.xls' port_values = {} with self.assertRaises(InvalidFieldName): read_holdings_bochk(filename, port_values)
def test_read_holdings_bochk2(self): filename = get_current_path( ) + '\\samples\\sample_holdings4 _ 06072016.xls' port_values = {} read_holdings_bochk(filename, port_values) self.verify_holdings2(port_values['holdings'])