mirror of
https://github.com/yweber/lodel2.git
synced 2026-04-09 11:49:58 +02:00
Bugfixes in LeGetQuery + more tests on LeObject.get <-> LeGetQuery
This commit is contained in:
parent
df8e38d9a9
commit
c6334f903f
3 changed files with 28 additions and 4 deletions
|
|
@ -528,7 +528,7 @@ target to LeUpdateQuery constructor"
|
|||
#@returns the number of updated items
|
||||
#@todo change stategy for instance update. Datas should be allowed
|
||||
#for execute method (and query)
|
||||
def _query(self, filters, rel_filters, datas):
|
||||
def _query(self, datas):
|
||||
uid_name = self._target_class._uid[0]
|
||||
if self.__leobject_instance is not None:
|
||||
#Instance update
|
||||
|
|
@ -629,7 +629,7 @@ class LeGetQuery(LeFilteredQuery):
|
|||
if 'group' in kwargs:
|
||||
#check kwargs['group']
|
||||
self.__group = kwargs['group']
|
||||
if 'limit' in kwargs:
|
||||
if 'limit' in kwargs and kwargs['limit'] is not None:
|
||||
try:
|
||||
self.__limit = int(kwargs['limit'])
|
||||
if self.__limit <= 0:
|
||||
|
|
@ -670,7 +670,7 @@ class LeGetQuery(LeFilteredQuery):
|
|||
|
||||
##@brief Implements select query operations
|
||||
# @returns a list containing the item(s)
|
||||
def _query(self):
|
||||
def _query(self, datas = None):
|
||||
# select datas corresponding to query_filter
|
||||
l_datas=self._ro_datasource.select( self._target_class,
|
||||
list(self.field_list),
|
||||
|
|
|
|||
1
runtest
1
runtest
|
|
@ -54,7 +54,6 @@ cp -R tests $testdir
|
|||
cd $testdir
|
||||
rm -R conf.d && mv tests/tests_conf.d conf.d
|
||||
make
|
||||
#python3 -W ignore -m unittest $@
|
||||
python3 loader.py $@
|
||||
|
||||
rm -Rf $testdir
|
||||
|
|
|
|||
|
|
@ -243,3 +243,28 @@ class LeObjectQueryMockTestCase(unittest.TestCase):
|
|||
self.assertEqual(res.d.lodel_id, 1)
|
||||
self.assertEqual(res.d.firstname, 'foo')
|
||||
self.assertEqual(res.d.lastname, 'bar')
|
||||
|
||||
def test_get_mini(self):
|
||||
""" Checking that LeObject.get method calls LeGetQuery correctly
|
||||
when called with minimum args """
|
||||
|
||||
with patch.object(
|
||||
LeGetQuery, '__init__', return_value = None) as mock_init:
|
||||
|
||||
try:
|
||||
dyncode.Person.get(['lodel_id = 1'])
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
mock_init.assert_called_once_with(
|
||||
dyncode.Person,
|
||||
query_filters = ['lodel_id = 1'],
|
||||
field_list = dyncode.Person.fieldnames(True),
|
||||
order = None, group = None, limit = None, offset = 0)
|
||||
|
||||
with patch.object(
|
||||
LeGetQuery, 'execute', return_value = []) as mock_exec:
|
||||
|
||||
dyncode.Person.get(['lodel_id = 1'])
|
||||
mock_exec.assert_called_once_with()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue