mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-07 15:29:21 +00:00
The model factories lived in the documents test package, but three other apps needed them. The AI, mail and testing suites all reached across an app boundary to import from documents.tests.factories, which made a private test package into a shared dependency. The factories now live in the shared testing package, where cross-app use is the intended use.
25 lines
886 B
Python
25 lines
886 B
Python
import pytest
|
|
|
|
from documents.models import Correspondent
|
|
from documents.models import Document
|
|
from paperless_testing.factories import CorrespondentFactory
|
|
from paperless_testing.factories import DocumentFactory
|
|
|
|
|
|
@pytest.mark.django_db
|
|
class TestDocument:
|
|
def test_correspondent_deletion_does_not_cascade(self) -> None:
|
|
assert Correspondent.objects.count() == 0
|
|
correspondent = CorrespondentFactory.create()
|
|
assert Correspondent.objects.count() == 1
|
|
|
|
assert Document.objects.count() == 0
|
|
DocumentFactory.create(correspondent=correspondent)
|
|
assert Document.objects.count() == 1
|
|
assert Document.objects.first().correspondent is not None
|
|
|
|
correspondent.delete()
|
|
assert Correspondent.objects.count() == 0
|
|
assert Document.objects.count() == 1
|
|
assert Document.objects.first().correspondent is None
|