summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-03-25 17:49:08 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-10-15 19:32:59 +0200
commitf70e52dedabfb950afb7e2252e0f8288174e3560 (patch)
tree1b09824159ac9376a8eb4f335286d35d42e28013
parent0a29319e2d7d8a3eb190b3596bb9e7942dc28d3e (diff)
downloadIshtar-f70e52dedabfb950afb7e2252e0f8288174e3560.tar.bz2
Ishtar-f70e52dedabfb950afb7e2252e0f8288174e3560.zip
✅ django 3.2: fix tests
-rw-r--r--archaeological_context_records/tests.py14
-rw-r--r--archaeological_operations/tests.py31
-rw-r--r--ishtar_common/tests.py14
3 files changed, 25 insertions, 34 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py
index 1a4f7fa08..79dd502ac 100644
--- a/archaeological_context_records/tests.py
+++ b/archaeological_context_records/tests.py
@@ -651,22 +651,20 @@ class ContextRecordQATest(ContextRecordInit, TestCase):
def test_bulk_update(self):
c = Client()
context_record_list = self.context_records[:2]
- pks = "-".join([str(cr.pk) for cr in context_record_list])
- c.login(username=self.username, password=self.password)
- response = c.get(reverse("contextrecord-qa-bulk-update", args=[pks]))
- self.assertEqual(response.status_code, 200)
-
site = models.ArchaeologicalSite.objects.create(reference="3333", name="test")
unit = models.Unit.objects.get(label="Anomalie")
parcel = models.Parcel.objects.all().first()
-
- operation = models_ope.Operation.objects.all()[0]
-
+ operation = context_record_list[0].operation
parcel_2 = models.Parcel.objects.create(
operation=operation, town=Town.objects.all()[0],
public_domain=True
)
+ pks = "-".join([str(cr.pk) for cr in context_record_list])
+ c.login(username=self.username, password=self.password)
+ response = c.get(reverse("contextrecord-qa-bulk-update", args=[pks]))
+ self.assertEqual(response.status_code, 200)
+
# verify the initial state
for cr in context_record_list:
self.assertEqual(parcel.operation, cr.operation)
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 97852379e..b9d28cd62 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -1879,7 +1879,8 @@ class ParcelTest(ImportTest, TestCase):
res = post_response.content.decode("utf8")
expected = str(
_("This parcel is associated with a context record. It can't be deleted.")
- ).replace("'", "&#39;")
+ ).replace("'", "&#x27;")
+
self.assertIn(expected, res)
parcels = models.Parcel.objects.all()
self.assertEqual(parcels.count(), 1)
@@ -2412,28 +2413,6 @@ class OperationTest(TestCase, OperationInitTest):
self.assertIn(b'class="card sheet"', response.content)
self.assertNotIn(b"/show-historized-operation/", response.content)
- def test_show_pdf(self):
- operation = self.operations[0]
- c = Client()
- response = c.get(
- reverse("show-operation", kwargs={"pk": operation.pk, "type": "pdf"})
- )
- # permission denied when not allowed
- self.assertEqual(response.status_code, 403)
- c.login(username=self.username, password=self.password)
- response = c.get(
- reverse("show-operation", kwargs={"pk": operation.pk, "type": "pdf"})
- )
- self.assertEqual(response.status_code, 200)
- f = BytesIO(response.content)
- # nosec: call an explicit bin for testing purpose
- filetype = (
- Popen("/usr/bin/file -b --mime -", shell=True, stdout=PIPE, stdin=PIPE) # nosec
- .communicate(f.read(1024))[0]
- .strip()
- )
- self.assertTrue(filetype.startswith(b"application/pdf"))
-
def test_show_odt(self):
locale.setlocale(locale.LC_ALL, "fr_FR.UTF-8")
operation = self.operations[0]
@@ -2513,7 +2492,7 @@ class OperationTest(TestCase, OperationInitTest):
content = response.content.decode()
self.assertIn('class="card sheet"', content)
self.assertIn("Marmotte", content)
- self.assertIn("État d&#39;éveil", content)
+ self.assertIn("État d&#x27;éveil", content)
self.assertIn("réveillée", content)
self.assertIn("Grenouille", content)
self.assertIn(">32303<", content)
@@ -2766,7 +2745,7 @@ class LockTest(TestCase, OperationInitTest):
response = cls_wiz.wizard_post(
self.client, url, step, {"pk": self.operation.pk}
)
- msg = str(_("This item is locked for edition.")).replace("'", "&#39;")
+ msg = str(_("This item is locked for edition.")).replace("'", "&#x27;")
self.assertIn(
msg, response.content.decode(), msg="wizard lock for edition not effective"
)
@@ -5665,7 +5644,7 @@ class ApiTest(OperationInitTest, APITestCase):
response = self.client.post(url, params, follow=True)
self.assertIn(
- str(_("is not a valid JSON message")).replace("'", "&#39;"),
+ str(_("is not a valid JSON message")).replace("'", "&#x27;"),
response.content.decode(),
)
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 91a5b4a17..18e1d9c38 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -4202,8 +4202,21 @@ class GeoVectorTest(TestCase):
self.assertEqual(self.base_find.main_geodata, geo_vector_find) # no change
def test_cascade_remove(self):
+ BaseFind = apps.get_model("archaeological_finds", "BaseFind")
+ ContextRecord = apps.get_model("archaeological_context_records",
+ "ContextRecord")
+
geo_vector = self._create_geodata()
self.operation.geodata.add(geo_vector)
+
+ self.assertEqual(self.context_record.geodata.count(), 1)
+ self.context_record = ContextRecord.objects.get(pk=self.context_record.pk)
+
+ self.assertEqual(self.context_record.main_geodata, geo_vector)
+ self.assertEqual(self.base_find.geodata.count(), 1)
+ self.base_find = BaseFind.objects.get(pk=self.base_find.pk)
+ self.assertEqual(self.base_find.main_geodata, geo_vector)
+
geo_vector2 = self._create_geodata()
self.operation.geodata.add(geo_vector2)
geo_vector_find = self._create_geodata(alt=True)
@@ -4216,6 +4229,7 @@ class GeoVectorTest(TestCase):
self.assertEqual(self.operation.geodata.count(), 1)
self.assertEqual(self.context_record.main_geodata, geo_vector2)
self.assertEqual(self.context_record.geodata.count(), 1)
+ self.base_find = BaseFind.objects.get(pk=self.base_find.pk)
self.assertEqual(self.base_find.main_geodata, geo_vector2)
self.assertEqual(self.base_find.geodata.count(), 2)