123456789101112131415161718192021222324252627282930313233343536373839 |
- import pytest
- import finoex
- import ioex.calcex
- def get_item_a(currency='EUR'):
- return finoex.Item(
- name='a',
- price_brutto=finoex.Sum(2.0, currency),
- )
- def get_item_b():
- return finoex.Item(
- name='b',
- price_brutto=finoex.Sum(3.0, 'EUR'),
- sub_items=[get_item_a(), get_item_a()],
- )
- @pytest.mark.parametrize(('items', 'expected_total'), [
- [[], 0],
- [[get_item_a()], finoex.Sum(2.0, 'EUR')],
- [[get_item_b()], finoex.Sum(7.0, 'EUR')],
- [[get_item_a(), get_item_b()], finoex.Sum(9.0, 'EUR')],
- ])
- def test_get_items_total_price_brutto(items, expected_total):
- c = finoex._ItemCollection(items=items)
- assert expected_total == c.items_total_price_brutto
- @pytest.mark.parametrize(('items'), [
- [get_item_a(currency='EUR'), get_item_a(currency='USD')],
- ])
- def test_get_items_total_price_brutto_fail(items):
- c = finoex._ItemCollection(items=items)
- with pytest.raises(ioex.calcex.UnitMismatchError):
- c.items_total_price_brutto
|