def test_aggregate_holdings_list_simple(): assert aggregate_holdings_list([]) is None holdings = [ Posting('Assets', A('10 HOOL'), None, None, None, None), Posting('Assets', A('14 HOOL'), None, None, None, None), ] assert aggregate_holdings_list(holdings) == \ Posting('Assets', A('24 HOOL'), None, None, None, None) holdings = [ Posting('Assets:No', A('10 HOOL'), None, None, None, None), Posting('Assets:Test', A('14 HOOL'), None, None, None, None), ] assert aggregate_holdings_list(holdings) == \ Posting('Assets', A('24 HOOL'), None, None, None, None)
def test_aggregate_holdings_by(): assert aggregate_holdings_list([]) is None holdings = [ Posting('Assets', A('10 HOOL'), None, None, None, None), Posting('Assets:Test', A('14 HOL'), None, None, None, None), ] assert aggregate_holdings_by(holdings, 'account') == holdings assert aggregate_holdings_by(holdings, 'currency') == holdings assert aggregate_holdings_by(holdings, 'invalid') == holdings holdings = [ Posting('Assets', A('10 HOOL'), None, None, None, None), Posting('Assets', A('14 HOOL'), None, None, None, None), ] assert aggregate_holdings_by(holdings, 'account') == \ [aggregate_holdings_list(holdings)]
def test_aggregate_holdings_list_with_price(): holdings = [ Posting('Assets', A('10 HOOL'), None, None, None, None), Posting('Assets', A('14 TEST'), Cost(D('10'), 'HOOL', None, None), D('12'), None, None), ] assert aggregate_holdings_list(holdings) == \ Posting('Assets', Amount(D('24'), '*'), Cost(D('6.25'), 'HOOL', None, None), D('178') / 24, None, None)