@@ -13,15 +13,23 @@ def setUpClass(cls) -> None:
13
13
14
14
def test_isEmpty_default_bone (self ):
15
15
from viur .core .bones import NumericBone
16
- self ._run_tests (NumericBone ())
16
+ self ._run_tests (bone := NumericBone ())
17
+ self .assertTrue (bone .isEmpty (SMALL_FLOAT ), msg = vars (bone ))
17
18
18
19
def test_isEmpty_emptyNone (self ):
19
20
from viur .core .bones import NumericBone
20
- self ._run_tests (NumericBone (getEmptyValueFunc = lambda : None ))
21
+ self ._run_tests (bone := NumericBone (getEmptyValueFunc = lambda : None ))
22
+ self .assertFalse (bone .isEmpty (SMALL_FLOAT ), msg = vars (bone ))
21
23
22
24
def test_isEmpty_precision (self ):
23
25
from viur .core .bones import NumericBone
24
- self ._run_tests (NumericBone (precision = 2 ))
26
+ self ._run_tests (bone := NumericBone (precision = 2 ))
27
+ self .assertTrue (bone .isEmpty (SMALL_FLOAT ), msg = vars (bone ))
28
+
29
+ def test_isEmpty_high_precision (self ):
30
+ from viur .core .bones import NumericBone
31
+ self ._run_tests (bone := NumericBone (precision = 8 ))
32
+ self .assertFalse (bone .isEmpty (SMALL_FLOAT ), msg = vars (bone ))
25
33
26
34
def test_isEmpty_precision_emptyNone (self ):
27
35
from viur .core .bones import NumericBone
@@ -35,9 +43,6 @@ def _run_tests(self, bone):
35
43
self .assertFalse (bone .isEmpty (123.456 ))
36
44
self .assertFalse (bone .isEmpty (LARGE_INT ))
37
45
self .assertFalse (bone .isEmpty (LARGE_FLOAT ))
38
- if bone .precision != 0 :
39
- self .assertFalse (bone .isEmpty (SMALL_FLOAT ), msg = vars (bone ))
40
-
41
46
self .assertTrue (bone .isEmpty ("" ))
42
47
self .assertTrue (bone .isEmpty (None ))
43
48
self .assertTrue (bone .isEmpty ([]))
@@ -55,6 +60,7 @@ def test_convert_to_numeric(self):
55
60
self .assertEqual (42.6 , bone ._convert_to_numeric (42.6 ))
56
61
self .assertEqual (42.6 , bone ._convert_to_numeric ("42.6" ))
57
62
self .assertEqual (42.6 , bone ._convert_to_numeric ("42,6" ))
63
+ self .assertEqual (42.6 , bone ._convert_to_numeric ({"val" : "42,6" , "idx" : "42,6" }))
58
64
self .assertIsInstance (bone ._convert_to_numeric (42 ), float )
59
65
with self .assertRaises (TypeError ):
60
66
bone ._convert_to_numeric (None )
@@ -70,6 +76,8 @@ def test_convert_to_numeric(self):
70
76
self .assertEqual (42 , bone ._convert_to_numeric (42.0 ))
71
77
self .assertEqual (42 , bone ._convert_to_numeric ("42.6" ))
72
78
self .assertEqual (42 , bone ._convert_to_numeric ("42,6" ))
79
+ self .assertEqual (42 , bone ._convert_to_numeric ("42,6" ))
80
+ self .assertEqual (42 , bone ._convert_to_numeric ({"val" : "42" , "idx" : "42" }))
73
81
with self .assertRaises (ValueError ):
74
82
bone ._convert_to_numeric ("123.456,5" )
75
83
self .assertIsInstance (bone ._convert_to_numeric (42 ), int )
0 commit comments