|
@@ -0,0 +1,20 @@
|
|
|
|
+#
|
|
|
|
+# Copyright (c) Daniel Sheffield 2023
|
|
|
|
+#
|
|
|
|
+# All rights reserved
|
|
|
|
+#
|
|
|
|
+# THIS SOFTWARE IS PROVIDED AS IS WITHOUT WARRANTY
|
|
|
|
+from decimal import Decimal
|
|
|
|
+from pytest import mark
|
|
|
|
+
|
|
|
|
+from app.data.decimal_util import(
|
|
|
|
+ decimal_or_none
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+@mark.parametrize('maybe_decimal, expected', [
|
|
|
|
+ ('1', Decimal('1')),
|
|
|
|
+ ('1.0', Decimal('1.0')),
|
|
|
|
+ ('', None),
|
|
|
|
+])
|
|
|
|
+def test_decimal_or_none(maybe_decimal, expected):
|
|
|
|
+ assert decimal_or_none(maybe_decimal) == expected
|