|
@@ -1,6 +1,7 @@
|
1
|
1
|
import unittest
|
2
|
2
|
|
3
|
3
|
from lodel.leapi.datahandlers.base_classes import DataHandler
|
|
4
|
+from lodel.leapi.datahandlers.datas import Varchar
|
4
|
5
|
|
5
|
6
|
|
6
|
7
|
class DataHandlerTestCase(unittest.TestCase):
|
|
@@ -12,4 +13,20 @@ class DataHandlerTestCase(unittest.TestCase):
|
12
|
13
|
except NotImplementedError:
|
13
|
14
|
self.assertNotIsInstance(datahandler, DataHandler)
|
14
|
15
|
self.assertIsNone(datahandler)
|
15
|
|
-
|
|
16
|
+
|
|
17
|
+ def test_register_new_handler(self):
|
|
18
|
+ DataHandler.register_new_handler('testvarchar', Varchar)
|
|
19
|
+ self.assertEqual(DataHandler.from_name('testvarchar'), Varchar)
|
|
20
|
+
|
|
21
|
+ def test_register_nonclass_as_handler(self):
|
|
22
|
+ try:
|
|
23
|
+ DataHandler.register_new_handler('testvarchar', 'common string')
|
|
24
|
+ except Exception as err:
|
|
25
|
+ self.assertEqual(ValueError, type(err))
|
|
26
|
+
|
|
27
|
+ def test_register_invalid_class_as_handler(self):
|
|
28
|
+
|
|
29
|
+ try:
|
|
30
|
+ DataHandler.register_new_handler('testvarchar', Exception)
|
|
31
|
+ except Exception as err:
|
|
32
|
+ self.assertEqual(ValueError, type(err))
|