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_datahandler.py 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import unittest
  2. from lodel.leapi.datahandlers.base_classes import DataHandler
  3. from lodel.leapi.datahandlers.datas import Varchar
  4. class DataHandlerTestCase(unittest.TestCase):
  5. def test_init_abstract_class(self):
  6. datahandler = None
  7. try:
  8. datahandler = DataHandler()
  9. except NotImplementedError:
  10. self.assertNotIsInstance(datahandler, DataHandler)
  11. self.assertIsNone(datahandler)
  12. def test_register_new_handler(self):
  13. DataHandler.register_new_handler('testvarchar', Varchar)
  14. self.assertEqual(DataHandler.from_name('testvarchar'), Varchar)
  15. def test_register_nonclass_as_handler(self):
  16. try:
  17. DataHandler.register_new_handler('testvarchar', 'common string')
  18. except Exception as err:
  19. self.assertEqual(ValueError, type(err))
  20. def test_register_invalid_class_as_handler(self):
  21. try:
  22. DataHandler.register_new_handler('testvarchar', Exception)
  23. except Exception as err:
  24. self.assertEqual(ValueError, type(err))
  25. def test_from_name(self):
  26. DataHandler.register_new_handler('test_varchar', Varchar)
  27. self.assertEqual(DataHandler.from_name('test_varchar'), Varchar)
  28. def test_from_missing_name(self):
  29. DataHandler.register_new_handler('test_varchar1', Varchar)
  30. DataHandler.register_new_handler('test_varchar2', Varchar)
  31. try:
  32. DataHandler.from_name('test_varchar3')
  33. except Exception as err:
  34. self.assertEqual(NameError, type(err))