Browse Source

Improve assertion feedback messages for test

pull/6/head
Marcio Mazza 10 years ago
parent
commit
b604413392
  1. 24
      legacy/test_migration.py

24
legacy/test_migration.py

@ -24,14 +24,22 @@ def test_get_renames():
else:
renamed = set(field_renames[model].keys())
# all renamed field references correspond to an actual field
assert renamed <= field_names
match_msg_template = 'All %s field names mentioned in renames ' \
'must match a %s field'
# check ignored fields in renaming
# all renamed field references correspond to a current field
assert renamed <= field_names, \
match_msg_template % ('new', 'current')
# ignored fields are explicitly listed
missing_in_renames = field_names - renamed
if missing_in_renames:
assert (model, missing_in_renames) in RENAMING_IGNORED_FIELDS
# all old names correspond to a legacy model field
legacy_model = legacy_app.get_model(model_renames.get(model, model.__name__))
assert set(field_renames[model].values()) <= {f.name for f in legacy_model._meta.fields}
assert (model, missing_in_renames) in RENAMING_IGNORED_FIELDS, \
'Field(s) missing in renames but not explicitly listed'
# all old names correspond to a legacy field
legacy_model = legacy_app.get_model(
model_renames.get(model, model.__name__))
legacy_field_names = {f.name for f in legacy_model._meta.fields}
assert set(field_renames[model].values()) <= legacy_field_names, \
match_msg_template % ('old', 'legacy')

Loading…
Cancel
Save