2
2
import unittest
3
3
4
4
from alot .utils import configobj as checks
5
+ from validate import VdtTypeError , VdtValueError
5
6
6
7
# Good descriptive test names often don't fit PEP8, which is meant to cover
7
8
# functions meant to be called by humans.
@@ -17,3 +18,34 @@ def test_strings_are_converted_to_single_item_lists(self):
17
18
def test_empty_strings_are_converted_to_empty_lists (self ):
18
19
forced = checks .force_list ('' )
19
20
self .assertEqual (forced , [])
21
+
22
+
23
+ class TestWidthTuple (unittest .TestCase ):
24
+
25
+ def test_validates_width_tuple (self ):
26
+ with self .assertRaises (VdtTypeError ):
27
+ checks .width_tuple ('invalid-value' )
28
+
29
+ def test_validates_width_tuple_for_fit_requires_two_args (self ):
30
+ with self .assertRaises (VdtTypeError ):
31
+ checks .width_tuple (['fit' , 123 ])
32
+
33
+ def test_args_for_fit_must_be_numbers (self ):
34
+ with self .assertRaises (VdtValueError ):
35
+ checks .width_tuple (['fit' , 123 , 'not-a-number' ])
36
+
37
+ def test_fit_with_two_numbers (self ):
38
+ fit_result = checks .width_tuple (['fit' , 123 , 456 ])
39
+ self .assertEqual (('fit' , 123 , 456 ), fit_result )
40
+
41
+ def test_validates_width_tuple_for_weight_needs_an_argument (self ):
42
+ with self .assertRaises (VdtTypeError ):
43
+ checks .width_tuple (['weight' ])
44
+
45
+ def test_arg_for_width_must_be_a_number (self ):
46
+ with self .assertRaises (VdtValueError ):
47
+ checks .width_tuple (['weight' , 'not-a-number' ])
48
+
49
+ def test_width_with_a_number (self ):
50
+ weight_result = checks .width_tuple (['weight' , 123 ])
51
+ self .assertEqual (('weight' , 123 ), weight_result )
0 commit comments