|
1 | 1 | import pytest |
2 | 2 | import rechnung.cli as cli |
3 | 3 | import rechnung.settings as settings |
| 4 | +import yaml |
4 | 5 |
|
5 | 6 | from click.testing import CliRunner |
6 | 7 | from shutil import copytree |
@@ -87,3 +88,26 @@ def test_print_contracts(cli_test_data_path): |
87 | 88 | result.output |
88 | 89 | == "1000: martha.muster@email.tld 2019-06-01 60.21€\n1001: mike.murks@email.tld 2030-06-01 13.37€\n1002: frank.nord@email.tld 2019-06-01 48.45€\n" |
89 | 90 | ) |
| 91 | + |
| 92 | +def test_invoice_create(cli_test_data_path): |
| 93 | + cli1, path = cli_test_data_path |
| 94 | + s = settings.get_settings_from_cwd(path) |
| 95 | + runner = CliRunner() |
| 96 | + result = runner.invoke(cli1, ["create", "2019", "10"]) |
| 97 | + invoice_1000_path = path.joinpath(s.invoices_dir, "1000", "1000.2019.10.yaml") |
| 98 | + invoice_1002_path = path.joinpath(s.invoices_dir, "1002", "1002.2019.10.yaml") |
| 99 | + assert invoice_1000_path.is_file() |
| 100 | + assert not path.joinpath(s.invoices_dir, "1001", "1001.2019.10.yaml").is_file() |
| 101 | + assert invoice_1002_path.is_file() |
| 102 | + |
| 103 | + with open(invoice_1000_path) as infile: |
| 104 | + invoice_data = yaml.safe_load(infile) |
| 105 | + assert invoice_data["total_net"] == 50.6 |
| 106 | + assert invoice_data["total_vat"] == 9.61 |
| 107 | + assert invoice_data["total_gross"] == 60.21 |
| 108 | + with open(invoice_1002_path) as infile: |
| 109 | + invoice_data = yaml.safe_load(infile) |
| 110 | + assert invoice_data["total_net"] == 40.71 |
| 111 | + assert invoice_data["total_vat"] == 7.74 |
| 112 | + assert invoice_data["total_gross"] == 48.45 |
| 113 | + |
0 commit comments