[CMF-checkins] CVS: CMF/CMFTopic/tests - test_SortC.py:1.1.4.1 test_DateC.py:1.5.8.1 test_ListC.py:1.5.8.1 test_SIC.py:1.5.8.1 test_SSC.py:1.5.8.1 test_Topic.py:1.8.4.1

Tres Seaver tseaver@zope.com
Thu, 20 Dec 2001 16:05:00 -0500


Update of /cvs-repository/CMF/CMFTopic/tests
In directory cvs.zope.org:/tmp/cvs-serv32529/CMFTopic/tests

Modified Files:
      Tag: CMF-1_2-branch
	test_DateC.py test_ListC.py test_SIC.py test_SSC.py 
	test_Topic.py 
Added Files:
      Tag: CMF-1_2-branch
	test_SortC.py 
Log Message:
 - Merge changes from tseaver-tracker_439-branch.

=== Added File CMF/CMFTopic/tests/test_SortC.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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
# 
##############################################################################
"""Unit tests for SortCriterion module.

$Id: test_SortC.py,v 1.1.4.1 2001/12/20 21:04:59 tseaver Exp $
"""
__version__ = '$Revision: 1.1.4.1 $'[11:-2]

import unittest

class SortCriterionTests( unittest.TestCase ):

    def test_Interface( self ):
        from Products.CMFTopic.interfaces import Criterion
        from Products.CMFTopic.SortCriterion import SortCriterion
        self.failUnless(
            Criterion.isImplementedByInstancesOf( SortCriterion ) )
    
    def test_Empty( self ):

        from Products.CMFTopic.SortCriterion import SortCriterion
        ssc = SortCriterion( 'foo', 'foofield' )

        self.assertEqual( ssc.getId(), 'foo' )
        self.assertEqual( ssc.field, None )
        self.assertEqual( ssc.index, 'foofield' )
        self.assertEqual( ssc.Field(), 'foofield' )
        self.assertEqual( ssc.reversed, 0 )

        items = ssc.getCriteriaItems()
        self.assertEqual( len( items ), 1 )
        self.assertEqual( items[0][0], 'sort_on' )
        self.assertEqual( items[0][1], 'foofield' )
    
    def test_Nonempty( self ):

        from Products.CMFTopic.SortCriterion import SortCriterion
        ssc = SortCriterion( 'foo', 'foofield' )

        ssc.edit( 1 )

        self.assertEqual( ssc.getId(), 'foo' )
        self.assertEqual( ssc.field, None )
        self.assertEqual( ssc.index, 'foofield' )
        self.assertEqual( ssc.Field(), 'foofield' )
        self.assertEqual( ssc.reversed, 1 )

        items = ssc.getCriteriaItems()
        self.assertEqual( len( items ), 2 )
        self.assertEqual( items[0][0], 'sort_on' )
        self.assertEqual( items[0][1], 'foofield' )
        self.assertEqual( items[1][0], 'sort_order' )
        self.assertEqual( items[1][1], 'reverse' )

def test_suite():
    return unittest.makeSuite( SortCriterionTests )

def main():
    unittest.TextTestRunner().run( test_suite() )

if __name__ == '__main__':
    main()
    


=== CMF/CMFTopic/tests/test_DateC.py 1.5 => 1.5.8.1 ===
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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
+# 
+##############################################################################
+"""Unit tests for DateCriterion module.
+
+$Id$
+"""
+__version__ = '$Revision$'[11:-2]
+
 import unittest
-import Products.CMFTopic.DateCriteria
 from DateTime.DateTime import DateTime
 
