Coverage for backend/django/diagnostics/models/DiagnosticsResult.py: 100%
16 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-06-23 21:51 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-06-23 21:51 +0000
1from django.db import models
2from typing import get_args, Literal
3from core.auxiliary.models.PropertyValue import PropertyValue
4from flowsheetInternals.unitops.models.SimulationObject import SimulationObject
5from core.managers import AccessControlManager
7class SeverityChoices(models.TextChoices):
8 INFO = "info", "Info"
9 WARNING = "warning", "Warning"
10 ERROR = "error", "Error"
12# Severity levels expected by the frontend.
13Severity = Literal["error", "warning", "info", "suggestion"]
15class DiagnosticsResult(models.Model):
16 """
17 This stores the results of diagnostics findings from the most recent
18 IDAES solve, which can be used to display warnings and errors on the frontend.
19 """
20 flowsheet = models.ForeignKey("core_auxiliary.Flowsheet", on_delete=models.CASCADE, related_name="diagnosticResults")
21 propertyValue = models.ForeignKey(PropertyValue, on_delete=models.CASCADE, related_name="diagnosticResults", null=True)
22 severity = models.CharField(choices=SeverityChoices.choices, default=SeverityChoices.INFO)
23 message = models.TextField()
26 objects = AccessControlManager()