<s> """<STR_LIT>""" <EOL> from datetime import datetime , timedelta <EOL> import unittest <EOL> from google . appengine . api import memcache <EOL> from google . appengine . ext import db <EOL> from tipfy import Request , RequestHandler , Tipfy <EOL> from tipfy . app import local <EOL> from tipfy . appengine . sharded_counter import Counter <EOL> import test_utils <EOL> class TestCounter ( test_utils . BaseTestCase ) : <EOL> def setUp ( self ) : <EOL> app = Tipfy ( ) <EOL> local . request = Request . from_values ( ) <EOL> local . request . app = app <EOL> test_utils . BaseTestCase . setUp ( self ) <EOL> def test_counter ( self ) : <EOL> hits = Counter ( '<STR_LIT>' ) <EOL> self . assertEqual ( hits . count , <NUM_LIT:0> ) <EOL> hits . increment ( ) <EOL> hits . increment ( <NUM_LIT:10> ) <EOL> hits . increment ( - <NUM_LIT:3> ) <EOL> self . assertEqual ( hits . count , <NUM_LIT:8> ) <EOL> self . assertEqual ( hits . get_count ( nocache = True ) , <NUM_LIT:8> ) <EOL> hits . count = <NUM_LIT:6> <EOL> self . assertEqual ( hits . get_count ( nocache = True ) , <NUM_LIT:6> ) <EOL> def test_cache ( self ) : <EOL> hits = Counter ( '<STR_LIT>' ) <EOL> self . assertEqual ( hits . count , <NUM_LIT:0> ) <EOL> hits . increment ( ) <EOL> hits . increment ( <NUM_LIT:10> ) <EOL> hits . increment ( - <NUM_LIT:3> ) <EOL> self . assertEqual ( hits . count , <NUM_LIT:8> ) <EOL> self . assertEqual ( hits . get_count ( nocache = True ) , <NUM_LIT:8> ) <EOL> hits . delete ( ) <EOL> self . assertEqual ( hits . get_count ( ) , <NUM_LIT:8> ) <EOL> self . assertEqual ( hits . get_count ( nocache = True ) , <NUM_LIT:0> ) <EOL> hits . memcached . delete_count ( ) <EOL> self . assertEqual ( hits . get_count ( ) , <NUM_LIT:0> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_utils . main ( ) </s>
