Açıklama Yok
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.2KB

12345678910111213141516171819202122232425262728293031323334353637
  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)