コード例 #1
0
ファイル: journal_html_test.py プロジェクト: wzyboy/beancount
    def test_iterate_html_postings(self):
        formatter = html_formatter.HTMLFormatter(
            display_context.DEFAULT_DISPLAY_CONTEXT)
        rows = list(
            journal_html.iterate_html_postings(self.real_account.txn_postings,
                                               formatter))

        # Check (entry, leg_postings, rowtype, extra_class, flag).
        self.assertEqual([
            (data.Open, 0, 'Open', '', ''),
            (data.Pad, 0, 'Pad', '', ''),
            (data.Transaction, 1, 'Padding', '', 'P'),
            (data.Balance, 0, 'Balance', '', ''),
            (data.Transaction, 1, 'Transaction', 'warning', '!'),
            (data.Balance, 0, 'Balance', '', ''),
            (data.Note, 0, 'Note', '', ''),
            (data.Document, 0, 'Document', '', ''),
            (data.Transaction, 2, 'Transaction', '', '*'),
            (data.Balance, 0, 'Balance', 'fail', ''),
            (data.Close, 0, 'Close', '', ''),
        ], [(type(row.entry), len(
            row.leg_postings), row.rowtype, row.extra_class, row.flag)
            for row in rows])

        self.assertTrue(
            all(
                re.search(row.rowtype, row.description) for row in rows
                if not isinstance(row.entry, data.Transaction)))

        self.assertTrue(all(isinstance(row.amount_str, str) for row in rows))
        self.assertTrue(all(isinstance(row.balance_str, str) for row in rows))
コード例 #2
0
ファイル: base.py プロジェクト: powerivq/beancount
 def __init__(self, *args, formatter=None, css_id=None, css_class=None):
     super().__init__(*args)
     if formatter is None:
         formatter = html_formatter.HTMLFormatter(
             display_context.DEFAULT_DISPLAY_CONTEXT)
     self.formatter = formatter
     self.css_id = css_id
     self.css_class = css_class
コード例 #3
0
ファイル: journal_html_test.py プロジェクト: wzyboy/beancount
 def test_html_entries_table_with_balance(self):
     oss = io.StringIO()
     formatter = html_formatter.HTMLFormatter(
         display_context.DEFAULT_DISPLAY_CONTEXT)
     journal_html.html_entries_table_with_balance(
         oss, self.real_account.txn_postings, formatter, True)
     html = oss.getvalue()
     self.assertTrue(isinstance(html, str))
     self.assertRegex(html, '<table')
コード例 #4
0
 def test_functions(self):
     # Just a smoke test.
     formatter = html_formatter.HTMLFormatter(
         display_context.DEFAULT_DISPLAY_CONTEXT)
     formatter.render_account('Assets:US:Bank:Checking')
     formatter.render_inventory(
         inventory.from_string('10 CAD, 2 HOOL {500 USD}'))
     formatter.render_context('2b4722c3f89f43841cacf16325c2')
     formatter.render_link('fc6189c48a53')
     formatter.render_doc('/path/to/my/document.pdf')
     formatter.render_event_type('location')
     formatter.render_commodity(('HOOL', 'USD'))
     formatter.render_source(
         data.new_metadata('/path/to/my/input.beancount', 17))
コード例 #5
0
    def test_table_of_balances(self):
        formatter = html_formatter.HTMLFormatter(
            display_context.DEFAULT_DISPLAY_CONTEXT)
        html = tree_table.table_of_balances(self.real_root, ['USD', 'CAD'],
                                            formatter,
                                            classes=['586e8200b379'])
        self.assertRegex(html, '<table')
        self.assertRegex(html, 'USD')
        self.assertRegex(html, 'CAD')
        self.assertRegex(html, '586e8200b379')
        self.assertRegex(html, 'Checking')

        # Check that an inactive account is being skipped.
        self.assertNotRegex(html, 'Inactive')
コード例 #6
0
    def test_render_inventory(self):
        formatter = html_formatter.HTMLFormatter(
            display_context.DEFAULT_DISPLAY_CONTEXT)
        balance = inventory.Inventory()
        self.assertEqual('', formatter.render_inventory(balance))

        balance = inventory.Inventory.from_string(
            '111 USD, 222 CAD, 3 HOOL {400 USD}')
        html_balance = formatter.render_inventory(balance)
        self.assertRegex(html_balance, r'\b111\b')
        self.assertRegex(html_balance, r'\bUSD\b')
        self.assertRegex(html_balance, r'\b222\b')
        self.assertRegex(html_balance, r'\bCAD\b')
        self.assertRegex(html_balance, r'\b3\b')
        self.assertRegex(html_balance, r'\bHOOL\b')
        self.assertRegex(html_balance, r'\b400\b')