No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_concat.py 1.1KB

123456789101112131415161718192021222324252627
  1. import unittest
  2. from lodel.leapi.datahandlers.datas import Concat, Varchar
  3. from lodel.editorial_model.components import EmClass
  4. from lodel.leapi.datahandlers.base_classes import DatasConstructor
  5. class ConcatTestCase(unittest.TestCase):
  6. # @TODO use Data Constructors
  7. def test_construct_data(self):
  8. test_class = EmClass('testing', display_name='testing class')
  9. test_class.new_field('field1', 'varchar')
  10. test_class.new_field('field2', 'varchar')
  11. datas = {'field1': 'o'*5, 'field2': 'k'*4}
  12. datas2 = {'field1': 'o'*5, 'field2': 'k'*10}
  13. test_concat = Concat(['field1', 'field2'], '*')
  14. concat_string_value = test_concat.construct_data(test_class, 'field', datas, '')
  15. self.assertEqual('%s*%s' % ('o'*5, 'k'*4), concat_string_value)
  16. test_concat.max_length=10
  17. concat_string_value = test_concat.construct_data(test_class, 'field', datas2, '')
  18. test_value = '%s*%s' % ('o'*5, 'k'*10)
  19. self.assertNotEqual(test_value, concat_string_value)
  20. self.assertEqual(len(concat_string_value), test_concat.max_length)
  21. self.assertTrue(concat_string_value in test_value)