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.
This commit is contained in:
Andrew Ekstedt 2018-09-29 10:12:10 -07:00
parent 083e43bb93
commit e6b64b8c5a

View file

@ -197,9 +197,11 @@ def test_texts(cls):
pytest.fail("%s: description mentions English" % column) pytest.fail("%s: description mentions English" % column)
# If there's more than one text column in a translation table, # If there's more than one text column in a translation table,
# they have to be nullable, to support missing translations # 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: if hasattr(cls, 'local_language') and len(text_columns) > 1:
for column in text_columns: for column in text_columns:
assert column.nullable assert column.nullable or column.name == 'name'
@parametrize('table', tables.mapped_classes) @parametrize('table', tables.mapped_classes)
def test_identifiers_with_names(table): def test_identifiers_with_names(table):