Actually test :foo in test_crash_empty_prefix
[zzz-pokedex.git] / pokedex / tests / test_strings.py
1 # Encoding: UTF-8
2
3 from nose.tools import *
4
5 from pokedex.db import tables, connect
6
7 class TestStrings(object):
8 def setup(self):
9 self.connection = connect()
10
11 def test_filter(self):
12 q = self.connection.query(tables.Pokemon).filter(
13 tables.Pokemon.name == u"Marowak")
14 assert q.one().identifier == 'marowak'
15
16 def test_gt(self):
17 # Assuming that the identifiers are just lowercase names
18 q1 = self.connection.query(tables.Pokemon).filter(
19 tables.Pokemon.name > u"Xatu").order_by(
20 tables.Pokemon.id)
21 q2 = self.connection.query(tables.Pokemon).filter(
22 tables.Pokemon.identifier > u"xatu").order_by(
23 tables.Pokemon.id)
24 assert q1.all() == q2.all()
25
26 def test_languages(self):
27 q = self.connection.query(tables.Pokemon).filter(
28 tables.Pokemon.name == u"Mightyena")
29 pkmn = q.one()
30 for lang, name in (
31 ('en', u'Mightyena'),
32 ('ja', u'グラエナ'),
33 ('roomaji', u'Guraena'),
34 ('fr', u'Grahyèna'),
35 ):
36 assert pkmn.names[lang] == name
37
38 @raises(KeyError)
39 def test_bad_lang(self):
40 q = self.connection.query(tables.Pokemon).filter(
41 tables.Pokemon.name == u"Mightyena")
42 pkmn = q.one()
43 pkmn.names["identifier of a language that doesn't exist"]