-FriendlyDate = Products.CMFTopic.DateCriteria.FriendlyDateCriterion
+class FriendlyDateCriterionTests( unittest.TestCase ):
+
+    lessThanFiveDaysOld = { 'value': 4
+                          , 'operation': 'min'
+                          , 'daterange': 'old'
+                          }
+
+    lessThanOneMonthAhead = { 'value': 30
+                            , 'operation': 'max'
+                            , 'daterange': 'ahead'
+                            }
+
+    def test_Interface( self ):
+        from Products.CMFTopic.interfaces import Criterion
+        from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
+        self.failUnless(
+            Criterion.isImplementedByInstancesOf( FriendlyDateCriterion ) )
+
+    def test_Empty( self ):
+
+        from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
+        friendly = FriendlyDateCriterion( 'foo', 'foofield' )
+
+        self.assertEqual( friendly.getId(), 'foo' )
+        self.assertEqual( friendly.field, 'foofield' )
+        self.assertEqual( friendly.value, None )
+        self.assertEqual( friendly.operation, 'min' )
+        self.assertEqual( friendly.daterange, 'old' )
+        self.assertEqual( len( friendly.getCriteriaItems() ), 0 )
+
+    def test_ListOfDefaultDates( self ):
 
-class TestFriendlyDate(unittest.TestCase):
-    lessThanFiveDaysOld = {
-        'value': 4,
-        'operation': 'min',
-        'daterange': 'old',
-        }
-
-    lessThanOneMonthAhead = {
-        'value': 30,
-        'operation': 'max',
-        'daterange': 'ahead',
-        }
-
-    def setUp( self ):
-        get_transaction().begin()
-
-    def tearDown( self ):
-        get_transaction().abort()
-
-    def test_Empty(self):
-        friendly = FriendlyDate('foo', 'foofield')
-        assert friendly.getId() == 'foo'
-        assert friendly.field == 'foofield'
-        assert friendly.value == None, 'Value should be None'
-        assert friendly.operation == 'min', 'Operator should be min'
-        assert friendly.daterange == 'old'
-        assert len(friendly.getCriteriaItems()) == 0
+        from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
+        friendly = FriendlyDateCriterion( 'foo', 'foofield' )
 
-    def test_ListOfDefaultDates(self):
-        friendly = FriendlyDate('foo','foofield')
         d = friendly.defaultDateOptions()
-        assert d[1][0] == 2, 'Expected 2, got %s' % d[1][0]
+        self.assertEqual( d[1][0], 2 )
+
+    def test_Clear( self ):
+
+        from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
+        friendly = FriendlyDateCriterion( 'foo', 'foofield' )
+
+        friendly.edit( value=None )
+        self.assertEqual( friendly.value, None )
+        self.assertEqual( friendly.operation, 'min' )
+        self.assertEqual( friendly.daterange, 'old' )
 
-    def test_Basic(self):
-        friendly = FriendlyDate('foo', 'foofield')
-        friendly.edit(value=None)
-        assert friendly.value == None
-        assert friendly.daterange == 'old'
-        assert friendly.operation == 'min'
+    def test_Basic( self ):
+
+        from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
+        friendly = FriendlyDateCriterion( 'foo', 'foofield' )
         
-        apply(friendly.edit, (), self.lessThanFiveDaysOld)
-        assert friendly.value == 4
-        assert friendly.operation == 'min'
-        assert friendly.daterange == 'old'
-
-        # Bogus value on the operation
-        self.assertRaises(ValueError, friendly.edit, 4, 'min:max', 'new')
-
-    def test_StringAsValue(self):
-        friendly = FriendlyDate('foo', 'foofield')
-        friendly.edit('4')
-        assert friendly.value == 4
-
-        friendly.edit('-4')
-        assert friendly.value == -4
-
-        friendly.edit('')
-        assert friendly.value is None
-
-        # Bogus value on the, well, value
-        self.assertRaises(ValueError, friendly.edit, 'blah')
-
-    def test_FiveDaysOld(self):
-        date = (DateTime() - 4).Date()
-        friendly = FriendlyDate('foo', 'foofield')
-        apply(friendly.edit, (), self.lessThanFiveDaysOld)
+        friendly.apply( self.lessThanFiveDaysOld )
+        self.assertEqual( friendly.value, 4 )
+        self.assertEqual( friendly.operation, 'min' )
+        self.assertEqual( friendly.daterange, 'old' )
 
