# Path: ledgerbil/ledgerbilexceptions.py
# class LdgReconcilerError(LdgException):
#     pass
# 
# Path: ledgerbil/ledgerthing.py
# UNSPECIFIED_PAYEE = "<Unspecified payee>"
# DATE_REGEX = r"^\d{4}(?:[-/]\d\d){2}(?=\s|$)"
# TOP_LINE_REGEX = re.compile(
#     r"(" + DATE_REGEX + r")(?:\s+|$)"  # date with required whitespace (or $)
#     r"\s*([!*])?\s*"  # optional transaction state (c/p)
#     r"(?:\(([^)]*)\)\s*)?"  # optional transaction # and whitespace
#     r"(.*?)(?=  |$)"  # opt. payee ends with two spaces (or $)
# )
# POSTING_REGEX = re.compile(
#     r"""(?x)  # verbose mode
#     ^\s+                             # opening indent
#     ([!*])?                          # optional pending/cleared
#     (?:\s*)?                         # optional whitespace after p/c
#     ([^;]+?)(?<=\S)(?=\ \ |$)        # account - 2 spaces ends acct
#     (?:\s*                           # optional share info, leading whitespace
#       (-?\s*[.,0-9]+)                # num shares
#       (?:\s*([^@; ]+))               # symbol
#       (?:\s*@\s*)?                   # optional @
#     )?                               # close of optional share stuff
#     \(?([-+*/()$\d.,\s]+)?\)?        # optional amount expression
#     (?:\s*=\s*[^;]+\s*)?             # optional balance assertion
#     (?:;.*$|$)                       # optional end comment
#     """
# )
# REC_PENDING = "!"
# REC_CLEARED = "*"
# REC_UNCLEARED = ""
# def get_ledger_posting(line):
#     def __init__(self, lines, reconcile_account=None):
#     def __repr__(self):
#     def __str__(self):
#     def parse_top_line(self, line):
#     def parse_transaction_lines(self, lines):
#     def get_lines(self):
#     def is_new_thing(line):
#     def is_transaction_start(line):
#     def assert_only_one_status(self, statuses):
#     def assert_only_one_symbol(self, symbols):
#     def assert_only_shares_if_shares(self, shareses):
#     def assert_not_top_line_status(self):
#     def get_date_and_payee(self):
#     def get_date_string(self):
#     def is_pending(self):
#     def set_pending(self):
#     def is_cleared(self):
#     def set_cleared(self):
#     def set_uncleared(self):
# class LedgerThing:
# 
# Path: ledgerbil/tests/helpers.py
# class Redirector(TestCase):
#     def setUp(self):
#         self.savestdout = sys.stdout
#         self.reset_redirect()
# 
#         self.savestderr = sys.stderr
#         self.reset_err_redirect()
# 
#     def tearDown(self):
#         self.redirect.close()
#         sys.stdout = self.savestdout
# 
#         self.redirecterr.close()
#         sys.stderr = self.savestderr
# 
#     def reset_redirect(self):
#         self.redirect = StringIO()
#         sys.stdout = self.redirect
# 
#     def reset_err_redirect(self):
#         self.redirecterr = StringIO()
#         sys.stderr = self.redirecterr


from datetime import date
from unittest import TestCase
from .. import ledgerthing, settings, settings_getter  # noqa: F401
from ..ledgerbilexceptions import LdgReconcilerError
from ..ledgerthing import (
    REC_CLEARED,
    REC_PENDING,
    REC_UNCLEARED,
    UNSPECIFIED_PAYEE,
    LedgerPosting,
    LedgerThing,
    get_ledger_posting,
)
from .helpers import Redirector
import pytest
        # uncleared
        lines = (
            "2016/10/24 glob",
            "  ; might as well test comment handling, too",
            "  e: blurg",
            "  a: smurg   $-25",
        )
        thing = LedgerThing(list(lines), reconcile_account="smurg")
        expected = (
            "2016/10/24 glob",
            "  ; might as well test comment handling, too",
            "  e: blurg",
            "    a: smurg   $-25",
        )
        assert tuple(thing.get_lines()) == expected
        # pending
        lines = ("2016/10/24 glob", " !e: blurg", "  a: smurg   $-25")
        thing = LedgerThing(list(lines), "blurg")
        expected = ("2016/10/24 glob", "  ! e: blurg", "  a: smurg   $-25")
        assert tuple(thing.get_lines()) == expected
        # cleared
        lines = ("2016/10/24 glob", " *e: blurg", "  a: smurg   $-25")
        thing = LedgerThing(list(lines), "blurg")
        expected = ("2016/10/24 glob", "  * e: blurg", "  a: smurg   $-25")
        assert tuple(thing.get_lines()) == expected

    def test_get_lines_status_changes(self):
        # uncleared -> pending
        lines = ("2016/10/24 abc", "  e: xyz", "     a: smurg   $-25")
        thing = LedgerThing(list(lines), reconcile_account="smurg")

