Browse Source

Update _LeClass __init__ + first test for LeRel2Type

Yann Weber 9 years ago
parent
commit
b54e46a09b
2 changed files with 46 additions and 4 deletions
  1. 2
    2
      leapi/leclass.py
  2. 44
    2
      leapi/test/test_lerelation.py

+ 2
- 2
leapi/leclass.py View File

22
     ## @brief Instanciate a new LeClass
22
     ## @brief Instanciate a new LeClass
23
     # @note Abstract method
23
     # @note Abstract method
24
     # @param **kwargs
24
     # @param **kwargs
25
-    def __init__(self, **kwargs):
26
-        raise NotImplementedError("Abstract class")
25
+    def __init__(self, lodel_id, **kwargs):
26
+        _LeObject.__init__(self, lodel_id, **kwargs)
27
 
27
 
28
     @classmethod
28
     @classmethod
29
     def fieldtypes(cls):
29
     def fieldtypes(cls):

+ 44
- 2
leapi/test/test_lerelation.py View File

171
         
171
         
172
     
172
     
173
     @unittest.skip("Wait for LeRelation.update() to unskip")
173
     @unittest.skip("Wait for LeRelation.update() to unskip")
174
-    @patch('leapi.datasources.dummy.DummyDatasource.insert')
174
+    @patch('leapi.datasources.dummy.DummyDatasource.update')
175
     def test_update(self, dsmock):
175
     def test_update(self, dsmock):
176
         """ test LeHierach update method"""
176
         """ test LeHierach update method"""
177
         from dyncode import LeHierarch
177
         from dyncode import LeHierarch
181
     
181
     
182
 
182
 
183
 class LeRel2TypeTestCase(LeRelationTestCase):
183
 class LeRel2TypeTestCase(LeRelationTestCase):
184
-    pass
184
+    
185
+    @unittest.skip("Wait implementation to unskip")
186
+    @patch('leapi.datasources.dummy.DummyDatasource.insert')
187
+    def test_insert(self, dsmock):
188
+        """ test LeHierach update method"""
189
+        from dyncode import LeObject, Article, Textes, Personne, Personnes, LeHierarch, LeRel2Type, Rel_textes2personne
190
+
191
+        queries = [
192
+            {
193
+                'lesup': Article(42),
194
+                'lesub': Personne(24),
195
+                'adresse': None,
196
+            },
197
+            {
198
+                'lesup': Textes(42),
199
+                'lesub': Personne(24),
200
+                'adresse': None,
201
+            },
202
+            {
203
+                'lesup': 42,
204
+                'lesub': Personne(24),
205
+                'adresse': None,
206
+            },
207
+
208
+            {
209
+                'lesup': Article(42),
210
+                'lesub': Personnes(24),
211
+                'adresse': "bar",
212
+            },
213
+            {
214
+                'lesup': Textes(42),
215
+                'lesub': Personnes(24),
216
+                'adresse': "foo",
217
+            },
218
+        ]
219
+
220
+        for query in queries:
221
+            Rel_textes2personne.insert(query)
222
+
223
+            eres = {'nature': None}
224
+            eres.uopdate(query)
225
+
226
+            dsmock.assert_called_once_with(Rel_textes2personne, **eres)
185
 
227
 

Loading…
Cancel
Save