Back to index

plone3  3.1.7
test_SSC.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 SimpleStringCriterion module.
00014 
00015 $Id: test_SSC.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 SimpleStringCriterionTests(CriterionTestCase):
00025 
00026     def _getTargetClass(self):
00027         from Products.CMFTopic.SimpleStringCriterion \
00028                 import SimpleStringCriterion
00029 
00030         return SimpleStringCriterion
00031 
00032     def test_Empty( self ):
00033         ssc = self._makeOne('foo', 'foofield')
00034 
00035         self.assertEqual( ssc.getId(), 'foo' )
00036         self.assertEqual( ssc.field, 'foofield' )
00037         self.assertEqual( ssc.value, '' )
00038         self.assertEqual( len( ssc.getCriteriaItems() ), 0 )
00039 
00040     def test_Nonempty( self ):
00041         ssc = self._makeOne('foo', 'foofield')
00042         ssc.edit( 'bar' )
00043 
00044         self.assertEqual( ssc.getId(), 'foo' )
00045         self.assertEqual( ssc.field, 'foofield' )
00046         self.assertEqual( ssc.value, 'bar' )
00047 
00048         items = ssc.getCriteriaItems()
00049 
00050         self.assertEqual( len( items ), 1 )
00051         self.assertEqual( len( items[0] ), 2 )
00052         self.assertEqual( items[0][0], 'foofield' )
00053         self.assertEqual( items[0][1], 'bar' )
00054 
00055 
00056 def test_suite():
00057     return unittest.TestSuite((
00058         unittest.makeSuite(SimpleStringCriterionTests),
00059         ))
00060 
00061 if __name__ == '__main__':
00062     unittest.main(defaultTest='test_suite')