Browse Source

Bugfixes in LeGetQuery + more tests on LeObject.get <-> LeGetQuery

Yann Weber 8 years ago
parent
commit
c6334f903f
3 changed files with 28 additions and 4 deletions
  1. 3
    3
      lodel/leapi/query.py
  2. 0
    1
      runtest
  3. 25
    0
      tests/leapi/test_leobject.py

+ 3
- 3
lodel/leapi/query.py View File

@@ -528,7 +528,7 @@ target to LeUpdateQuery constructor"
528 528
     #@returns the number of updated items
529 529
     #@todo change stategy for instance update. Datas should be allowed 
530 530
     #for execute method (and query)
531
-    def _query(self, filters, rel_filters, datas):
531
+    def _query(self, datas):
532 532
         uid_name = self._target_class._uid[0]
533 533
         if self.__leobject_instance is not None:
534 534
             #Instance update
@@ -629,7 +629,7 @@ class LeGetQuery(LeFilteredQuery):
629 629
         if 'group' in kwargs:
630 630
             #check kwargs['group']
631 631
             self.__group = kwargs['group']
632
-        if 'limit' in kwargs:
632
+        if 'limit' in kwargs and kwargs['limit'] is not None:
633 633
             try:
634 634
                 self.__limit = int(kwargs['limit'])
635 635
                 if self.__limit <= 0:
@@ -670,7 +670,7 @@ class LeGetQuery(LeFilteredQuery):
670 670
 
671 671
     ##@brief Implements select query operations
672 672
     # @returns a list containing the item(s)
673
-    def _query(self):
673
+    def _query(self, datas = None):
674 674
         # select datas corresponding to query_filter
675 675
         l_datas=self._ro_datasource.select(  self._target_class,
676 676
                                     list(self.field_list),

+ 0
- 1
runtest View File

@@ -54,7 +54,6 @@ cp -R tests $testdir
54 54
 cd $testdir
55 55
 rm -R conf.d && mv tests/tests_conf.d conf.d
56 56
 make
57
-#python3 -W ignore -m unittest $@
58 57
 python3 loader.py $@
59 58
 
60 59
 rm -Rf $testdir

+ 25
- 0
tests/leapi/test_leobject.py View File

@@ -243,3 +243,28 @@ class LeObjectQueryMockTestCase(unittest.TestCase):
243 243
             self.assertEqual(res.d.lodel_id, 1)
244 244
             self.assertEqual(res.d.firstname, 'foo')
245 245
             self.assertEqual(res.d.lastname, 'bar')
246
+
247
+    def test_get_mini(self):
248
+        """ Checking that LeObject.get method calls LeGetQuery correctly
249
+            when called with minimum args """
250
+            
251
+        with patch.object(
252
+            LeGetQuery, '__init__', return_value = None) as mock_init:
253
+        
254
+            try:
255
+                dyncode.Person.get(['lodel_id = 1'])
256
+            except AttributeError:
257
+                pass
258
+            
259
+            mock_init.assert_called_once_with(
260
+                dyncode.Person,
261
+                query_filters = ['lodel_id = 1'],
262
+                field_list = dyncode.Person.fieldnames(True),
263
+                order = None, group = None, limit = None, offset = 0)
264
+
265
+        with patch.object(
266
+            LeGetQuery, 'execute', return_value = []) as mock_exec:
267
+            
268
+            dyncode.Person.get(['lodel_id = 1'])
269
+            mock_exec.assert_called_once_with()
270
+

Loading…
Cancel
Save