mirror of https://github.com/interlegis/sapl.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
837 B
32 lines
837 B
from django.apps import apps
|
|
|
|
|
|
appconfs = [apps.get_app_config(n) for n in [
|
|
'parlamentares',
|
|
'comissoes',
|
|
'sessao',
|
|
'materia',
|
|
'norma',
|
|
'lexml',
|
|
'protocoloadm', ]]
|
|
name_sets = [set(m.__name__ for m in ac.get_models()) for ac in appconfs]
|
|
|
|
# apps do not overlap
|
|
for s1 in name_sets:
|
|
for s2 in name_sets:
|
|
if s1 is not s2:
|
|
assert not s1.intersection(s2)
|
|
|
|
# apps include all legacy models
|
|
legacy_app = apps.get_app_config('legacy')
|
|
legacy_model_names = set(m.__name__ for m in legacy_app.get_models())
|
|
all_names = set()
|
|
for s1 in name_sets:
|
|
all_names = all_names.union(s1)
|
|
assert all_names == legacy_model_names
|
|
|
|
|
|
def has_primary_key(model):
|
|
return any(field.primary_key for field in model._meta.fields)
|
|
|
|
assert all(has_primary_key(model) for model in legacy_app.models.values())
|
|
|