-        result = friendly.getCriteriaItems()
-        assert friendly.daterange == 'old'
+    def test_BadInput( self ):
+
+        from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
+        friendly = FriendlyDateCriterion( 'foo', 'foofield' )
+
+        # Bogus value
+        self.assertRaises( ValueError, friendly.edit, 'blah' )
+
+        # Bogus operation
+        self.assertRaises( ValueError, friendly.edit, 4, 'min:max', 'old' )
+
+        # Bogus daterange
+        self.assertRaises( ValueError, friendly.edit, 4, 'max', 'new' )
+
+    def test_StringAsValue( self ):
+
+        from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
+        friendly = FriendlyDateCriterion( 'foo', 'foofield' )
+
+        friendly.edit( '4' )
+        self.assertEqual( friendly.value, 4 )
+
+        friendly.edit( '-4' )
+        self.assertEqual( friendly.value, -4 )
+
+        friendly.edit( '' )
+        self.assertEqual( friendly.value, None )
+
+    def test_FiveDaysOld( self ):
+
+        from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
+        friendly = FriendlyDateCriterion( 'foo', 'foofield' )
+
+        friendly.apply( self.lessThanFiveDaysOld )
+        self.assertEqual( friendly.daterange, 'old' )
         
-        assert len(result) == 2
-        assert result[0][0] == 'foofield'
-        assert result[0][1].Date() == date, 'Result %s not expected %s' % (
-            result[0][1].Date(), date)
-        assert result[1][0] == 'foofield_usage'
-        assert result[1][1] == 'range:min'
-
-    def test_OneMonthAhead(self):
-        date = (DateTime() + 30).Date()
-        friendly = FriendlyDate('foo', 'foofield')
-        apply(friendly.edit, (), self.lessThanOneMonthAhead)
         result = friendly.getCriteriaItems()
-        assert friendly.daterange == 'ahead'
+        self.assertEqual( len( result ), 2 )
+        self.assertEqual( result[0][0], 'foofield' )
+        self.assertEqual( result[0][1].Date(), ( DateTime() - 4 ).Date() )
+        self.assertEqual( result[1][0], 'foofield_usage' )
+        self.assertEqual( result[1][1], 'range:min' )
+
+    def test_OneMonthAhead( self ):
 
-        assert result[0][1].Date() == date, 'Result %s not expected %s' % (
-            result[0][1].Date(), date)
-        assert result[1][1] == 'range:max'
+        from Products.CMFTopic.DateCriteria import FriendlyDateCriterion
+        friendly = FriendlyDateCriterion( 'foo', 'foofield' )
+
+        friendly.apply( self.lessThanOneMonthAhead )
+        self.assertEqual( friendly.daterange, 'ahead' )
+
+        result = friendly.getCriteriaItems()
+        self.assertEqual( result[0][1].Date(), ( DateTime() + 30 ).Date() )
+        self.assertEqual( result[1][1], 'range:max' )
 
 def test_suite():
-    return unittest.makeSuite(TestFriendlyDate)
+    return unittest.makeSuite( FriendlyDateCriterionTests )
 
 def main():
-    unittest.TextTestRunner().run(test_suite())
+    unittest.TextTestRunner().run( test_suite() )
     
 if __name__ == '__main__':
     main()


=== CMF/CMFTopic/tests/test_ListC.py 1.5 => 1.5.8.1 ===
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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
+# 
+##############################################################################
+"""Unit tests for ListCriterion module.
+
+$Id$
+"""
+__version__ = '$Revision$'[11:-2]
+
 import unittest
-import Products.CMFTopic.ListCriterion
 
-LISTC = Products.CMFTopic.ListCriterion.ListCriterion
+class ListCriterionTests( unittest.TestCase ):
 
+    def test_Interface( self ):
+        from Products.CMFTopic.interfaces import Criterion
+        from Products.CMFTopic.ListCriterion import ListCriterion
+        self.failUnless(
+            Criterion.isImplementedByInstancesOf( ListCriterion ) )
 
