mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Update test_strings.py to the new API (still fails though)
This commit is contained in:
parent
d961cfe1c7
commit
c4dc27732d
1 changed files with 26 additions and 26 deletions
|
@ -36,7 +36,9 @@ class TestStrings(object):
|
||||||
('roomaji', u'Guraena'),
|
('roomaji', u'Guraena'),
|
||||||
('fr', u'Grahyèna'),
|
('fr', u'Grahyèna'),
|
||||||
):
|
):
|
||||||
assert pkmn.names[lang] == name
|
language = self.connection.query(tables.Language).filter_by(
|
||||||
|
identifier=lang).one()
|
||||||
|
assert pkmn.name_map[language] == name
|
||||||
|
|
||||||
@raises(KeyError)
|
@raises(KeyError)
|
||||||
def test_bad_lang(self):
|
def test_bad_lang(self):
|
||||||
|
@ -50,12 +52,10 @@ class TestStrings(object):
|
||||||
identifier=u"jade-orb").one()
|
identifier=u"jade-orb").one()
|
||||||
language = self.connection.query(tables.Language).filter_by(
|
language = self.connection.query(tables.Language).filter_by(
|
||||||
identifier=u"de").one()
|
identifier=u"de").one()
|
||||||
item.names['de'] = u"foo"
|
item.name_map[language] = u"foo"
|
||||||
assert item.names['de'] == "foo"
|
assert item.name_map[language] == "foo"
|
||||||
assert item.names[language] == "foo"
|
item.name_map[language] = u"xyzzy"
|
||||||
item.names[language] = u"xyzzy"
|
assert item.name_map[language] == "xyzzy"
|
||||||
assert item.names['de'] == "xyzzy"
|
|
||||||
assert item.names[language] == "xyzzy"
|
|
||||||
|
|
||||||
def test_mutating_default(self):
|
def test_mutating_default(self):
|
||||||
item = self.connection.query(tables.Item).filter_by(
|
item = self.connection.query(tables.Item).filter_by(
|
||||||
|
@ -66,14 +66,12 @@ class TestStrings(object):
|
||||||
def test_string_mapping(self):
|
def test_string_mapping(self):
|
||||||
item = self.connection.query(tables.Item).filter_by(
|
item = self.connection.query(tables.Item).filter_by(
|
||||||
identifier=u"jade-orb").one()
|
identifier=u"jade-orb").one()
|
||||||
assert len(item.names) == len(item.texts)
|
assert len(item.name_map) == len(item.names)
|
||||||
for lang in item.texts:
|
for lang in item.names:
|
||||||
assert item.names[lang] == item.texts[lang].name
|
assert item.name_map[lang] == item.names[lang].name
|
||||||
assert item.names[lang] == item.names[lang.identifier]
|
assert lang in item.name_map
|
||||||
assert lang in item.names
|
assert "language that doesn't exist" not in item.name_map
|
||||||
assert lang.identifier in item.names
|
assert tables.Language() not in item.name_map
|
||||||
assert "language that doesn't exist" not in item.names
|
|
||||||
assert tables.Language() not in item.names
|
|
||||||
|
|
||||||
def test_new_language(self):
|
def test_new_language(self):
|
||||||
item = self.connection.query(tables.Item).filter_by(
|
item = self.connection.query(tables.Item).filter_by(
|
||||||
|
@ -84,23 +82,25 @@ class TestStrings(object):
|
||||||
language.iso639 = language.iso3166 = u'--'
|
language.iso639 = language.iso3166 = u'--'
|
||||||
language.official = False
|
language.official = False
|
||||||
self.connection.add(language)
|
self.connection.add(language)
|
||||||
item.names[u'test'] = u"foo"
|
item.name_map[language] = u"foo"
|
||||||
assert item.names[language] == "foo"
|
assert item.name_map[language] == "foo"
|
||||||
assert item.names['test'] == "foo"
|
assert language in item.name_map
|
||||||
assert 'de' in item.names
|
item.name_map[language] = u"xyzzy"
|
||||||
assert language in item.names
|
assert item.name_map[language] == "xyzzy"
|
||||||
item.names[language] = u"xyzzy"
|
|
||||||
assert item.names[language] == "xyzzy"
|
|
||||||
assert item.names['test'] == "xyzzy"
|
|
||||||
|
|
||||||
@raises(NotImplementedError)
|
@raises(AssertionError)
|
||||||
def test_delstring(self):
|
def test_delstring(self):
|
||||||
item = self.connection.query(tables.Item).filter_by(
|
item = self.connection.query(tables.Item).filter_by(
|
||||||
identifier=u"jade-orb").one()
|
identifier=u"jade-orb").one()
|
||||||
del item.names['en']
|
language = self.connection.query(tables.Language).filter_by(
|
||||||
|
identifier=u"en").one()
|
||||||
|
del item.name_map[language]
|
||||||
|
self.connection.commit()
|
||||||
|
|
||||||
def test_markdown(self):
|
def test_markdown(self):
|
||||||
move = self.connection.query(tables.Move).filter_by(
|
move = self.connection.query(tables.Move).filter_by(
|
||||||
identifier=u"thunderbolt").one()
|
identifier=u"thunderbolt").one()
|
||||||
|
language = self.connection.query(tables.Language).filter_by(
|
||||||
|
identifier=u"en").one()
|
||||||
assert '10%' in move.effect.as_text
|
assert '10%' in move.effect.as_text
|
||||||
assert '10%' in move.effects['en'].as_text
|
assert '10%' in move.effect_map[language].as_text
|
||||||
|
|
Loading…
Reference in a new issue