[Checkins] SVN: zope.index/trunk/src/zope/index/text/tests/test_ Add test modules for improving coverage of text index implementations.
Tres Seaver
tseaver at palladion.com
Wed Jun 10 14:14:54 EDT 2009
Log message for revision 100807:
Add test modules for improving coverage of text index implementations.
Changed:
A zope.index/trunk/src/zope/index/text/tests/test_cosine.py
A zope.index/trunk/src/zope/index/text/tests/test_okapi.py
-=-
Added: zope.index/trunk/src/zope/index/text/tests/test_cosine.py
===================================================================
--- zope.index/trunk/src/zope/index/text/tests/test_cosine.py (rev 0)
+++ zope.index/trunk/src/zope/index/text/tests/test_cosine.py 2009-06-10 18:14:53 UTC (rev 100807)
@@ -0,0 +1,78 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Text Index Tests
+
+$Id: test_index.py 100805 2009-06-10 17:58:58Z tseaver $
+"""
+import unittest
+
+class CosineIndexTestBase:
+ # Subclasses must define '_getBTreesFamily'
+ def _getTargetClass(self):
+ from zope.index.text.cosineindex import CosineIndex
+ return CosineIndex
+
+ def _makeOne(self):
+ from zope.index.text.lexicon import Lexicon
+ from zope.index.text.lexicon import Splitter
+ lexicon = Lexicon(Splitter())
+ return self._getTargetClass()(lexicon, family=self._getBTreesFamily())
+
+ def test_class_conforms_to_IInjection(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.interfaces import IInjection
+ verifyClass(IInjection, self._getTargetClass())
+
+ def test_instance_conforms_to_IInjection(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.interfaces import IInjection
+ verifyObject(IInjection, self._makeOne())
+
+ def test_class_conforms_to_IStatistics(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.interfaces import IStatistics
+ verifyClass(IStatistics, self._getTargetClass())
+
+ def test_instance_conforms_to_IStatistics(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.interfaces import IStatistics
+ verifyObject(IStatistics, self._makeOne())
+
+ def test_class_conforms_to_IExtendedQuerying(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.text.interfaces import IExtendedQuerying
+ verifyClass(IExtendedQuerying, self._getTargetClass())
+
+ def test_instance_conforms_to_IExtendedQuerying(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.text.interfaces import IExtendedQuerying
+ verifyObject(IExtendedQuerying, self._makeOne())
+
+class CosineIndexTest32(CosineIndexTestBase, unittest.TestCase):
+
+ def _getBTreesFamily(self):
+ import BTrees
+ return BTrees.family32
+
+class CosineIndexTest64(CosineIndexTestBase, unittest.TestCase):
+
+ def _getBTreesFamily(self):
+ import BTrees
+ return BTrees.family64
+
+def test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(CosineIndexTest32),
+ unittest.makeSuite(CosineIndexTest64),
+ ))
Added: zope.index/trunk/src/zope/index/text/tests/test_okapi.py
===================================================================
--- zope.index/trunk/src/zope/index/text/tests/test_okapi.py (rev 0)
+++ zope.index/trunk/src/zope/index/text/tests/test_okapi.py 2009-06-10 18:14:53 UTC (rev 100807)
@@ -0,0 +1,80 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Okapi text index tests
+"""
+import unittest
+
+class OkapiIndexTestBase:
+ # Subclasses must define '_getBTreesFamily'
+ def _getTargetClass(self):
+ from zope.index.text.okapiindex import OkapiIndex
+ return OkapiIndex
+
+ def _makeOne(self):
+ from zope.index.text.lexicon import Lexicon
+ from zope.index.text.lexicon import Splitter
+ lexicon = Lexicon(Splitter())
+ return self._getTargetClass()(lexicon, family=self._getBTreesFamily())
+
+ def test_class_conforms_to_IInjection(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.interfaces import IInjection
+ verifyClass(IInjection, self._getTargetClass())
+
+ def test_instance_conforms_to_IInjection(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.interfaces import IInjection
+ verifyObject(IInjection, self._makeOne())
+
+ def test_class_conforms_to_IStatistics(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.interfaces import IStatistics
+ verifyClass(IStatistics, self._getTargetClass())
+
+ def test_instance_conforms_to_IStatistics(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.interfaces import IStatistics
+ verifyObject(IStatistics, self._makeOne())
+
+ def test_class_conforms_to_IExtendedQuerying(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.text.interfaces import IExtendedQuerying
+ verifyClass(IExtendedQuerying, self._getTargetClass())
+
+ def test_instance_conforms_to_IExtendedQuerying(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.text.interfaces import IExtendedQuerying
+ verifyObject(IExtendedQuerying, self._makeOne())
+
+ def test_empty(self):
+ index = self._makeOne()
+ self.assertEqual(index._totaldoclen(), 0)
+
+class OkapiIndexTest32(OkapiIndexTestBase, unittest.TestCase):
+
+ def _getBTreesFamily(self):
+ import BTrees
+ return BTrees.family32
+
+class OkapiIndexTest64(OkapiIndexTestBase, unittest.TestCase):
+
+ def _getBTreesFamily(self):
+ import BTrees
+ return BTrees.family64
+
+def test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(OkapiIndexTest32),
+ unittest.makeSuite(OkapiIndexTest64),
+ ))
More information about the Checkins
mailing list