-class TestListCriterion(unittest.TestCase):
+    def test_Empty( self ):
 
-    def setUp( self ):
-        get_transaction().begin()
+        from Products.CMFTopic.ListCriterion import ListCriterion
+        listc = ListCriterion('foo', 'foofield')
 
-    def tearDown( self ):
-        get_transaction().abort()
+        self.assertEqual( listc.getId(), 'foo' )
+        self.assertEqual( listc.field, 'foofield' )
+        self.assertEqual( listc.value, ('',) )
+        self.assertEqual( len(listc.getCriteriaItems()), 0 )
     
-    def test_Empty( self ):
-        listc = LISTC('foo', 'foofield')
-        assert listc.getId() == 'foo'
-        assert listc.field == 'foofield'
-        assert listc.value == ('',)
-        assert len(listc.getCriteriaItems()) == 0
-    
-    def test_Nonempty( self ):
-        listc = LISTC( 'foo', 'foofield' )
+    def test_Edit_withString( self ):
+
+        from Products.CMFTopic.ListCriterion import ListCriterion
+        listc = ListCriterion( 'foo', 'foofield' )
+
         listc.edit('bar\nbaz')
-        assert listc.getId() == 'foo'
-        assert listc.field == 'foofield'
-        assert listc.value == ( 'bar', 'baz' )
-        items =listc.getCriteriaItems()
-        assert len( items ) == 1
-        assert len( items[0] ) == 2
-        assert items[0][0] == 'foofield'
-        assert items[0][1] == ( 'bar', 'baz' )
+        self.assertEqual( listc.getId(), 'foo' )
+        self.assertEqual( listc.field, 'foofield' )
+        self.assertEqual( listc.value, ( 'bar', 'baz' ) )
+
+        items = listc.getCriteriaItems()
+        self.assertEqual( len( items ), 1 )
+        self.assertEqual( len( items[0] ), 2 )
+        self.assertEqual( items[0][0], 'foofield' )
+        self.assertEqual( items[0][1], ( 'bar', 'baz' ) )
+    
+    def test_Edit_withList( self ):
+
+        from Products.CMFTopic.ListCriterion import ListCriterion
+        listc = ListCriterion( 'foo', 'foofield' )
+
         abc = [ 'a', 'b', 'c' ]
         listc.edit( abc )
-        items =listc.getCriteriaItems()
-        assert items[0][1] == tuple( abc )
+
+        items = listc.getCriteriaItems()
+        self.assertEqual( items[0][1], tuple( abc ) )
 
 def test_suite():
-    return unittest.makeSuite(TestListCriterion)
+    return unittest.makeSuite( ListCriterionTests )
 
 def main():
-    unittest.TextTestRunner().run(test_suite())
+    unittest.TextTestRunner().run( test_suite() )
 
 if __name__ == '__main__':
     main()


=== CMF/CMFTopic/tests/test_SIC.py 1.5 => 1.5.8.1 ===
-import Products.CMFTopic.SimpleIntCriterion
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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
+# 
+##############################################################################
+"""Unit tests for SimpleIntCriterion module.
+
+$Id$
+"""
+__version__ = '$Revision$'[11:-2]
 
-SIC = Products.CMFTopic.SimpleIntCriterion.SimpleIntCriterion
+import unittest
 
+class SimpleIntCriterionTests( unittest.TestCase ):
 
-class TestSimpleInt(unittest.TestCase):
+    def test_Interface( self ):
+        from Products.CMFTopic.interfaces import Criterion
+        from Products.CMFTopic.SimpleIntCriterion import SimpleIntCriterion
+        self.failUnless(
+            Criterion.isImplementedByInstancesOf( SimpleIntCriterion ) )
+
+    def test_Empty( self ):
+
+        from Products.CMFTopic.SimpleIntCriterion import SimpleIntCriterion
+
+        sic = SimpleIntCriterion( 'foo', 'foofield' )
+        self.assertEqual( sic.getId(), 'foo' )
+        self.assertEqual( sic.field, 'foofield' )
+        self.assertEqual( sic.value, None )
+        self.assertEqual( sic.getValueString(), '' )
+        self.assertEqual( len(sic.getCriteriaItems() ), 0 )
+    
+    def test_EditWithString( self ):
 