# Path: ledgerbil/ledgerbilexceptions.py
# class LdgReconcilerError(LdgException):
#     pass
# 
# Path: ledgerbil/ledgerthing.py
# UNSPECIFIED_PAYEE = "<Unspecified payee>"
# DATE_REGEX = r"^\d{4}(?:[-/]\d\d){2}(?=\s|$)"
# TOP_LINE_REGEX = re.compile(
#     r"(" + DATE_REGEX + r")(?:\s+|$)"  # date with required whitespace (or $)
#     r"\s*([!*])?\s*"  # optional transaction state (c/p)
#     r"(?:\(([^)]*)\)\s*)?"  # optional transaction # and whitespace
#     r"(.*?)(?=  |$)"  # opt. payee ends with two spaces (or $)
# )
# POSTING_REGEX = re.compile(
#     r"""(?x)  # verbose mode
#     ^\s+                             # opening indent
#     ([!*])?                          # optional pending/cleared
#     (?:\s*)?                         # optional whitespace after p/c
#     ([^;]+?)(?<=\S)(?=\ \ |$)        # account - 2 spaces ends acct
#     (?:\s*                           # optional share info, leading whitespace
#       (-?\s*[.,0-9]+)                # num shares
#       (?:\s*([^@; ]+))               # symbol
#       (?:\s*@\s*)?                   # optional @
#     )?                               # close of optional share stuff
#     \(?([-+*/()$\d.,\s]+)?\)?        # optional amount expression
#     (?:\s*=\s*[^;]+\s*)?             # optional balance assertion
#     (?:;.*$|$)                       # optional end comment
#     """
# )
# REC_PENDING = "!"
# REC_CLEARED = "*"
# REC_UNCLEARED = ""
# def get_ledger_posting(line):
#     def __init__(self, lines, reconcile_account=None):
#     def __repr__(self):
#     def __str__(self):
#     def parse_top_line(self, line):
#     def parse_transaction_lines(self, lines):
#     def get_lines(self):
#     def is_new_thing(line):
#     def is_transaction_start(line):
#     def assert_only_one_status(self, statuses):
#     def assert_only_one_symbol(self, symbols):
#     def assert_only_shares_if_shares(self, shareses):
#     def assert_not_top_line_status(self):
#     def get_date_and_payee(self):
#     def get_date_string(self):
#     def is_pending(self):
#     def set_pending(self):
#     def is_cleared(self):
#     def set_cleared(self):
#     def set_uncleared(self):
# class LedgerThing:
# 
# Path: ledgerbil/tests/helpers.py
# class Redirector(TestCase):
#     def setUp(self):
#         self.savestdout = sys.stdout
#         self.reset_redirect()
# 
#         self.savestderr = sys.stderr
#         self.reset_err_redirect()
# 
#     def tearDown(self):
#         self.redirect.close()
#         sys.stdout = self.savestdout
# 
#         self.redirecterr.close()
#         sys.stderr = self.savestderr
# 
#     def reset_redirect(self):
#         self.redirect = StringIO()
#         sys.stdout = self.redirect
# 
#     def reset_err_redirect(self):
#         self.redirecterr = StringIO()
#         sys.stderr = self.redirecterr


# Path: ledgerbil/tests/test_ledgerthing.py
from datetime import date
from unittest import TestCase
from .. import ledgerthing, settings, settings_getter  # noqa: F401
from ..ledgerbilexceptions import LdgReconcilerError
from ..ledgerthing import (
    REC_CLEARED,
    REC_PENDING,
    REC_UNCLEARED,
    UNSPECIFIED_PAYEE,
    LedgerPosting,
    LedgerThing,
    get_ledger_posting,
)
from .helpers import Redirector
import pytest

        # uncleared
        lines = (
            "2016/10/24 glob",
            "  ; might as well test comment handling, too",
            "  e: blurg",
            "  a: smurg   $-25",
        )
        thing = LedgerThing(list(lines), reconcile_account="smurg")
        expected = (
            "2016/10/24 glob",
            "  ; might as well test comment handling, too",
            "  e: blurg",
            "    a: smurg   $-25",
        )
        assert tuple(thing.get_lines()) == expected
        # pending
        lines = ("2016/10/24 glob", " !e: blurg", "  a: smurg   $-25")
        thing = LedgerThing(list(lines), "blurg")
        expected = ("2016/10/24 glob", "  ! e: blurg", "  a: smurg   $-25")
        assert tuple(thing.get_lines()) == expected
        # cleared
        lines = ("2016/10/24 glob", " *e: blurg", "  a: smurg   $-25")
        thing = LedgerThing(list(lines), "blurg")
        expected = ("2016/10/24 glob", "  * e: blurg", "  a: smurg   $-25")
        assert tuple(thing.get_lines()) == expected

    def test_get_lines_status_changes(self):
        # uncleared -> pending
        lines = ("2016/10/24 abc", "  e: xyz", "     a: smurg   $-25")
        thing = LedgerThing(list(lines), reconcile_account="smurg")

        thing.rec_status = REC_PENDING