コード例 #1
0
ファイル: test_exportimport.py プロジェクト: bendavis78/zope
    def setUp(self):
        from Products.PluginIndexes.DateRangeIndex.DateRangeIndex \
                import DateRangeIndex

        NodeAdapterTestCase.setUp(self)
        self._obj = DateRangeIndex('foo_daterange')
        self._XML = _DATERANGE_XML
コード例 #2
0
 def test_DateRangeIndex(self):
     from xml.dom.minidom import parseString
     from Products.PluginIndexes.DateRangeIndex.DateRangeIndex \
             import DateRangeIndex
     from Products.GenericSetup.testing import DummySetupEnviron
     from Products.GenericSetup.PluginIndexes.exportimport \
             import DateRangeIndexNodeAdapter
     environ = DummySetupEnviron()
     def _no_clear(*a):
         raise AssertionError("Don't clear me!")
     index = DateRangeIndex('foo_daterange')
     index._since_field = 'bar'
     index._until_field = 'baz'
     index.clear = _no_clear 
     adapted = DateRangeIndexNodeAdapter(index, environ)
     adapted.node = parseString(_DATERANGE_XML).documentElement # no raise
コード例 #3
0
    def test_DateRangeIndex(self):
        from xml.dom.minidom import parseString
        from Products.PluginIndexes.DateRangeIndex.DateRangeIndex \
                import DateRangeIndex
        from Products.GenericSetup.testing import DummySetupEnviron
        from Products.GenericSetup.PluginIndexes.exportimport \
                import DateRangeIndexNodeAdapter
        environ = DummySetupEnviron()

        def _no_clear(*a):
            raise AssertionError("Don't clear me!")

        index = DateRangeIndex('foo_daterange')
        index._since_field = 'bar'
        index._until_field = 'baz'
        index.clear = _no_clear
        adapted = DateRangeIndexNodeAdapter(index, environ)
        adapted.node = parseString(_DATERANGE_XML).documentElement  # no raise
コード例 #4
0
    def setUp(self):
        from Products.PluginIndexes.DateRangeIndex.DateRangeIndex \
                import DateRangeIndex

        PlacelessSetup.setUp(self)
        zcml.load_config('meta.zcml', Products.Five)
        zcml.load_config('configure.zcml', Products.GenericSetup.PluginIndexes)

        self._obj = DateRangeIndex('foo_daterange')
        self._XML = _DATERANGE_XML
コード例 #5
0
    def setUp(self):
        import Products.GenericSetup.PluginIndexes
        from Products.PluginIndexes.DateRangeIndex.DateRangeIndex \
                import DateRangeIndex

        NodeAdapterTestCase.setUp(self)
        zcml.load_config('configure.zcml', Products.GenericSetup.PluginIndexes)

        self._obj = DateRangeIndex('foo_daterange')
        self._XML = _DATERANGE_XML
コード例 #6
0
 def _make_catalog(self):
     zcat = ZCatalog('catalog')
     zcat._catalog.addIndex('big', BooleanIndex('big'))
     zcat._catalog.addIndex('date', DateRangeIndex('date', 'start', 'end'))
     zcat._catalog.addIndex('num', FieldIndex('num'))
     zcat._catalog.addIndex('numbers', KeywordIndex('numbers'))
     zcat._catalog.addIndex('path', PathIndex('getPhysicalPath'))
     zcat._catalog.addIndex('uuid', UUIDIndex('num'))
     for i in range(9):
         obj = Dummy(i)
         zcat.catalog_object(obj, str(i))
     return zcat
コード例 #7
0
    def test_empty( self ):

        empty = DateRangeIndex( 'empty' )

        assert empty.getEntryForObject( 1234 ) is None
        empty.unindex_object( 1234 ) # shouldn't throw

        assert not empty.uniqueValues( 'foo' )
        assert not empty.uniqueValues( 'foo', 1 )

        assert empty._apply_index( { 'zed' : 12345 } ) is None

        result, used = empty._apply_index( { 'empty' : 12345 } )

        assert not result
        assert used == ( None, None )
コード例 #8
0
 def _make_catalog(self):
     from Products.PluginIndexes.BooleanIndex.BooleanIndex import \
         BooleanIndex
     from Products.PluginIndexes.DateRangeIndex.DateRangeIndex import \
         DateRangeIndex
     from Products.PluginIndexes.FieldIndex.FieldIndex import FieldIndex
     from Products.PluginIndexes.KeywordIndex.KeywordIndex import \
         KeywordIndex
     from Products.PluginIndexes.PathIndex.PathIndex import PathIndex
     from Products.PluginIndexes.UUIDIndex.UUIDIndex import UUIDIndex
     from Products.ZCatalog.ZCatalog import ZCatalog
     zcat = ZCatalog('catalog')
     zcat._catalog.addIndex('big', BooleanIndex('big'))
     zcat._catalog.addIndex('date', DateRangeIndex('date', 'start', 'end'))
     zcat._catalog.addIndex('num', FieldIndex('num'))
     zcat._catalog.addIndex('numbers', KeywordIndex('numbers'))
     zcat._catalog.addIndex('path', PathIndex('getPhysicalPath'))
     zcat._catalog.addIndex('uuid', UUIDIndex('num'))
     for i in range(9):
         obj = dummy(i)
         zcat.catalog_object(obj, str(i))
     return zcat
コード例 #9
0
    def test_retrieval( self ):

        work = DateRangeIndex( 'work', 'start', 'stop' )

        for i in range( len( dummies ) ):
            work.index_object( i, dummies[i] )

        for i in range( len( dummies ) ):
            assert work.getEntryForObject( i ) == dummies[i].datum()

        for value in range( -1, 15 ):

            matches = matchingDummies( value )
            results, used = work._apply_index( { 'work' : value } )
            assert used == ( 'start', 'stop' )

            assert len( matches ) == len( results ), ( '%s: %s == %s'
               % ( value, map( lambda x: x.name(), matches ), results ) )

            matches.sort( lambda x, y: cmp( x.name(), y.name() ) )

            for result, match in map( None, results, matches ):
                assert work.getEntryForObject( result ) == match.datum()
コード例 #10
0
 def unindex_object( self, documentId ):
     for lang in self.languages:
         self._v_lang = lang
         DateRangeIndex.unindex_object(self, documentId)
     self._v_lang = None
コード例 #11
0
 def setUp(self):
     from Products.PluginIndexes.DateRangeIndex.DateRangeIndex import \
         DateRangeIndex
     self._obj = DateRangeIndex('foo_daterange')
     self._XML = _DATERANGE_XML
コード例 #12
0
 def _badlong(self):
     work = DateRangeIndex ('work', 'start', 'stop' )
     bad = Dummy( 'bad', long(sys.maxint) + 1, long(sys.maxint) + 1 )
     work.index_object( 0, bad )
コード例 #13
0
 def unindex_object(self, documentId):
     for lang in self.languages:
         self._v_lang = lang
         DateRangeIndex.unindex_object(self, documentId)
     self._v_lang = None