mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-09-14 21:45:37 -05:00
Add test for invalid tag hierarchy recursion error
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
from rest_framework.test import APITestCase
|
from rest_framework.test import APITestCase
|
||||||
|
|
||||||
from documents import bulk_edit
|
from documents import bulk_edit
|
||||||
@@ -191,3 +192,14 @@ class TestTagHierarchy(APITestCase):
|
|||||||
assert resp_ok.status_code in (200, 202)
|
assert resp_ok.status_code in (200, 202)
|
||||||
x.refresh_from_db()
|
x.refresh_from_db()
|
||||||
assert x.parent_id == c.id
|
assert x.parent_id == c.id
|
||||||
|
|
||||||
|
def test_invalid_hierarchy_recursion_error(self):
|
||||||
|
t = Tag.objects.create(name="TagA")
|
||||||
|
|
||||||
|
with mock.patch(
|
||||||
|
"documents.models.Tag.subtree_height",
|
||||||
|
side_effect=RecursionError,
|
||||||
|
):
|
||||||
|
with self.assertRaises(ValidationError) as cm:
|
||||||
|
t.clean()
|
||||||
|
assert "Invalid tag hierarchy" in str(cm.exception)
|
||||||
|
Reference in New Issue
Block a user