def explore_pokemon(context, request): # TODO should this be part of the api? it knows if there was "really" a # search did_search = bool(request.GET) if not did_search: return dict( did_search=did_search, results=None, all_pokemon=None, all_types=None, all_generations=None, ) q = api.Query(api.PokemonLocus, session) q.parse_multidict(request.GET) return dict( did_search=did_search, results=q.execute(), # XXX these really oughta come from the locus, or something. fix this # up yo all_types=session.query(t.Type), all_generations=session.query(t.Generation), )
def test_output_struct(session): aq = api.Query(api.MoveLocus, session) aq.add_criterion('type', 'dragon') results = aq.execute() for result in results: print result print result.identifier print result.type print result.generation print result.damage_class
def test_simple_prefetch(session): aq = api.Query(api.PokemonLocus, session) aq.add_criterion('type', 'normal') aq.add_fetch('generation') aq.add_language('en') results = aq.execute() with disable_session(session): for result in results: print result print result.identifier print result.type print result.generation
def test_filter_simple_type(session): aq = api.Query(api.MoveLocus, session) aq.add_criterion('type', 'dragon') check_query(aq, [ 'draco-meteor', 'dragonbreath', 'dragon-claw', 'dragon-dance', 'dragon-pulse', 'dragon-rage', 'dragon-rush', 'dragon-tail', 'dual-chop', 'outrage', 'roar-of-time', 'spacial-rend', 'twister', ])
def move_search(context, request): # XXX request._LOCALE_ = 'en' # TODO should this be part of the api? it knows if there was "really" a # search did_search = bool(request.GET) q = api.Query(api.MoveLocus, session) q.parse_multidict(request.GET) move_groups, moves, move_previews = q.results() return dict( did_search=did_search, move_groups=move_groups, moves=moves, move_previews=move_previews, # XXX these really oughta come from the locus, or something. fix this # up yo all_types=session.query(t.Type), all_generations=session.query(t.Generation), )
def test_filter_simple_name(session): aq = api.Query(api.MoveLocus, session) aq.add_criterion('name', 'flamethrower') check_query(aq, ['flamethrower'], exact=True) '''
def test_filter_simple_identifier(session): aq = api.Query(api.MoveLocus, session) aq.add_criterion('identifier', 'pay-day') check_query(aq, ['pay-day'])