<s> __all__ = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> import unittest <EOL> from iktomi . storage import LocalMemStorage , MemcachedStorage <EOL> class LocalMemStorageTest ( unittest . TestCase ) : <EOL> def test_set ( self ) : <EOL> '<STR_LIT>' <EOL> s = LocalMemStorage ( ) <EOL> s . set ( '<STR_LIT:key>' , '<STR_LIT:value>' ) <EOL> self . assertEqual ( s . storage [ '<STR_LIT:key>' ] , '<STR_LIT:value>' ) <EOL> def test_set_rewrite ( self ) : <EOL> '<STR_LIT>' <EOL> s = LocalMemStorage ( ) <EOL> s . set ( '<STR_LIT:key>' , '<STR_LIT:value>' ) <EOL> s . set ( '<STR_LIT:key>' , '<STR_LIT>' ) <EOL> self . assertEqual ( s . storage [ '<STR_LIT:key>' ] , '<STR_LIT>' ) <EOL> def test_get ( self ) : <EOL> '<STR_LIT>' <EOL> s = LocalMemStorage ( ) <EOL> self . assertEqual ( s . get ( '<STR_LIT:key>' ) , None ) <EOL> self . assertEqual ( s . get ( '<STR_LIT:key>' , '<STR_LIT:1>' ) , '<STR_LIT:1>' ) <EOL> s . set ( '<STR_LIT:key>' , '<STR_LIT:value>' ) <EOL> self . assertEqual ( s . get ( '<STR_LIT:key>' ) , '<STR_LIT:value>' ) <EOL> def test_delete ( self ) : <EOL> '<STR_LIT>' <EOL> s = LocalMemStorage ( ) <EOL> self . assertEqual ( s . delete ( '<STR_LIT:key>' ) , True ) <EOL> s . set ( '<STR_LIT:key>' , '<STR_LIT:value>' ) <EOL> self . assertEqual ( s . delete ( '<STR_LIT:key>' ) , True ) <EOL> self . assertEqual ( s . get ( '<STR_LIT:key>' ) , None ) <EOL> class MemcachedStorageTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . storage = MemcachedStorage ( '<STR_LIT>' ) <EOL> if not self . storage . storage . set ( '<STR_LIT:test>' , '<STR_LIT:test>' ) : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> def tearDown ( self ) : <EOL> memcached = self . storage . storage <EOL> memcached . delete ( '<STR_LIT:test>' ) <EOL> memcached . delete ( '<STR_LIT:key>' ) <EOL> memcached . disconnect_all ( ) <EOL> def test_set ( self ) : <EOL> '<STR_LIT>' <EOL> self . assertEqual ( self . storage . set ( '<STR_LIT:key>' , '<STR_LIT:value>' ) , True ) <EOL> self . assertEqual ( self . storage . set ( '<STR_LIT:key>' , '<STR_LIT>' ) , True ) <EOL> def test_get ( self ) : <EOL> '<STR_LIT>' <EOL> self . assertEqual ( self . storage . get ( '<STR_LIT:key>' ) , None ) <EOL> self . assertEqual ( self . storage . get ( '<STR_LIT:key>' , '<STR_LIT:default>' ) , '<STR_LIT:default>' ) <EOL> self . storage . set ( '<STR_LIT:key>' , '<STR_LIT:value>' ) <EOL> self . assertEqual ( self . storage . get ( '<STR_LIT:key>' ) , '<STR_LIT:value>' ) <EOL> def test_delete ( self ) : <EOL> '<STR_LIT>' <EOL> self . assertEqual ( self . storage . delete ( '<STR_LIT:key>' ) , True ) <EOL> self . storage . set ( '<STR_LIT:key>' , '<STR_LIT:value>' ) <EOL> self . assertEqual ( self . storage . delete ( '<STR_LIT:key>' ) , True ) <EOL> self . assertEqual ( self . storage . get ( '<STR_LIT:key>' ) , None ) </s>
