<commit_before>import datetime

from beancount.core.data import Transaction

from fava.core.holdings import inventory_at_dates


def test_inventory_at_dates(load_doc):
    """
    plugin "auto_accounts"

    2016-01-01 *
      Equity:Unknown
      Assets:Cash			5000 USD

    2016-01-02 *
      Assets:Account1             15 HOOL {123 USD}
      Assets:Cash

    2016-01-03 *
      Assets:Account1             10 HOOL {130 USD}
      Assets:Cash
    """
    entries, _, _ = load_doc
    dates = [
        datetime.date(2016, 1, 1),
        datetime.date(2016, 1, 2),
        datetime.date(2016, 1, 3),
        datetime.date(2016, 1, 4),
        datetime.date(2016, 1, 5),
        datetime.date(2016, 1, 6),
    ]

    transactions = [
        entry for entry in entries if isinstance(entry, Transaction)
    ]

    number_of_positions = [
        len(inv)
        for inv in inventory_at_dates(transactions, dates, lambda p: True)
    ]
    assert number_of_positions == [0, 0, 2, 3, 3, 3]

    number_of_positions = [
        len(inv)
        for inv in inventory_at_dates(transactions, dates,
                                      lambda p: p.account.startswith('Assets'))
    ]
    assert number_of_positions == [0, 1, 2, 3, 3, 3]<commit_msg>fix tests<commit_after>import datetime

from beancount.core.data import Transaction

from fava.core.holdings import inventory_at_dates


def test_inventory_at_dates(load_doc):
    """
    plugin "auto_accounts"

    2016-01-01 *
      Equity:Unknown
      Assets:Cash			5000 USD

    2016-01-02 *
      Assets:Account1             15 HOOL {123 USD}
      Assets:Cash

    2016-01-03 *
      Assets:Account1             10 HOOL {130 USD}
      Assets:Cash
    """
    entries, _, _ = load_doc
    dates = [
        datetime.date(2016, 1, 1),
        datetime.date(2016, 1, 2),
        datetime.date(2016, 1, 3),
        datetime.date(2016, 1, 4),
        datetime.date(2016, 1, 5),
        datetime.date(2016, 1, 6),
    ]

    transactions = (entry for entry in entries
                    if isinstance(entry, Transaction))

    number_of_positions = [
        len(inv)
        for inv in inventory_at_dates(transactions, dates, lambda p: True)
    ]
    assert number_of_positions == [0, 0, 2, 3, 3, 3]

    transactions = (entry for entry in entries
                    if isinstance(entry, Transaction))
    number_of_positions = [
        len(inv)
        for inv in inventory_at_dates(transactions, dates,
                                      lambda p: p.account.startswith('Assets'))
    ]
    assert number_of_positions == [0, 1, 2, 3, 3, 3]
{'fraction_non_alphanumeric': 0.1016949152542373, 'fraction_numerical': 0.06779661016949153, 'mean_word_length': 2.0552941176470587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4525234', 'n_tokens_mistral': 973, 'n_tokens_neox': 819, 'n_words': 207}