|
@@ -3,6 +3,7 @@ import pytest
|
|
|
import copy
|
|
|
import finoex
|
|
|
import ioex
|
|
|
+import re
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(('params', 'kwargs', 'expected_value', 'expected_currency'), [
|
|
@@ -115,3 +116,18 @@ def test_parse_text(loc, text, expected_sum):
|
|
|
def test_parse_text_fail(text):
|
|
|
with pytest.raises(Exception):
|
|
|
finoex.Sum.parse_text(text)
|
|
|
+
|
|
|
+
|
|
|
+@pytest.mark.parametrize(('haystack', 'expected_needles'), [
|
|
|
+ ["Preis: 0,50 €", [{'currency': '€', 'value': '0,50'}]],
|
|
|
+ ["Preis: 0,50 US$", [{'currency': 'US$', 'value': '0,50'}]],
|
|
|
+ ["Preis: 1234 ¥", [{'currency': '¥', 'value': '1234'}]],
|
|
|
+ ["price: 1.23 €", [{'currency': '€', 'value': '1.23'}]],
|
|
|
+ ["price: 1.23 US$", [{'currency': 'US$', 'value': '1.23'}]],
|
|
|
+])
|
|
|
+def test_sum_regex_value_first(haystack, expected_needles):
|
|
|
+ matches = re.finditer(
|
|
|
+ finoex.Sum.sum_regex_value_first,
|
|
|
+ haystack,
|
|
|
+ )
|
|
|
+ assert expected_needles == [m.groupdict() for m in matches]
|