소스 검색

Changed the EmField override check in EmClass + updated tests

Yann Weber 8 년 전
부모
커밋
9fb87ec0ec
2개의 변경된 파일5개의 추가작업 그리고 6개의 파일을 삭제
  1. 1
    1
      lodel/editorial_model/components.py
  2. 4
    5
      tests/editorial_model/test_model.py

+ 1
- 1
lodel/editorial_model/components.py 파일 보기

@@ -100,7 +100,7 @@ class EmClass(EmComponent):
100 100
         # Incomplete field override check
101 101
         if emfield.uid in self.__all_fields:
102 102
             parent_field = self.__all_fields[emfield.uid]
103
-            if emfield.data_handler_name != parent_field.data_handler_name:
103
+            if not emfield.data_handler_instance.can_override(parent_field.data_handler_instance):
104 104
                 raise AttributeError("'%s' field override a parent field, but data_handles are not compatible" % emfield.uid)
105 105
         self.__fields[emfield.uid] = emfield
106 106
         emfield._emclass = self

+ 4
- 5
tests/editorial_model/test_model.py 파일 보기

@@ -73,16 +73,16 @@ class EmClassTestCase(unittest.TestCase):
73 73
     def test_field_override(self):
74 74
         """ Test EmClass field overriding in inheritance """
75 75
         cls1 = EmClass('testClass', 'test class')
76
-        cls1.new_field('test', data_handler = 'varchar', max_length = 8)
76
+        cls1.new_field('test', data_handler = 'varchar', max_length = 16, nullable=True)
77 77
         cls1.new_field('test2', data_handler = 'integer', nullable = True)
78 78
 
79 79
         cls2 = EmClass('testClass2', parents = cls1)
80
-        cls2.new_field('test', data_handler = 'varchar', max_length = 16)
80
+        cls2.new_field('test', data_handler = 'varchar', max_length = 16, nullable=False)
81 81
         cls2.new_field('test2', data_handler = 'integer', nullable = False)
82 82
 
83 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)
84
+        self.assertTrue(cls1.fields('test').data_handler_options['nullable'])
85
+        self.assertFalse(cls2.fields('test').data_handler_options['nullable'])
86 86
 
87 87
     ## @todo add more test when data handlers implements compatibility checks
88 88
     def test_field_invalid_type_override(self):
@@ -95,7 +95,6 @@ class EmClassTestCase(unittest.TestCase):
95 95
         with self.assertRaises(AttributeError):
96 96
             cls2.new_field('test', data_handler = 'integer')
97 97
 
98
-    @unittest.skip("Wait for data handlers to implements a method to check options compatibility")
99 98
     def test_field_invalid_options_overrid(self):
100 99
         """ Testing invalid fields overriding (incompatible data handler options) """
101 100
         cls1 = EmClass('testClass', 'test class')

Loading…
취소
저장