Chore: Convert more testing to pytest style (#12678)

This commit is contained in:
Trenton H authored and GitHub committed 2026-04-30 11:40:11 -07:00
1 parent 59c08e84e2
commit b38d112691
6 files changed
+845 -626

No files matched your search

+11 -17
View File
@@ -1,4 +1,4 @@
from django.test import TestCase
import pytest
from documents.models import Correspondent
from documents.models import Document
@@ -6,25 +6,19 @@ from documents.tests.factories import CorrespondentFactory
from documents.tests.factories import DocumentFactory
class CorrespondentTestCase(TestCase):
def test___str__(self) -> None:
for s in ("test", "oχi", "test with fun_charÅc'\"terß"):
correspondent = CorrespondentFactory.create(name=s)
self.assertEqual(str(correspondent), s)
class DocumentTestCase(TestCase):
@pytest.mark.django_db
class TestDocument:
def test_correspondent_deletion_does_not_cascade(self) -> None:
self.assertEqual(Correspondent.objects.all().count(), 0)
assert Correspondent.objects.count() == 0
correspondent = CorrespondentFactory.create()
self.assertEqual(Correspondent.objects.all().count(), 1)
assert Correspondent.objects.count() == 1
self.assertEqual(Document.objects.all().count(), 0)
assert Document.objects.count() == 0
DocumentFactory.create(correspondent=correspondent)
self.assertEqual(Document.objects.all().count(), 1)
self.assertIsNotNone(Document.objects.all().first().correspondent)
assert Document.objects.count() == 1
assert Document.objects.first().correspondent is not None
correspondent.delete()
self.assertEqual(Correspondent.objects.all().count(), 0)
self.assertEqual(Document.objects.all().count(), 1)
self.assertIsNone(Document.objects.all().first().correspondent)
assert Correspondent.objects.count() == 0
assert Document.objects.count() == 1
assert Document.objects.first().correspondent is None