summaryrefslogtreecommitdiff
path: root/archaeological_context_records/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records/tests.py')
-rw-r--r--archaeological_context_records/tests.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py
index 942ad83f1..0338a2f20 100644
--- a/archaeological_context_records/tests.py
+++ b/archaeological_context_records/tests.py
@@ -24,6 +24,7 @@ import locale
from django.apps import apps
from django.conf import settings
from django.contrib.auth.models import Permission, Group
+from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
from django.template.defaultfilters import slugify
@@ -600,6 +601,35 @@ class ContextRecordTest(ContextRecordInit, TestCase):
# same unit and other operation -> 1
self.assertEqual(cr3.custom_index, 1)
+ def test_cascade_delete(self):
+ cr1 = self.context_records[0]
+ # add a geo_vector associated to the town
+ source_content_type_pk = ContentType.objects.get(
+ app_label="ishtar_common",
+ model="town"
+ ).pk
+ geo_vector = models.GeoVectorData.objects.create(
+ source_content_type_id=source_content_type_pk,
+ source_id=cr1.town_id,
+ name="geo",
+ comment="This is a comment."
+ )
+ cr1.geodata.add(geo_vector)
+ BaseFind = apps.get_model("archaeological_finds", "BaseFind")
+ bf = BaseFind.objects.create(context_record=cr1)
+ bf.geodata.add(geo_vector)
+ Find = apps.get_model("archaeological_finds", "Find")
+ find = Find.objects.create()
+ bf.find.add(find)
+ dating = models.ContextRecordDating.objects.create(context_record=cr1)
+ cr1.operation.delete()
+ self.assertEqual(models.ContextRecord.objects.filter(id=cr1.id).count(), 0)
+ self.assertEqual(Find.objects.filter(id=find.id).count(), 0)
+ self.assertEqual(BaseFind.objects.filter(id=bf.id).count(), 0)
+ self.assertEqual(models.ContextRecordDating.objects.filter(id=dating.id).count(),
+ 0)
+ self.assertEqual(models.GeoVectorData.objects.filter(id=geo_vector.id).count(), 1)
+
class ContextRecordQATest(ContextRecordInit, TestCase):
fixtures = CONTEXT_RECORD_TOWNS_FIXTURES