[CMF-checkins] CVS: Products/CMFTopic/tests - test_ListC.py:1.6.10.1

Tres Seaver tseaver@zope.com
Mon, 7 Jan 2002 14:34:27 -0500


Update of /cvs-repository/Products/CMFTopic/tests
In directory cvs.zope.org:/tmp/cvs-serv23591/CMFTopic/tests

Modified Files:
      Tag: tseaver-listcrit_operator-branch
	test_ListC.py 
Log Message:


  - Add 'operator' attribute to ListCriterion, to permit overriding the
    implicit 'or' operator used for keyword indexes such as 'Subject'.


=== Products/CMFTopic/tests/test_ListC.py 1.6 => 1.6.10.1 ===
 
         items = listc.getCriteriaItems()
-        self.assertEqual( items[0][1], tuple( abc ) )
+        self.failUnless( 'foofield' in map( lambda x: x[0], items ) )
+        self.failUnless( tuple( abc ) in map( lambda x: x[1], items ) )
+
+    def test_operator( self ):
+
+        from Products.CMFTopic.ListCriterion import ListCriterion
+        listc = ListCriterion( 'foo', 'foofield' )
+
+        abc = [ 'a', 'b', 'c' ]
+
+        listc.edit( abc )
+        items = listc.getCriteriaItems()
+        self.assertEqual( len( items ), 1 )
+
+        listc.edit( abc, 'or' )
+        items = listc.getCriteriaItems()
+        self.assertEqual( len( items ), 2 )
+        self.failUnless( ( 'foofield_operator', 'or' ) in items )
+
+        listc.edit( abc, 'and' )
+        items = listc.getCriteriaItems()
+        self.assertEqual( len( items ), 2 )
+        self.failUnless( ( 'foofield_operator', 'and' ) in items )
 
 def test_suite():
     return unittest.makeSuite( ListCriterionTests )