Add German names for B/W stuff.
[zzz-pokedex.git] / pokedex / tests / test_database_sanity.py
1 from nose.tools import *
2 import unittest
3 from sqlalchemy.orm import aliased
4
5 from pokedex.db import connect, tables
6
7 def test_encounter_slots():
8 # Encounters have a version, which has a version group; encounters also
9 # have an encounter_slot, which has a version group. The two version
10 # groups should match, universally.
11 session = connect()
12
13 version_group_a = aliased(tables.VersionGroup)
14 version_group_b = aliased(tables.VersionGroup)
15
16 sanity_q = session.query(tables.Encounter) \
17 .join((tables.EncounterSlot, tables.Encounter.slot)) \
18 .join((version_group_a, tables.EncounterSlot.version_group)) \
19 .join((tables.Version, tables.Encounter.version)) \
20 .join((version_group_b, tables.Version.version_group)) \
21 .filter(version_group_a.id != version_group_b.id)
22
23 assert_equal(sanity_q.count(), 0,
24 "Encounter slots all match the encounters they belong to")