diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-02-24 15:16:56 +0100 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-02-25 10:15:33 +0100 |
| commit | 53b408380649f39880763b35a2a9d24eb7cc014a (patch) | |
| tree | 4a932ebc46229239d7bcb9e21f36ce84efa969c9 /ishtar_common/tests.py | |
| parent | 13e838988e0a32e0ef54c15d90c8df2f92dad853 (diff) | |
| download | Ishtar-53b408380649f39880763b35a2a9d24eb7cc014a.tar.bz2 Ishtar-53b408380649f39880763b35a2a9d24eb7cc014a.zip | |
♻️ imports: simplify, refactor and clean
Diffstat (limited to 'ishtar_common/tests.py')
| -rw-r--r-- | ishtar_common/tests.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 304353efc..022783f64 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -54,11 +54,11 @@ from django.db import transaction from django.db.models.fields import BooleanField from django.db.models.fields.related import ForeignKey from django.db.utils import IntegrityError -from django.template.defaultfilters import slugify from django.test import TestCase as BaseTestCase from django.test.client import Client from django.test.runner import DiscoverRunner from django.utils import timezone +from django.utils.text import slugify from django.utils.translation import gettext_lazy as _ from django.urls import reverse @@ -3358,7 +3358,8 @@ class ImportTest(BaseImportTest): ot = models.OrganizationType.objects.create(label=label) self.assertEqual( models.ItemKey.objects.filter( - object_id=ot.pk, key=slugify(label), content_type=content_type + object_id=ot.pk, key=slugify(label, allow_unicode=True), + content_type=content_type ).count(), 1, ) @@ -3366,24 +3367,26 @@ class ImportTest(BaseImportTest): ot_2 = models.OrganizationType.objects.create(label=label_2) self.assertEqual( models.ItemKey.objects.filter( - object_id=ot_2.pk, key=slugify(label_2), content_type=content_type + object_id=ot_2.pk, key=slugify(label_2, allow_unicode=True), + content_type=content_type ).count(), 1, ) # replace key - ot_2.add_key(slugify(label), force=True) + ot_2.add_key(slugify(label, allow_unicode=True), force=True) # one key point to only one item self.assertEqual( models.ItemKey.objects.filter( - key=slugify(label), content_type=content_type + key=slugify(label, allow_unicode=True), content_type=content_type ).count(), 1, ) # this key point to the right item self.assertEqual( models.ItemKey.objects.filter( - object_id=ot_2.pk, key=slugify(label), content_type=content_type + object_id=ot_2.pk, key=slugify(label, allow_unicode=True), + content_type=content_type ).count(), 1, ) @@ -3391,12 +3394,13 @@ class ImportTest(BaseImportTest): # modification label_3 = "Yop" ot_2.label = label_3 - ot_2.txt_idx = slugify(label_3) + ot_2.txt_idx = slugify(label_3, allow_unicode=True) ot_2.save() # old label not referenced anymore self.assertEqual( models.ItemKey.objects.filter( - object_id=ot_2.pk, key=slugify(label_2), content_type=content_type + object_id=ot_2.pk, key=slugify(label_2, allow_unicode=True), + content_type=content_type ).count(), 0, ) @@ -3404,13 +3408,15 @@ class ImportTest(BaseImportTest): # new key is here self.assertEqual( models.ItemKey.objects.filter( - object_id=ot_2.pk, key=slugify(label), content_type=content_type + object_id=ot_2.pk, key=slugify(label, allow_unicode=True), + content_type=content_type ).count(), 1, ) self.assertEqual( models.ItemKey.objects.filter( - object_id=ot_2.pk, key=slugify(label_3), content_type=content_type + object_id=ot_2.pk, key=slugify(label_3, allow_unicode=True), + content_type=content_type ).count(), 1, ) |
