Compare commits

..

5 Commits

Author SHA1 Message Date
Trenton Holmes
912d3840df Adds some end to end generate testing with the localization 2025-08-12 09:44:59 -07:00
Trenton Holmes
282611a833 Don't let codespell break this test 2025-08-12 09:44:59 -07:00
Trenton Holmes
7b92db189f Adds testing coverage plus a check for the locale being valid 2025-08-12 09:44:59 -07:00
Trenton Holmes
61813fab65 Initial work on a localize date filter 2025-08-12 09:44:59 -07:00
dependabot[bot]
ee6b700243 docker(deps): Bump astral-sh/uv (#10564)
Bumps [astral-sh/uv](https://github.com/astral-sh/uv) from 0.8.4-python3.12-bookworm-slim to 0.8.8-python3.12-bookworm-slim.
- [Release notes](https://github.com/astral-sh/uv/releases)
- [Changelog](https://github.com/astral-sh/uv/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/uv/compare/0.8.4...0.8.8)

---
updated-dependencies:
- dependency-name: astral-sh/uv
  dependency-version: 0.8.8-python3.12-bookworm-slim
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-12 06:39:43 -07:00
2 changed files with 34 additions and 1 deletions

View File

@@ -32,7 +32,7 @@ RUN set -eux \
# Purpose: Installs s6-overlay and rootfs
# Comments:
# - Don't leave anything extra in here either
FROM ghcr.io/astral-sh/uv:0.8.4-python3.12-bookworm-slim AS s6-overlay-base
FROM ghcr.io/astral-sh/uv:0.8.8-python3.12-bookworm-slim AS s6-overlay-base
WORKDIR /usr/src/s6

View File

@@ -24,6 +24,7 @@ from documents.models import DocumentType
from documents.models import StoragePath
from documents.tasks import empty_trash
from documents.templating.filepath import localize_date
from documents.tests.factories import DocumentFactory
from documents.tests.utils import DirectoriesMixin
from documents.tests.utils import FileSystemAssertsMixin
@@ -1749,3 +1750,35 @@ class TestDateLocalization:
localize_date(self.TEST_DATE, "medium", "invalid_locale_code")
assert "Invalid locale identifier" in str(excinfo.value)
@pytest.mark.django_db
@pytest.mark.parametrize(
"filename_format,expected_filename",
[
pytest.param(
"{{title}}_{{ document.created | localize_date('MMMM', 'es_ES')}}",
"My Document_octubre.pdf",
id="spanish_month_name",
),
pytest.param(
"{{title}}_{{ document.created | localize_date('EEEE', 'fr_FR')}}",
"My Document_jeudi.pdf",
id="french_day_of_week",
),
pytest.param(
"{{title}}_{{ document.created | localize_date('dd/MM/yyyy', 'en_GB')}}",
"My Document_26/10/2023.pdf",
id="uk_date_format",
),
],
)
def test_localize_date_path_building(self, filename_format, expected_filename):
document = DocumentFactory.create(
title="My Document",
mime_type="application/pdf",
storage_type=Document.STORAGE_TYPE_UNENCRYPTED,
created=self.TEST_DATE, # 2023-10-26 (which is a Thursday)
)
with override_settings(FILENAME_FORMAT=filename_format):
filename = generate_filename(document)
assert filename == Path(expected_filename)