-    def setUp( self ):
-        get_transaction().begin()
+        from Products.CMFTopic.SimpleIntCriterion import SimpleIntCriterion
 
-    def tearDown( self ):
-        get_transaction().abort()
+        sic = SimpleIntCriterion('foo', 'foofield')
+        sic.edit('0')
+        self.assertEqual( sic.value, 0 )
+        self.assertEqual( sic.getValueString(), '0' )
 
-    def test_Empty(self):
-        sic = SIC('foo', 'foofield' )
-        assert sic.getId() == 'foo'
-        assert sic.field == 'foofield'
-        assert sic.value == None
-        assert len(sic.getCriteriaItems()) == 0
+        items = sic.getCriteriaItems()
+        self.assertEqual( len( items ), 1 )
+        self.assertEqual( len( items[0] ), 2 )
+        self.assertEqual( items[0][0], 'foofield' )
+        self.assertEqual( items[0][1], 0 )
     
-    def test_Nonempty(self):
-        sic = SIC('foo', 'foofield')
-        sic.edit('0')
-        assert sic.getId() == 'foo'
-        assert sic.field == 'foofield'
-        assert sic.value == 0
-        items =sic.getCriteriaItems()
-        assert len(items) == 1
-        assert len(items[0]) == 2
-        assert items[0][0] == 'foofield'
-        assert items[0][1] == 0
-
-        sic = SIC('foo', 'foofield')
-        sic.edit(32)
-        assert sic.value == 32
-        items =sic.getCriteriaItems()
-        assert len(items) == 1
-        assert len(items[0]) == 2
-        assert items[0][1] == 32
-
-    def test_Range(self):
-        sic = SIC('foo', 'foofield')
-        sic.edit(32, SIC.MINIMUM)
-        items = sic.getCriteriaItems()
-        assert len(items) == 2
-        assert len(items[0]) == len(items[1]) == 2
-        assert items[0][1] == 32
-        assert items[1][0] == 'foofield_usage'
-        assert items[1][1] == 'range:min'
-
-        sic.direction = SIC.MAXIMUM
+    def test_EditWithInt( self ):
+
+        from Products.CMFTopic.SimpleIntCriterion import SimpleIntCriterion
+
+        sic = SimpleIntCriterion( 'foo', 'foofield' )
+        sic.edit( 32 )
+        self.assertEqual( sic.value, 32 )
+        self.assertEqual( sic.getValueString(), '32' )
+
+        items = sic.getCriteriaItems()
+        self.assertEqual( len(items), 1 )
+        self.assertEqual( len(items[0]), 2 )
+        self.assertEqual( items[0][1], 32 )
+
+    def test_RangeMin( self ):
+
+        from Products.CMFTopic.SimpleIntCriterion import SimpleIntCriterion
+
+        sic = SimpleIntCriterion( 'foo', 'foofield' )
+        sic.edit( '32', SimpleIntCriterion.MINIMUM )
+
+        self.assertEqual( sic.value, 32 )
+        self.assertEqual( sic.getValueString(), '32' )
+
+        items = sic.getCriteriaItems()
+        self.assertEqual( len( items ), 2 )
+        self.assertEqual( len( items[0] ), 2 )
+        self.assertEqual( len( items[1] ), 2 )
+        self.assertEqual( items[0][0], 'foofield' )
+        self.assertEqual( items[0][1], 32 )
+        self.assertEqual( items[1][0], 'foofield_usage' )
+        self.assertEqual( items[1][1], 'range:min' )
+
+    def test_RangeMin_withInt( self ):
+
+        from Products.CMFTopic.SimpleIntCriterion import SimpleIntCriterion
+
+        sic = SimpleIntCriterion( 'foo', 'foofield' )
+        sic.edit( 32, SimpleIntCriterion.MINIMUM )
+
+        self.assertEqual( sic.value, 32 )
+        self.assertEqual( sic.getValueString(), '32' )
+
+        items = sic.getCriteriaItems()
+        self.assertEqual( len( items ), 2 )
+        self.assertEqual( len( items[0] ), 2 )
+        self.assertEqual( len( items[1] ), 2 )
+        self.assertEqual( items[0][0], 'foofield' )
+        self.assertEqual( items[0][1], 32 )
+        self.assertEqual( items[1][0], 'foofield_usage' )
+        self.assertEqual( items[1][1], 'range:min' )
+
+    def test_RangeMax( self ):
+
+        from Products.CMFTopic.SimpleIntCriterion import SimpleIntCriterion
+
+        sic = SimpleIntCriterion( 'foo', 'foofield' )
+        sic.edit( '32', SimpleIntCriterion.MAXIMUM )
+
+        self.assertEqual( sic.value, 32 )
+        self.assertEqual( sic.getValueString(), '32' )
+
         items = sic.getCriteriaItems()
