diff --git a/renovate.json b/renovate.json index 3a155500..afbc8134 100644 --- a/renovate.json +++ b/renovate.json @@ -9,12 +9,6 @@ "matchManagers": ["pep621"], "matchPackageNames": [] }, - { - "groupName": "allowed django versions", - "matchManagers": ["pep621"], - "matchPackageNames": ["Django"], - "allowedVersions": "<5.2" - }, { "groupName": "allowed redis versions", "matchManagers": ["pep621"], diff --git a/src/backend/core/factories.py b/src/backend/core/factories.py index d0a641d8..15245c39 100644 --- a/src/backend/core/factories.py +++ b/src/backend/core/factories.py @@ -35,6 +35,8 @@ class UserFactory(factory.django.DjangoModelFactory): class Meta: model = models.User + # Skip postgeneration save, no save is made in the postgeneration methods. + skip_postgeneration_save = True sub = factory.Sequence(lambda n: f"user{n!s}") email = factory.Faker("email") diff --git a/src/backend/core/migrations/0001_initial.py b/src/backend/core/migrations/0001_initial.py index 7f4d80ab..4eef49ee 100644 --- a/src/backend/core/migrations/0001_initial.py +++ b/src/backend/core/migrations/0001_initial.py @@ -504,7 +504,7 @@ class Migration(migrations.Migration): migrations.AddConstraint( model_name="documentaccess", constraint=models.CheckConstraint( - check=models.Q( + condition=models.Q( models.Q(("team", ""), ("user__isnull", False)), models.Q(("team__gt", ""), ("user__isnull", True)), _connector="OR", @@ -540,7 +540,7 @@ class Migration(migrations.Migration): migrations.AddConstraint( model_name="templateaccess", constraint=models.CheckConstraint( - check=models.Q( + condition=models.Q( models.Q(("team", ""), ("user__isnull", False)), models.Q(("team__gt", ""), ("user__isnull", True)), _connector="OR", diff --git a/src/backend/core/models.py b/src/backend/core/models.py index ff4a7062..a2599edf 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -520,7 +520,7 @@ class Document(MP_Node, BaseModel): verbose_name_plural = _("Documents") constraints = [ models.CheckConstraint( - check=( + condition=( models.Q(deleted_at__isnull=True) | models.Q(deleted_at=models.F("ancestors_deleted_at")) ), @@ -1088,7 +1088,7 @@ class DocumentAccess(BaseAccess): violation_error_message=_("This team is already in this document."), ), models.CheckConstraint( - check=models.Q(user__isnull=False, team="") + condition=models.Q(user__isnull=False, team="") | models.Q(user__isnull=True, team__gt=""), name="check_document_access_either_user_or_team", violation_error_message=_("Either user or team must be set, not both."), @@ -1236,7 +1236,7 @@ class TemplateAccess(BaseAccess): violation_error_message=_("This team is already in this template."), ), models.CheckConstraint( - check=models.Q(user__isnull=False, team="") + condition=models.Q(user__isnull=False, team="") | models.Q(user__isnull=True, team__gt=""), name="check_template_access_either_user_or_team", violation_error_message=_("Either user or team must be set, not both."), diff --git a/src/backend/core/tests/documents/test_api_documents_update_extract_attachments.py b/src/backend/core/tests/documents/test_api_documents_update_extract_attachments.py index 10c798f8..cf30b5e6 100644 --- a/src/backend/core/tests/documents/test_api_documents_update_extract_attachments.py +++ b/src/backend/core/tests/documents/test_api_documents_update_extract_attachments.py @@ -47,7 +47,7 @@ def test_api_documents_update_new_attachment_keys_anonymous(django_assert_num_qu factories.DocumentFactory(attachments=[image_keys[3]], link_reach="restricted") expected_keys = {image_keys[i] for i in [0, 1]} - with django_assert_num_queries(9): + with django_assert_num_queries(11): response = APIClient().put( f"/api/v1.0/documents/{document.id!s}/", {"content": get_ydoc_with_mages(image_keys)}, @@ -60,7 +60,7 @@ def test_api_documents_update_new_attachment_keys_anonymous(django_assert_num_qu # Check that the db query to check attachments readability for extracted # keys is not done if the content changes but no new keys are found - with django_assert_num_queries(5): + with django_assert_num_queries(7): response = APIClient().put( f"/api/v1.0/documents/{document.id!s}/", {"content": get_ydoc_with_mages(image_keys[:2])}, @@ -98,7 +98,7 @@ def test_api_documents_update_new_attachment_keys_authenticated( factories.DocumentFactory(attachments=[image_keys[4]], users=[user]) expected_keys = {image_keys[i] for i in [0, 1, 2, 4]} - with django_assert_num_queries(10): + with django_assert_num_queries(12): response = client.put( f"/api/v1.0/documents/{document.id!s}/", {"content": get_ydoc_with_mages(image_keys)}, @@ -111,7 +111,7 @@ def test_api_documents_update_new_attachment_keys_authenticated( # Check that the db query to check attachments readability for extracted # keys is not done if the content changes but no new keys are found - with django_assert_num_queries(6): + with django_assert_num_queries(8): response = client.put( f"/api/v1.0/documents/{document.id!s}/", {"content": get_ydoc_with_mages(image_keys[:2])}, diff --git a/src/backend/core/tests/test_models_documents.py b/src/backend/core/tests/test_models_documents.py index 01d5181e..ae10fb55 100644 --- a/src/backend/core/tests/test_models_documents.py +++ b/src/backend/core/tests/test_models_documents.py @@ -1064,7 +1064,7 @@ def test_models_documents_restore(django_assert_num_queries): assert document.deleted_at is not None assert document.ancestors_deleted_at == document.deleted_at - with django_assert_num_queries(8): + with django_assert_num_queries(10): document.restore() document.refresh_from_db() assert document.deleted_at is None @@ -1107,7 +1107,7 @@ def test_models_documents_restore_complex(django_assert_num_queries): assert child2.ancestors_deleted_at == document.deleted_at # Restore the item - with django_assert_num_queries(11): + with django_assert_num_queries(13): document.restore() document.refresh_from_db() child1.refresh_from_db() @@ -1157,7 +1157,7 @@ def test_models_documents_restore_complex_bis(django_assert_num_queries): # Restoring the grand parent should not restore the document # as it was deleted before the grand parent - with django_assert_num_queries(9): + with django_assert_num_queries(11): grand_parent.restore() grand_parent.refresh_from_db() diff --git a/src/backend/impress/settings.py b/src/backend/impress/settings.py index 05d89443..5d16e165 100755 --- a/src/backend/impress/settings.py +++ b/src/backend/impress/settings.py @@ -849,6 +849,9 @@ class Test(Base): "django.contrib.auth.hashers.MD5PasswordHasher", ] USE_SWAGGER = True + # Static files are not used in the test environment + # Tests are raising warnings because the /data/static directory does not exist + STATIC_ROOT = None CELERY_TASK_ALWAYS_EAGER = values.BooleanValue(True) diff --git a/src/backend/pyproject.toml b/src/backend/pyproject.toml index f681c125..a5fd08c8 100644 --- a/src/backend/pyproject.toml +++ b/src/backend/pyproject.toml @@ -38,7 +38,7 @@ dependencies = [ "django-redis==5.4.0", "django-storages[s3]==1.14.6", "django-timezone-field>=5.1", - "django==5.1.10", + "django==5.2.3", "django-treebeard==4.7.1", "djangorestframework==3.16.0", "drf_spectacular==0.28.0",