Example #1
0
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)
Example #2
0
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)
Example #3
0
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)]
Example #4
0
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)]
Example #5
0
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)
Example #6
0
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)