Back to index

plone3  3.1.7
test_SortC.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """ Unit tests for SortCriterion module.
00014 
00015 $Id: test_SortC.py 68496 2006-06-05 16:30:18Z yuppie $
00016 """
00017 
00018 import unittest
00019 import Testing
00020 
00021 from common import CriterionTestCase
00022 
00023 
00024 class SortCriterionTests(CriterionTestCase):
00025 
00026     def _getTargetClass(self):
00027         from Products.CMFTopic.SortCriterion import SortCriterion
00028 
00029         return SortCriterion
00030 
00031     def test_Empty( self ):
00032         ssc = self._makeOne('foo', 'foofield')
00033 
00034         self.assertEqual( ssc.getId(), 'foo' )
00035         self.assertEqual( ssc.field, None )
00036         self.assertEqual( ssc.index, 'foofield' )
00037         self.assertEqual( ssc.Field(), 'foofield' )
00038         self.assertEqual( ssc.reversed, 0 )
00039 
00040         items = ssc.getCriteriaItems()
00041         self.assertEqual( len( items ), 1 )
00042         self.assertEqual( items[0][0], 'sort_on' )
00043         self.assertEqual( items[0][1], 'foofield' )
00044 
00045     def test_Nonempty( self ):
00046         ssc = self._makeOne('foo', 'foofield')
00047 
00048         ssc.edit( 1 )
00049 
00050         self.assertEqual( ssc.getId(), 'foo' )
00051         self.assertEqual( ssc.field, None )
00052         self.assertEqual( ssc.index, 'foofield' )
00053         self.assertEqual( ssc.Field(), 'foofield' )
00054         self.assertEqual( ssc.reversed, 1 )
00055 
00056         items = ssc.getCriteriaItems()
00057         self.assertEqual( len( items ), 2 )
00058         self.assertEqual( items[0][0], 'sort_on' )
00059         self.assertEqual( items[0][1], 'foofield' )
00060         self.assertEqual( items[1][0], 'sort_order' )
00061         self.assertEqual( items[1][1], 'reverse' )
00062 
00063 
00064 def test_suite():
00065     return unittest.TestSuite((
00066         unittest.makeSuite(SortCriterionTests),
00067         ))
00068 
00069 if __name__ == '__main__':
00070     unittest.main(defaultTest='test_suite')