From de27f2c282bab707ba2dbcb2c4d8483c9963e4c2 Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Tue, 9 Mar 2021 22:28:31 -0800 Subject: [PATCH] Fix test for missing default forms --- pokedex/tests/test_database_sanity.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pokedex/tests/test_database_sanity.py b/pokedex/tests/test_database_sanity.py index c515a48..4e8ad1e 100644 --- a/pokedex/tests/test_database_sanity.py +++ b/pokedex/tests/test_database_sanity.py @@ -110,8 +110,8 @@ def test_default_forms(session): default pokemon.""" q = session.query(tables.Pokemon) - q = q.join(tables.PokemonForm) - q = q.filter(tables.PokemonForm.is_default==True) + # TODO: could use table.Pokemon.forms.and_: https://docs.sqlalchemy.org/en/14/orm/queryguide.html#orm-queryguide-join-on-augmented + q = q.outerjoin(tables.PokemonForm, (tables.PokemonForm.pokemon_id == tables.Pokemon.id) & (tables.PokemonForm.is_default==True)) q = q.options(lazyload('*')) q = q.group_by(tables.Pokemon) q = q.add_columns(func.count(tables.PokemonForm.id)) @@ -123,8 +123,7 @@ def test_default_forms(session): pytest.fail("pokemon %s has %d default forms" % (pokemon.name, num_default_forms)) q = session.query(tables.PokemonSpecies) - q = q.join(tables.Pokemon) - q = q.filter(tables.Pokemon.is_default==True) + q = q.outerjoin(tables.Pokemon, (tables.Pokemon.species_id == tables.PokemonSpecies.id) & (tables.Pokemon.is_default==True)) q = q.options(lazyload('*')) q = q.group_by(tables.PokemonSpecies) q = q.add_columns(func.count(tables.Pokemon.id))