X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/bd70b19c7408e29a74a15e1288db1821f58cf777..3c031f8db5d5faadf837dc447b80002736e16bbb:/pokedex/tests/test_lookup.py?ds=sidebyside diff --git a/pokedex/tests/test_lookup.py b/pokedex/tests/test_lookup.py index b6bef60..6479bd6 100644 --- a/pokedex/tests/test_lookup.py +++ b/pokedex/tests/test_lookup.py @@ -89,3 +89,27 @@ def test_fuzzy_lookup(): top_names = [_.object.name for _ in results[0:2]] assert_true(u'Nidoran♂' in top_names, u'Nidoran♂ is a top result for "Nidoran"') assert_true(u'Nidoran♀' in top_names, u'Nidoran♀ is a top result for "Nidoran"') + +def test_wildcard_lookup(): + tests = [ + (u'pokemon:*meleon', u'Charmeleon'), + (u'item:master*', u'Master Ball'), + (u'ee?ee', u'Eevee'), + ] + + for wildcard, name in tests: + results = pokedex.lookup.lookup(wildcard) + first_result = results[0] + assert_equal(first_result.object.name, name, + u'Wildcards work correctly') + +def test_random_lookup(): + for _ in xrange(5): + results = pokedex.lookup.lookup(u'random') + assert_equal(len(results), 1, u'Random returns one result') + + for table_name in [u'pokemon', u'moves', u'items', u'abilities', u'types']: + results = pokedex.lookup.lookup(u'random', valid_types=[table_name]) + assert_equal(len(results), 1, u'Constrained random returns one result') + assert_equal(results[0].object.__tablename__, table_name, + u'Constrained random returns result from the right table')