Exemplo n.º 1
0
    def test_example(self):
        """
        Test converted example with hledger
        """
        with tempfile.NamedTemporaryFile("w",
                                         suffix=".beancount",
                                         encoding="utf-8") as beanfile:
            # Generate an example Beancount file.
            example.write_example_file(
                datetime.date(1980, 1, 1),
                datetime.date(2010, 1, 1),
                datetime.date(2014, 1, 1),
                reformat=True,
                file=beanfile,
            )
            beanfile.flush()

            # Convert the file to HLedger format.
            #
            # Note: don't bother parsing for now, just a smoke test to make sure
            # we don't fail on run.
            with tempfile.NamedTemporaryFile("w",
                                             suffix=".hledger") as lgrfile:
                result = beancount2ledger.convert_file(beanfile.name,
                                                       "hledger")
                lgrfile.write(result)
                lgrfile.flush()
Exemplo n.º 2
0
def setup_app(tmpdir):
    filename = tmpdir.join('beancount.example')
    with filename.open('w') as fd:
        today = datetime.date.today()
        write_example_file(datetime.date(1980, 5, 12),
                           datetime.date(today.year - 3, 1, 1),
                           today, True, fd)
    app.config['BEANCOUNT_FILES'] = [str(filename)]
    load_file()
    app.testing = True
Exemplo n.º 3
0
def setup_app(tmpdir):
    filename = tmpdir.join('beancount.example')
    with filename.open('w') as fd:
        today = datetime.date.today()
        write_example_file(datetime.date(1980, 5, 12),
                           datetime.date(today.year - 3, 1, 1),
                           today, True, fd)
    app.beancount_filename = str(filename)
    api.load_file(app.beancount_filename)
    app.testing = True
Exemplo n.º 4
0
    def test_example(self):
        with tempfile.NamedTemporaryFile('w',
                                         suffix='.beancount',
                                         encoding='utf-8') as beanfile:
            # Generate an example Beancount file.
            example.write_example_file(datetime.date(1980, 1, 1),
                                       datetime.date(2010, 1, 1),
                                       datetime.date(2014, 1, 1),
                                       reformat=True,
                                       file=beanfile)
            beanfile.flush()

            # Convert the file to Ledger format.
            with tempfile.NamedTemporaryFile('w', suffix='.ledger') as lgrfile:
                result = beancount2ledger.convert_file(beanfile.name)
                lgrfile.write(result)
                lgrfile.flush()

                # FIXME: Use a proper temp dir.
                shutil.copyfile(lgrfile.name, '/tmp/test.ledger')
                self.check_parses_ledger(lgrfile.name)
Exemplo n.º 5
0
    def test_example(self):
        with tempfile.NamedTemporaryFile('w',
                                         suffix='.beancount',
                                         encoding='utf-8') as beanfile:
            # Generate an example Beancount file.
            example.write_example_file(datetime.date(1980, 1, 1),
                                       datetime.date(2010, 1, 1),
                                       datetime.date(2014, 1, 1),
                                       reformat=True,
                                       file=beanfile)
            beanfile.flush()

            # Convert the file to HLedger format.
            #
            # Note: don't bother parsing for now, just a smoke test to make sure
            # we don't fail on run.
            with tempfile.NamedTemporaryFile('w',
                                             suffix='.hledger') as lgrfile:
                with test_utils.capture():
                    result = test_utils.run_with_args(
                        report.main,
                        [beanfile.name, '-o', lgrfile.name, 'hledger'])
                self.assertEqual(0, result)
Exemplo n.º 6
0
    def test_example(self):
        with tempfile.NamedTemporaryFile('w',
                                         suffix='.beancount',
                                         encoding='utf-8') as beanfile:
            # Generate an example Beancount file.
            example.write_example_file(datetime.date(1980, 1, 1),
                                       datetime.date(2010, 1, 1),
                                       datetime.date(2014, 1, 1),
                                       True,
                                       file=beanfile)
            beanfile.flush()

            # Convert the file to Ledger format.
            with tempfile.NamedTemporaryFile('w', suffix='.ledger') as lgrfile:
                with test_utils.capture():
                    result = test_utils.run_with_args(
                        report.main,
                        [beanfile.name, '-o', lgrfile.name, 'ledger'])
                self.assertEqual(0, result)

                import shutil
                shutil.copyfile(lgrfile.name, '/tmp/test.ledger')
                self.check_parses_ledger(lgrfile.name)