|
@@ -70,6 +70,42 @@ class EmClassTestCase(unittest.TestCase):
|
70
|
70
|
field.uid = 'test field.'
|
71
|
71
|
self.assertNotEqual(field.d_hash(), e_hash)
|
72
|
72
|
|
|
73
|
+ def test_field_override(self):
|
|
74
|
+ """ Test EmClass field overriding in inheritance """
|
|
75
|
+ cls1 = EmClass('testClass', 'test class')
|
|
76
|
+ cls1.new_field('test', data_handler = 'varchar', max_length = 8)
|
|
77
|
+ cls1.new_field('test2', data_handler = 'integer', nullable = True)
|
|
78
|
+
|
|
79
|
+ cls2 = EmClass('testClass2', parents = cls1)
|
|
80
|
+ cls2.new_field('test', data_handler = 'varchar', max_length = 16)
|
|
81
|
+ cls2.new_field('test2', data_handler = 'integer', nullable = False)
|
|
82
|
+
|
|
83
|
+ self.assertEqual(len(cls1.fields()), len(cls2.fields()))
|
|
84
|
+ self.assertEqual(cls1.fields('test').data_handler_options['max_length'], 8)
|
|
85
|
+ self.assertEqual(cls2.fields('test').data_handler_options['max_length'], 16)
|
|
86
|
+
|
|
87
|
+ ## @todo add more test when data handlers implements compatibility checks
|
|
88
|
+ def test_field_invalid_type_override(self):
|
|
89
|
+ """ Testing invalid fields overriding (incompatible data_handler)"""
|
|
90
|
+ cls1 = EmClass('testClass', 'test class')
|
|
91
|
+ cls1.new_field('test', data_handler = 'varchar', max_length = 8)
|
|
92
|
+ cls1.new_field('test2', data_handler = 'integer', nullable = True)
|
|
93
|
+
|
|
94
|
+ cls2 = EmClass('testClass2', parents = cls1)
|
|
95
|
+ with self.assertRaises(AttributeError):
|
|
96
|
+ cls2.new_field('test', data_handler = 'integer')
|
|
97
|
+
|
|
98
|
+ @unittest.skip("Wait for data handlers to implements a method to check options compatibility")
|
|
99
|
+ def test_field_invalid_options_overrid(self):
|
|
100
|
+ """ Testing invalid fields overriding (incompatible data handler options) """
|
|
101
|
+ cls1 = EmClass('testClass', 'test class')
|
|
102
|
+ cls1.new_field('test', data_handler = 'varchar', max_length = 8)
|
|
103
|
+ cls1.new_field('test2', data_handler = 'integer', nullable = True)
|
|
104
|
+
|
|
105
|
+ cls2 = EmClass('testClass2', parents = cls1)
|
|
106
|
+ with self.assertRaises(AttributeError):
|
|
107
|
+ cls2.new_field('test', data_handler = 'varchar', max_length = 2)
|
|
108
|
+
|
73
|
109
|
class EmGroupTestCase(unittest.TestCase):
|
74
|
110
|
|
75
|
111
|
def test_init(self):
|