eastgenomics / trendyQC

Django app for monitoring trends in MultiQC data
MIT License
0 stars 0 forks source link

Improve assertion message in `get_metric_filter` #60

Open Yu-jinKim opened 5 months ago

Yu-jinKim commented 5 months ago
    # loop through the models and their fields to find in which model the
    # metric comes from
    for model in apps.get_models():
        model_name = model.__name__.lower()

        for field in model._meta.get_fields():
            if (field.name == form_metric) and (model_name == form_model):
                metric_filter_dict[model_name] = f"{model_name}__{field.name}"

    assert metric_filter_dict, f"{form_metric} does not exist in any model"

This confused me because my error during testing was in the (model_name == form_model) rather than the form_metric. So add model name in the assertion message