-        assert items[1][0] == 'foofield_usage'
-        assert items[1][1] == 'range:max'
+        self.assertEqual( len( items ), 2 )
+        self.assertEqual( len( items[0] ), 2 )
+        self.assertEqual( len( items[1] ), 2 )
+        self.assertEqual( items[0][0], 'foofield' )
+        self.assertEqual( items[0][1], 32 )
+        self.assertEqual( items[1][0], 'foofield_usage' )
+        self.assertEqual( items[1][1], 'range:max' )
+
+    def test_RangeMax_withInt( self ):
+
+        from Products.CMFTopic.SimpleIntCriterion import SimpleIntCriterion
+
+        sic = SimpleIntCriterion( 'foo', 'foofield' )
+        sic.edit( 32, SimpleIntCriterion.MAXIMUM )
+
+        self.assertEqual( sic.value, 32 )
+        self.assertEqual( sic.getValueString(), '32' )
+
+        items = sic.getCriteriaItems()
+        self.assertEqual( len( items ), 2 )
+        self.assertEqual( len( items[0] ), 2 )
+        self.assertEqual( len( items[1] ), 2 )
+        self.assertEqual( items[0][0], 'foofield' )
+        self.assertEqual( items[0][1], 32 )
+        self.assertEqual( items[1][0], 'foofield_usage' )
+        self.assertEqual( items[1][1], 'range:max' )
+
+    def test_RangeMinMax( self ):
+
+        from Products.CMFTopic.SimpleIntCriterion import SimpleIntCriterion
+
+        sic = SimpleIntCriterion( 'foo', 'foofield' )
+        sic.edit( '32 34', SimpleIntCriterion.MINMAX )
+
+        self.assertEqual( sic.value, ( 32, 34 ) )
+        self.assertEqual( sic.getValueString(), '32 34' )
+
+        items = sic.getCriteriaItems()
+        self.assertEqual( len( items ), 2 )
+        self.assertEqual( len( items[0] ), 2 )
+        self.assertEqual( len( items[1] ), 2 )
+        self.assertEqual( items[0][0], 'foofield' )
+        self.assertEqual( items[0][1], ( 32, 34 ) )
+        self.assertEqual( items[1][0], 'foofield_usage' )
+        self.assertEqual( items[1][1], 'range:min:max' )
+
+    def test_RangeMinMax_withTuple( self ):
+
+        from Products.CMFTopic.SimpleIntCriterion import SimpleIntCriterion
+
+        sic = SimpleIntCriterion( 'foo', 'foofield' )
+        sic.edit( ( 32, 34 ), SimpleIntCriterion.MINMAX )
+
+        self.assertEqual( sic.value, ( 32, 34 ) )
+        self.assertEqual( sic.getValueString(), '32 34' )
 
