<s> """<STR_LIT>""" <EOL> import time <EOL> import unittest <EOL> from google . appengine . ext import deferred <EOL> from google . appengine . api import taskqueue <EOL> from google . appengine . ext import db <EOL> from tipfy import Rule , Tipfy <EOL> from tipfy . app import local <EOL> import test_utils <EOL> def get_rules ( ) : <EOL> return [ <EOL> Rule ( '<STR_LIT>' , name = '<STR_LIT>' , <EOL> handler = '<STR_LIT>' % __name__ ) , <EOL> Rule ( '<STR_LIT>' , name = '<STR_LIT>' , <EOL> handler = '<STR_LIT>' % __name__ ) , <EOL> ] <EOL> def get_url_rules ( ) : <EOL> rules = [ <EOL> Rule ( '<STR_LIT>' , name = '<STR_LIT>' , handler = '<STR_LIT>' ) , <EOL> ] <EOL> return Map ( rules ) <EOL> def get_app ( ) : <EOL> return Tipfy ( { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : True , <EOL> } , <EOL> } , rules = get_url_rules ( ) ) <EOL> class TaskTestModel ( db . Model ) : <EOL> number = db . IntegerProperty ( ) <EOL> def save_entities ( numbers ) : <EOL> entities = [ ] <EOL> for number in numbers : <EOL> entities . append ( TaskTestModel ( key_name = str ( number ) , number = number ) ) <EOL> res = db . put ( entities ) <EOL> import sys <EOL> sys . exit ( res ) <EOL> class TestDeferredHandler ( test_utils . BaseTestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_simple_deferred ( self ) : <EOL> numbers = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> keys = [ db . Key . from_path ( '<STR_LIT>' , str ( number ) ) for number in numbers ] <EOL> entities = db . get ( keys ) <EOL> self . assertEqual ( entities , [ None , None , None ] ) <EOL> deferred . defer ( save_entities , numbers ) <EOL> class TestTasks ( test_utils . BaseTestCase ) : <EOL> """<STR_LIT>""" <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_utils . main ( ) </s>
