From e6b64b8c5a3182e8a0018dde3700ca7e6098e998 Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Sat, 29 Sep 2018 10:12:10 -0700 Subject: [PATCH] Relax test for nullability of translation columns The previous commit added a nullable subtitle field to location_names. This caused a test in test_schema.py to fail because the name field wasn't also nullable. A comment above the test says, "If there's more than one text column in a translation table they have to be nullable, to support missing translations", but i don't think that logic holds in this case. The idea is that we might have a translation for the subtitle, but not the name, or vice versa, so both need to be nullable in case one or the other is missing. But in this particular case that doesn't make sense: if you don't have a name, you don't have a location; it may or may not have a subtitle, but a location will always have a name. Therefore, add an exception to the test. --- pokedex/tests/test_schema.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pokedex/tests/test_schema.py b/pokedex/tests/test_schema.py index 0a17dc4..196c368 100644 --- a/pokedex/tests/test_schema.py +++ b/pokedex/tests/test_schema.py @@ -197,9 +197,11 @@ def test_texts(cls): pytest.fail("%s: description mentions English" % column) # If there's more than one text column in a translation table, # they have to be nullable, to support missing translations + # Exception: the 'name' column may be required, if none of the other + # columns make sense without it if hasattr(cls, 'local_language') and len(text_columns) > 1: for column in text_columns: - assert column.nullable + assert column.nullable or column.name == 'name' @parametrize('table', tables.mapped_classes) def test_identifiers_with_names(table):