-        sic.direction = SIC.MINMAX
         items = sic.getCriteriaItems()
-        assert items[1][0] == 'foofield_usage'
-        assert items[1][1] == 'range:min:max'
+        self.assertEqual( len( items ), 2 )
+        self.assertEqual( len( items[0] ), 2 )
+        self.assertEqual( len( items[1] ), 2 )
+        self.assertEqual( items[0][0], 'foofield' )
+        self.assertEqual( items[0][1], ( 32, 34 ) )
+        self.assertEqual( items[1][0], 'foofield_usage' )
+        self.assertEqual( items[1][1], 'range:min:max' )
 
 def test_suite():
-    return unittest.makeSuite(TestSimpleInt)
+    return unittest.makeSuite( SimpleIntCriterionTests )
 
 def main():
-    unittest.TextTestRunner().run(test_suite())
+    unittest.TextTestRunner().run( test_suite() )
 
 if __name__ == '__main__':
     main()


=== CMF/CMFTopic/tests/test_SSC.py 1.5 => 1.5.8.1 ===
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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
+# 
+##############################################################################
+"""Unit tests for SimpleStringCriterion module.
+
+$Id$
+"""
+__version__ = '$Revision$'[11:-2]
+
 import unittest
-import Products.CMFTopic.SimpleStringCriterion
 
-SSC = Products.CMFTopic.SimpleStringCriterion.SimpleStringCriterion
+class SimpleStringCriterionTests( unittest.TestCase ):
 
+    def test_Interface( self ):
+        from Products.CMFTopic.interfaces import Criterion
+        from Products.CMFTopic.SimpleStringCriterion \
+            import SimpleStringCriterion
+        self.failUnless(
+            Criterion.isImplementedByInstancesOf( SimpleStringCriterion ) )
+    
+    def test_Empty( self ):
 
-class TestSimpleString(unittest.TestCase):
+        from Products.CMFTopic.SimpleStringCriterion \
+            import SimpleStringCriterion
 
-    def setUp( self ):
-        get_transaction().begin()
+        ssc = SimpleStringCriterion( 'foo', 'foofield' )
 
-    def tearDown( self ):
-        get_transaction().abort()
-    
-    def test_Empty( self ):
-        ssc = SSC('foo', 'foofield')
-        assert ssc.getId() == 'foo'
-        assert ssc.field == 'foofield'
-        assert ssc.value == ''
-        assert len( ssc.getCriteriaItems() ) == 0
+        self.assertEqual( ssc.getId(), 'foo' )
+        self.assertEqual( ssc.field, 'foofield' )
+        self.assertEqual( ssc.value, '' )
+        self.assertEqual( len( ssc.getCriteriaItems() ), 0 )
     
     def test_Nonempty( self ):
-        ssc = SSC('foo', 'foofield')
-        ssc.edit('bar')
-        assert ssc.getId() == 'foo'
-        assert ssc.field == 'foofield'
-        assert ssc.value == 'bar'
-
-        items =ssc.getCriteriaItems()
-        assert len(items) == 1
-        assert len(items[0]) == 2
-        assert items[0][0] == 'foofield'
-        assert items[0][1] == 'bar'
+
+        from Products.CMFTopic.SimpleStringCriterion \
+            import SimpleStringCriterion
+
+        ssc = SimpleStringCriterion( 'foo', 'foofield' )
+        ssc.edit( 'bar' )
+
+        self.assertEqual( ssc.getId(), 'foo' )
+        self.assertEqual( ssc.field, 'foofield' )
+        self.assertEqual( ssc.value, 'bar' )
+
+        items = ssc.getCriteriaItems()
+
+        self.assertEqual( len( items ), 1 )
+        self.assertEqual( len( items[0] ), 2 )
+        self.assertEqual( items[0][0], 'foofield' )
+        self.assertEqual( items[0][1], 'bar' )
 
 def test_suite():
-    return unittest.makeSuite(TestSimpleString)
+    return unittest.makeSuite( SimpleStringCriterionTests )
 
 def main():
