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_varchar.py 935B

12345678910111213141516171819202122232425
  1. import unittest
  2. from lodel.leapi.datahandlers.datas import Varchar, Integer
  3. from lodel.leapi.datahandlers.base_classes import FieldValidationError
  4. from lodel.exceptions import *
  5. test_varchar = Varchar(max_length=10)
  6. class VarcharTestCase(unittest.TestCase):
  7. def test_check_good_data_value(self):
  8. for test_value in ["c" * 10, "c" * 9]:
  9. value = test_varchar._check_data_value(test_value)
  10. self.assertEqual(value, test_value)
  11. def test_check_bad_data_value(self):
  12. for test_value in ["c" * 11]:
  13. with self.assertRaises(FieldValidationError):
  14. value = test_varchar._check_data_value(test_value)
  15. def test_can_override(self):
  16. test_varchar1 = Varchar()
  17. test_integer = Integer()
  18. test_varchar2 = Varchar()
  19. self.assertFalse(test_varchar1.can_override(test_integer))
  20. self.assertTrue(test_varchar1.can_override(test_varchar2))