Skip to content

Commit

Permalink
Increase the test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ale-rt committed Apr 22, 2018
1 parent 0527e3e commit 98e0ff7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Products/PluginIndexes/tests/test_unindex.py
Expand Up @@ -17,6 +17,8 @@
from OFS.SimpleItem import SimpleItem
from Testing.makerequest import makerequest

from Products.ZCatalog.query import IndexQuery


class TestUnIndex(unittest.TestCase):

Expand Down Expand Up @@ -164,3 +166,30 @@ class Dummy(object):
# clear changes the index
index.clear()
self.assertEqual(index.getCounter(), 3)

def test_no_type_error(self):
''' Check that on Python 3.6 we do not get a TypeError when trying
to query an index with a key that has an invalid type
'''
index = self._makeOne('counter')

class Dummy(object):
id = 1
counter = 'test'

obj = Dummy()
index.index_object(obj.id, obj)

# With the right query we can find the object
query = IndexQuery({'counter': 'test'}, 'counter')
res = index.query_index(query)
self.assertListEqual(list(res), [1])

# If the type is not the expected one we cannot
query = IndexQuery({'counter': None}, 'counter')
res = index.query_index(query)
self.assertListEqual(list(res), [])

query = IndexQuery({'counter': 42}, 'counter')
res = index.query_index(query)
self.assertListEqual(list(res), [])

0 comments on commit 98e0ff7

Please sign in to comment.