mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Add a sanity check for PokemonForm.order
This commit is contained in:
parent
3a59ef1fe0
commit
3dc8a4cbd0
1 changed files with 25 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from sqlalchemy.orm import aliased
|
from sqlalchemy.orm import aliased, joinedload
|
||||||
from sqlalchemy.orm.exc import NoResultFound
|
from sqlalchemy.orm.exc import NoResultFound
|
||||||
|
|
||||||
from pokedex.db import connect, tables, util
|
from pokedex.db import connect, tables, util
|
||||||
|
@ -40,3 +40,27 @@ def test_nonzero_autoincrement_ids():
|
||||||
util.get(session, cls, id=0)
|
util.get(session, cls, id=0)
|
||||||
nonzero_id.description = "No zero id in %s" % cls.__name__
|
nonzero_id.description = "No zero id in %s" % cls.__name__
|
||||||
yield nonzero_id, cls
|
yield nonzero_id, cls
|
||||||
|
|
||||||
|
def test_unique_form_order():
|
||||||
|
"""Check that tone PokemonForm.order value isn't used for more species
|
||||||
|
"""
|
||||||
|
|
||||||
|
session = connect()
|
||||||
|
|
||||||
|
species_by_form_order = {}
|
||||||
|
|
||||||
|
query = session.query(tables.PokemonForm)
|
||||||
|
query = query.options(joinedload('pokemon.species'))
|
||||||
|
|
||||||
|
for form in query:
|
||||||
|
print form.name
|
||||||
|
try:
|
||||||
|
previous_species = species_by_form_order[form.order]
|
||||||
|
except KeyError:
|
||||||
|
species_by_form_order[form.order] = form.species
|
||||||
|
else:
|
||||||
|
assert previous_species == form.species, (
|
||||||
|
"PokemonForm.order == %s is used for %s and %s" % (
|
||||||
|
form.order,
|
||||||
|
species_by_form_order[form.order].name,
|
||||||
|
form.species.name))
|
||||||
|
|
Loading…
Reference in a new issue