<s> import time <EOL> from django . core . cache import cache <EOL> from django . test import TestCase <EOL> from tastypie . cache import NoCache , SimpleCache <EOL> class NoCacheTestCase ( TestCase ) : <EOL> def tearDown ( self ) : <EOL> cache . delete ( '<STR_LIT:foo>' ) <EOL> cache . delete ( '<STR_LIT>' ) <EOL> super ( NoCacheTestCase , self ) . tearDown ( ) <EOL> def test_get ( self ) : <EOL> cache . set ( '<STR_LIT:foo>' , '<STR_LIT:bar>' , <NUM_LIT> ) <EOL> cache . set ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> no_cache = NoCache ( ) <EOL> self . assertEqual ( no_cache . get ( '<STR_LIT:foo>' ) , None ) <EOL> self . assertEqual ( no_cache . get ( '<STR_LIT>' ) , None ) <EOL> self . assertEqual ( no_cache . get ( '<STR_LIT>' ) , None ) <EOL> def test_set ( self ) : <EOL> no_cache = NoCache ( ) <EOL> no_cache . set ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) <EOL> no_cache . set ( '<STR_LIT>' , '<STR_LIT>' , timeout = <NUM_LIT:1> ) <EOL> self . assertEqual ( cache . get ( '<STR_LIT:foo>' ) , None ) <EOL> self . assertEqual ( cache . get ( '<STR_LIT>' ) , None ) <EOL> class SimpleCacheTestCase ( TestCase ) : <EOL> def tearDown ( self ) : <EOL> cache . delete ( '<STR_LIT:foo>' ) <EOL> cache . delete ( '<STR_LIT>' ) <EOL> super ( SimpleCacheTestCase , self ) . tearDown ( ) <EOL> def test_get ( self ) : <EOL> cache . set ( '<STR_LIT:foo>' , '<STR_LIT:bar>' , <NUM_LIT> ) <EOL> cache . set ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> simple_cache = SimpleCache ( ) <EOL> self . assertEqual ( simple_cache . get ( '<STR_LIT:foo>' ) , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( simple_cache . get ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( simple_cache . get ( '<STR_LIT>' ) , None ) <EOL> def test_set ( self ) : <EOL> simple_cache = SimpleCache ( ) <EOL> simple_cache . set ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) <EOL> simple_cache . set ( '<STR_LIT>' , '<STR_LIT>' , timeout = <NUM_LIT:1> ) <EOL> self . assertEqual ( cache . get ( '<STR_LIT:foo>' ) , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( cache . get ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> time . sleep ( <NUM_LIT:2> ) <EOL> self . assertEqual ( cache . get ( '<STR_LIT>' ) , None ) </s>
