From 8c619b923d3533b30ebcc69e582598896adc0544 Mon Sep 17 00:00:00 2001 From: Sylvain Boissel Date: Wed, 30 Oct 2024 18:05:30 +0100 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20Mise=20=C3=A0=20jour=20des=20pictogr?= =?UTF-8?q?ammes=20lors=20des=20mises=20=C3=A0=20jour=20(#232)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Launch the import_dsfr_pictograms script during updates * Update tests --- Makefile | 3 ++- Procfile | 2 +- .../commands/import_dsfr_pictograms.py | 13 ++++------ content_manager/tests/test_blocks.py | 24 +++++++++++++++++++ content_manager/tests/test_views.py | 1 + forms/tests/test_forms.py | 1 + 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index bf791656..ef2fad72 100644 --- a/Makefile +++ b/Makefile @@ -64,8 +64,9 @@ init-dev: update: $(EXEC_CMD) poetry install --without dev $(EXEC_CMD) poetry run python manage.py migrate - $(EXEC_CMD) poetry run python manage.py import_page_templates make collectstatic + $(EXEC_CMD) poetry run python manage.py import_dsfr_pictograms + $(EXEC_CMD) poetry run python manage.py import_page_templates make index diff --git a/Procfile b/Procfile index b0d9aa20..fc465ec1 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -postdeploy: python manage.py migrate && python manage.py import_page_templates && python manage.py update_index +postdeploy: python manage.py migrate && python manage.py import_dsfr_pictograms && python manage.py import_page_templates && python manage.py update_index web: gunicorn config.wsgi --log-file - diff --git a/content_manager/management/commands/import_dsfr_pictograms.py b/content_manager/management/commands/import_dsfr_pictograms.py index 85796883..2ca51fb3 100644 --- a/content_manager/management/commands/import_dsfr_pictograms.py +++ b/content_manager/management/commands/import_dsfr_pictograms.py @@ -1,6 +1,5 @@ import os -from django.core.management import call_command from django.core.management.base import BaseCommand from wagtail.images.models import Image @@ -9,15 +8,13 @@ class Command(BaseCommand): - help = """Import all the pictograms from the DSFR""" + help = """ + Import all the pictograms from the DSFR. - def handle(self, *args, **kwargs): - call_command( - "collectstatic", - "--ignore=*.sass", - interactive=False, - ) + Should only be launched if the statics have been collected at least once. + """ + def handle(self, *args, **kwargs): picto_root = "staticfiles/dsfr/dist/artwork/pictograms/" picto_folders = os.listdir(picto_root) picto_folders.sort() diff --git a/content_manager/tests/test_blocks.py b/content_manager/tests/test_blocks.py index 7843a212..f318b8d9 100644 --- a/content_manager/tests/test_blocks.py +++ b/content_manager/tests/test_blocks.py @@ -322,6 +322,30 @@ def test_tile_with_image_has_div(self): self.assertContains(response, "fr-tile__header") + def test_tile_manages_svg_image(self): + image_file = "static/artwork/technical-error.svg" + image = import_image(image_file, "Sample image") + + body = [ + ( + "tile", + { + "title": "Sample tile", + "description": RichText('

This is a sample tile.

'), + "image": image, + }, + ) + ] + + self.content_page.body = body + self.content_page.save() + + url = self.content_page.url + + response = self.client.get(url) + + self.assertContains(response, "fr-tile__pictogram") + class BlogRecentEntriesBlockTestCase(WagtailPageTestCase): def setUp(self): diff --git a/content_manager/tests/test_views.py b/content_manager/tests/test_views.py index db9a6636..34f62c3c 100644 --- a/content_manager/tests/test_views.py +++ b/content_manager/tests/test_views.py @@ -159,6 +159,7 @@ def test_footer_description_uses_conf(self): class MenusTestCase(WagtailPageTestCase): @classmethod def setUpTestData(cls) -> None: + call_command("collectstatic", "--ignore=*.sass", interactive=False) call_command("create_starter_pages") def setUp(self) -> None: diff --git a/forms/tests/test_forms.py b/forms/tests/test_forms.py index b4bb4545..946c3f0a 100644 --- a/forms/tests/test_forms.py +++ b/forms/tests/test_forms.py @@ -7,6 +7,7 @@ class FormsTestCase(WagtailPageTestCase): @classmethod def setUpTestData(cls) -> None: + call_command("collectstatic", "--ignore=*.sass", interactive=False) call_command("create_starter_pages") def test_form_page_is_renderable(self):