Skip to content

Commit 1fa1932

Browse files
committed
fix(spp_metrics_services): use savepoint for SQL unique constraint test
1 parent c45290a commit 1fa1932

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

spp_metrics_services/tests/test_coverage.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -478,16 +478,17 @@ def test_constraint_expression_type_without_expression(self):
478478
)
479479

480480
def test_constraint_unique_name(self):
481-
"""Duplicate dimension name raises an error."""
482-
with self.assertRaises(ValidationError):
483-
self.dim_model.create(
484-
{
485-
"name": "test_is_group", # already exists
486-
"label": "Duplicate",
487-
"dimension_type": "field",
488-
"field_path": "name",
489-
}
490-
)
481+
"""Duplicate dimension name raises an error (SQL unique constraint)."""
482+
with self.assertRaises(Exception): # noqa: B017
483+
with self.env.cr.savepoint():
484+
self.dim_model.create(
485+
{
486+
"name": "test_is_group", # already exists
487+
"label": "Duplicate",
488+
"dimension_type": "field",
489+
"field_path": "name",
490+
}
491+
)
491492

492493
# -------------------------------------------------------------------------
493494
# write() and unlink() cache invalidation

0 commit comments

Comments
 (0)