-    unittest.TextTestRunner().run(test_suite())
+    unittest.TextTestRunner().run( test_suite() )
 
 if __name__ == '__main__':
     main()


=== CMF/CMFTopic/tests/test_Topic.py 1.8 => 1.8.4.1 ===
-import Products.CMFTopic.Topic
-import Products.CMFTopic.SimpleStringCriterion
-import Products.CMFTopic.SimpleIntCriterion
-
-SSC = Products.CMFTopic.SimpleStringCriterion.SimpleStringCriterion
-SIC = Products.CMFTopic.SimpleIntCriterion.SimpleIntCriterion
-Topic = Products.CMFTopic.Topic.Topic
-
 
 class TestTopic(unittest.TestCase):
-    """ Test all the general Topic cases  """
-
-    def setUp( self ):
-        get_transaction().begin()
-
-    def tearDown( self ):
-        get_transaction().abort()
+    """
+        Test all the general Topic cases
+    """
 
     def test_Empty( self ):
+
+        from Products.CMFTopic.Topic import Topic
         topic = Topic('top')
+
         query = topic.buildQuery()
-        assert len( query ) == 0
+        self.assertEqual( len( query ), 0 )
     
     def test_Simple( self ):
+
+        from Products.CMFTopic.Topic import Topic
         topic = Topic('top')
-        topic._setObject('crit__foo', SSC('crit__foo', 'foo'))
-        topic.crit__foo.edit('bar')
+        topic.addCriterion( 'foo', 'String Criterion' )
+        topic.getCriterion( 'foo' ).edit( 'bar' )
+
         query = topic.buildQuery()
-        assert len(query) == 1
-        assert query['foo'] == 'bar'
+        self.assertEqual( len(query), 1 )
+        self.assertEqual( query['foo'], 'bar' )
+
+        topic.addCriterion( 'baz', 'Integer Criterion' )
+        topic.getCriterion( 'baz' ).edit( 43 )
 
-        topic._setObject('crit__baz', SIC('crit__baz', 'baz'))
-        topic.crit__baz.edit(43)
         query = topic.buildQuery()
-        assert len(query) == 2
-        assert query['foo'] == 'bar'
-        assert query['baz'] == 43
+        self.assertEqual( len( query ), 2 )
+        self.assertEqual( query[ 'foo' ], 'bar' )
+        self.assertEqual( query[ 'baz' ], 43 )
     
     def test_Nested( self ):
+
+        from Products.CMFTopic.Topic import Topic
         topic = Topic('top')
-        topic._setObject('crit__foo', SSC('crit__foo', 'foo'))
-        topic.crit__foo.edit('bar')
-        subtopic = Topic('qux')
-        subtopic._setObject('crit__baz', SSC('crit__baz', 'baz' ))
-        subtopic.crit__baz.edit('bam')
-        topic._setObject('qux', subtopic, set_owner=0)
+
+        topic.addCriterion( 'foo', 'String Criterion' )
+        topic.getCriterion( 'foo' ).edit( 'bar' )
+
+        topic.addSubtopic( 'qux' )
         subtopic = topic.qux
+
+        subtopic.addCriterion( 'baz', 'String Criterion' )
+        subtopic.getCriterion( 'baz' ).edit( 'bam' )
+
         query = subtopic.buildQuery()
-        assert len(query) == 2, str(query)
-        assert query['foo'] == 'bar'
-        assert query['baz'] == 'bam'
+        self.assertEqual( len( query ), 2 )
+        self.assertEqual( query['foo'], 'bar' )
+        self.assertEqual( query['baz'], 'bam' )
 
         subtopic.acquireCriteria = 0
         query = subtopic.buildQuery()
-        assert len(query) == 1
-        assert query['baz'] == 'bam'
+        self.assertEqual( len( query ), 1 )
+        self.assertEqual( query['baz'], 'bam' )
 
 def test_suite():
     return unittest.makeSuite(TestTopic)