Skip to content

Commit

Permalink
Use ValidationError in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dalonsoa committed Jan 17, 2024
1 parent 9443b12 commit b21da1c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/measurement/test_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime

import pytz
from django.core.exceptions import ValidationError
from django.test import TestCase
from model_bakery import baker

Expand Down Expand Up @@ -149,7 +150,7 @@ def test_clean_validation(self):
# If becomes inactive but is not validated, there's an error
self.model.is_validated = False
self.model.is_active = False
with self.assertRaises(ValueError):
with self.assertRaises(ValidationError):
self.model.clean()

# If it is inactive but has been validated, then it is ok again
Expand All @@ -167,17 +168,17 @@ def test_clean_reporting(self):
# If either is false, then it cannot be used
self.model.is_validated = True
self.model.is_active = False
with self.assertRaises(ValueError):
with self.assertRaises(ValidationError):
self.model.clean()

self.model.is_validated = False
self.model.is_active = True
with self.assertRaises(ValueError):
with self.assertRaises(ValidationError):
self.model.clean()

self.model.is_validated = False
self.model.is_active = False
with self.assertRaises(ValueError):
with self.assertRaises(ValidationError):
self.model.clean()

def test_overwritten(self):
Expand Down

0 comments on commit b21da1c

Please sign in to comment.