|
@@ -1,27 +1,30 @@
|
1
|
1
|
import unittest
|
2
|
2
|
|
3
|
|
-from lodel.leapi.datahandlers.datas import Concat, Varchar
|
4
|
|
-from lodel.editorial_model.components import EmClass
|
5
|
|
-from lodel.leapi.datahandlers.base_classes import DatasConstructor
|
|
3
|
+from lodel.leapi.datahandlers.datas import Concat as Testee
|
6
|
4
|
|
7
|
|
-class ConcatTestCase(unittest.TestCase):
|
8
|
|
-
|
9
|
|
- # @TODO use Data Constructors
|
10
|
|
- def test_construct_data(self):
|
11
|
|
- test_class = EmClass('testing', display_name='testing class')
|
12
|
|
- test_class.new_field('field1', 'varchar')
|
13
|
|
- test_class.new_field('field2', 'varchar')
|
14
|
|
-
|
15
|
|
- datas = {'field1': 'o'*5, 'field2': 'k'*4}
|
16
|
|
- datas2 = {'field1': 'o'*5, 'field2': 'k'*10}
|
17
|
5
|
|
18
|
|
- test_concat = Concat(['field1', 'field2'], '*')
|
19
|
|
- concat_string_value = test_concat.construct_data(test_class, 'field', datas, '')
|
20
|
|
- self.assertEqual('%s*%s' % ('o'*5, 'k'*4), concat_string_value)
|
21
|
|
-
|
22
|
|
- test_concat.max_length=10
|
23
|
|
- concat_string_value = test_concat.construct_data(test_class, 'field', datas2, '')
|
24
|
|
- test_value = '%s*%s' % ('o'*5, 'k'*10)
|
25
|
|
- self.assertNotEqual(test_value, concat_string_value)
|
26
|
|
- self.assertEqual(len(concat_string_value), test_concat.max_length)
|
27
|
|
- self.assertTrue(concat_string_value in test_value)
|
|
6
|
+class ConcatTestCase(unittest.TestCase):
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+ def test_has_base_type_property(self):
|
|
10
|
+ self.assertTrue(hasattr(Testee, 'base_type'))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+ def test_base_type_is_char(self):
|
|
14
|
+ self.assertEqual(Testee.base_type, 'char')
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+ def test_has_help_property(self):
|
|
18
|
+ self.assertTrue(hasattr(Testee, 'help'))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+ def test_help_property_str_is_set(self):
|
|
22
|
+ self.assertEqual(type(Testee.help), str)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+ def test_sets_correct_format_string(self):
|
|
26
|
+ separator = '-'
|
|
27
|
+ field_list = ['', '', '']
|
|
28
|
+ testee = Testee(field_list, separator)
|
|
29
|
+
|
|
30
|
+ self.assertEqual(testee._format_string, separator.join(['%s' for _ in field_list]))
|