Region-prefix some locations identifiers, and add a test

Unova Routes 19-23 were added in B/W 2 and i forgot to prefix them when
we added the locations. Kalos Victory Road used to have a prefix but it
got dropped when i re-ripped X/Y locations. Kalos Pokemon League gets a
prefix too, since both Sinnoh and Alola also have Pokemon Leagues.

Add a test to ensure that we don't forget again in the future.
This commit is contained in:
Andrew Ekstedt 2018-09-29 11:35:13 -07:00
parent 59fd27c574
commit 9a8918135f
2 changed files with 28 additions and 7 deletions

View file

@ -519,11 +519,11 @@ id,region_id,identifier
535,5,join-avenue 535,5,join-avenue
536,5,floccesy-town 536,5,floccesy-town
537,5,lentimas-town 537,5,lentimas-town
538,5,route-19 538,5,unova-route-19
539,5,route-20 539,5,unova-route-20
540,5,route-21 540,5,unova-route-21
541,5,route-22 541,5,unova-route-22
542,5,route-23 542,5,unova-route-23
543,5,castelia-sewers 543,5,castelia-sewers
544,5,floccesy-ranch 544,5,floccesy-ranch
545,5,virbank-complex 545,5,virbank-complex
@ -638,8 +638,8 @@ id,region_id,identifier
654,6,dernière-way 654,6,dernière-way
655,6,kalos-route-22 655,6,kalos-route-22
656,6,detourner-way 656,6,detourner-way
657,6,victory-road 657,6,kalos-victory-road
658,6,pokemon-league 658,6,kalos-pokemon-league
659,6,kiloude-city 659,6,kiloude-city
660,6,battle-maison 660,6,battle-maison
661,6,azure-bay 661,6,azure-bay

1 id region_id identifier
519 535 5 join-avenue
520 536 5 floccesy-town
521 537 5 lentimas-town
522 538 5 route-19 unova-route-19
523 539 5 route-20 unova-route-20
524 540 5 route-21 unova-route-21
525 541 5 route-22 unova-route-22
526 542 5 route-23 unova-route-23
527 543 5 castelia-sewers
528 544 5 floccesy-ranch
529 545 5 virbank-complex
638 654 6 dernière-way
639 655 6 kalos-route-22
640 656 6 detourner-way
641 657 6 victory-road kalos-victory-road
642 658 6 pokemon-league kalos-pokemon-league
643 659 6 kiloude-city
644 660 6 battle-maison
645 661 6 azure-bay

View file

@ -1,6 +1,8 @@
import pytest import pytest
parametrize = pytest.mark.parametrize parametrize = pytest.mark.parametrize
import re
from sqlalchemy.orm import aliased, joinedload, lazyload from sqlalchemy.orm import aliased, joinedload, lazyload
from sqlalchemy.orm.exc import NoResultFound from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.sql import func from sqlalchemy.sql import func
@ -93,3 +95,22 @@ def test_default_forms(session):
pytest.fail("species %s has no default pokemon" % species.name) pytest.fail("species %s has no default pokemon" % species.name)
elif num_default_pokemon > 1: elif num_default_pokemon > 1:
pytest.fail("species %s has %d default pokemon" % (species.name, num_default_pokemon)) pytest.fail("species %s has %d default pokemon" % (species.name, num_default_pokemon))
ROUTE_RE = re.compile(ur'route-\d+')
def test_location_identifiers(session):
"""Check that location identifiers for some common locations are prefixed
with the region name, ala kalos-route-2"""
q = session.query(tables.Location)
q = q.join(tables.Region)
q = q.options(lazyload('*'))
for loc in q:
if (loc.identifier in [u'victory-road', u'pokemon-league', u'safari-zone']
or ROUTE_RE.match(loc.identifier)):
if loc.region:
region = loc.region.identifier.lower()
suggested_identifier = region + "-" + loc.identifier
pytest.fail("location %d: identifier %s should be prefixed with its region (e.g. %s)" % (loc.id, loc.identifier, suggested_identifier))
else:
pytest.fail("location %d: identifier %s should be prefixed with its region" % (loc.id, loc.identifier))