fix(): fixed bugs with cache invalidation, notifications and guardrails
This commit is contained in:
@@ -86,6 +86,14 @@ def _extract_django_rejected_value(
|
||||
return None
|
||||
|
||||
|
||||
def _extract_django_issue(
|
||||
error: django.core.exceptions.ValidationError,
|
||||
) -> str:
|
||||
if error.messages:
|
||||
return str(error.messages[0])
|
||||
return str(error.message)
|
||||
|
||||
|
||||
def handle_django_validation_error(
|
||||
request: HttpRequest,
|
||||
exc: django.core.exceptions.ValidationError,
|
||||
@@ -99,7 +107,7 @@ def handle_django_validation_error(
|
||||
field_errors_data.extend(
|
||||
{
|
||||
"field": field,
|
||||
"issue": str(error.message),
|
||||
"issue": _extract_django_issue(error),
|
||||
"rejected_value": _extract_django_rejected_value(error),
|
||||
}
|
||||
for error in errors
|
||||
@@ -108,7 +116,7 @@ def handle_django_validation_error(
|
||||
field_errors_data.extend(
|
||||
{
|
||||
"field": "non_field_error",
|
||||
"issue": str(error.message),
|
||||
"issue": _extract_django_issue(error),
|
||||
"rejected_value": _extract_django_rejected_value(error),
|
||||
}
|
||||
for error in exc.error_list
|
||||
|
||||
@@ -159,3 +159,14 @@ class ExperimentReportAPITest(TestCase):
|
||||
HTTP_AUTHORIZATION=self.auth,
|
||||
)
|
||||
self.assertEqual(resp.status_code, 404)
|
||||
|
||||
def test_report_invalid_start_date_returns_422(self) -> None:
|
||||
resp = self.client.get(
|
||||
reverse(
|
||||
"api-1:get_experiment_report",
|
||||
args=[self.experiment.pk],
|
||||
),
|
||||
{"start_date": "not-a-date"},
|
||||
HTTP_AUTHORIZATION=self.auth,
|
||||
)
|
||||
self.assertEqual(resp.status_code, 422)
|
||||
|
||||
Reference in New Issue
Block a user