~trufas/ledgeroni

ref: 34d9de19c34e7ad190b2676ee65a517331101b6c ledgeroni/tests/integration/test_balance.py -rw-r--r-- 1.2 KiB
34d9de19 — Rafael Castillo Fix balance crashing with no filter 1 year, 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from click.testing import CliRunner
from ledgeroni.cli import cli


def test_balance():
    "Tests the balance command without any options"
    runner = CliRunner()
    result = runner.invoke(cli, [
        '-f', 'tests/sample_data/index.ledger', '--price-db',
        'tests/sample_data/prices_db', 'balance'])
    assert result.exit_code == 0


def test_bal_alias():
    "Makes sure the balance alias is registered"
    runner = CliRunner()
    result = runner.invoke(cli, [
        '-f', 'tests/sample_data/index.ledger', '--price-db',
        'tests/sample_data/prices_db', 'bal'])
    assert result.exit_code == 0
    assert '1.50 BTC  Asset:Bitcoin Wallet' in result.output


def test_without_ledger():
    "Throws an error when no ledger file is specified"
    runner = CliRunner()
    result = runner.invoke(cli, [
        '--price-db', 'tests/sample_data/prices_db', 'balance'])
    assert result.exit_code == 2


def test_filtering():
    "Test posting filtering"
    runner = CliRunner()
    result = runner.invoke(cli, [
        '-f', 'tests/sample_data/index.ledger', '--price-db',
        'tests/sample_data/prices_db', 'bal', 'paypal'])
    assert result.exit_code == 0
    assert 'Bank:Paypal' in result.output
    assert 'income' not in result.output