From 42b51ff283d2cfd8b2084d131e81179e1d614023 Mon Sep 17 00:00:00 2001 From: "Ph. SW." Date: Tue, 22 Oct 2024 21:14:35 +0200 Subject: [PATCH] =?UTF-8?q?Supprime=20le=20param=C3=A8tre=20`build=5Fpdf?= =?UTF-8?q?=5Fwhen=5Fpublished`=20et=20d=C3=A9sactive=20plus=20d'exports?= =?UTF-8?q?=20dans=20les=20tests=20(#6670)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/source/back-end/contents.rst | 1 - zds/settings/abstract_base/zds.py | 1 - zds/settings/prod.py | 1 - zds/tutorialv2/publication_utils.py | 8 +------- zds/tutorialv2/tests/__init__.py | 1 - zds/tutorialv2/tests/tests_feeds.py | 7 +------ zds/tutorialv2/tests/tests_front.py | 3 +-- zds/tutorialv2/tests/tests_utils.py | 6 ------ zds/tutorialv2/tests/tests_views/tests_content.py | 2 -- zds/tutorialv2/tests/tests_views/tests_published.py | 4 +--- zds/utils/api/tests.py | 11 ++++++----- 11 files changed, 10 insertions(+), 35 deletions(-) diff --git a/doc/source/back-end/contents.rst b/doc/source/back-end/contents.rst index dd98c3422e..c8a369940b 100644 --- a/doc/source/back-end/contents.rst +++ b/doc/source/back-end/contents.rst @@ -602,7 +602,6 @@ Ces paramètres sont à surcharger dans le dictionnaire ``ZDS_APP['content']``: - ``user_page_number``: Nombre de contenus de chaque type qu'on affiche sur le profil d'un utilisateur, 5 par défaut, - ``default_image``: chemin vers l'image utilisée par défaut dans les icônes de contenu, - ``import_image_prefix``: préfixe mnémonique permettant d'indiquer que l'image se trouve dans l'archive jointe lors de l'import de contenu -- ``build_pdf_when_published``: indique que la publication générera un PDF (quelque soit la politique, si ``False``, les PDF ne seront pas générés, sauf à appeler la commande adéquate), - ``maximum_slug_size``: taille maximale du slug d'un contenu Paramètres propres aux tribunes libres diff --git a/zds/settings/abstract_base/zds.py b/zds/settings/abstract_base/zds.py index 29ad9724d9..94342f1b02 100644 --- a/zds/settings/abstract_base/zds.py +++ b/zds/settings/abstract_base/zds.py @@ -190,7 +190,6 @@ "user_page_number": 5, "default_image": BASE_DIR / "fixtures" / "noir_black.png", "import_image_prefix": "archive", - "build_pdf_when_published": True, "maximum_slug_size": 150, "characters_per_minute": 1500, "editorial_line_link": "https://zestedesavoir.com/articles/3978/la-ligne-editoriale-officielle-de-zeste-de-savoir-2/", diff --git a/zds/settings/prod.py b/zds/settings/prod.py index 8453c5c287..3fdc86a2ed 100644 --- a/zds/settings/prod.py +++ b/zds/settings/prod.py @@ -129,7 +129,6 @@ def _get_version(): ZDS_APP["site"]["association"]["email"] = "communication@zestedesavoir.com" # content -# ZDS_APP['content']['build_pdf_when_published'] = False ZDS_APP["article"]["repo_path"] = "/opt/zds/data/articles-data" ZDS_APP["content"]["repo_private_path"] = "/opt/zds/data/contents-private" ZDS_APP["content"]["repo_public_path"] = "/opt/zds/data/contents-public" diff --git a/zds/tutorialv2/publication_utils.py b/zds/tutorialv2/publication_utils.py index 59fd7a5a47..99dd9f1e06 100644 --- a/zds/tutorialv2/publication_utils.py +++ b/zds/tutorialv2/publication_utils.py @@ -174,22 +174,16 @@ def write_md_file(md_file_path, parsed_with_local_images, versioned): ) -def generate_external_content( - base_name, extra_contents_path, md_file_path, overload_settings=False, excluded=None, **kwargs -): +def generate_external_content(base_name, extra_contents_path, md_file_path, excluded=None, **kwargs): """ generate all static file that allow offline access to content :param base_name: base nae of file (without extension) :param extra_contents_path: internal directory where all files will be pushed :param md_file_path: bundled markdown file path - :param overload_settings: this option force the function to generate all registered formats even when settings \ - ask for PDF not to be published :param excluded: list of excluded format, None if no exclusion """ excluded = excluded or ["watchdog"] - if not settings.ZDS_APP["content"]["build_pdf_when_published"] and not overload_settings: - excluded.append("pdf") for publicator_name, publicator in PublicatorRegistry.get_all_registered(excluded): try: publicator.publish( diff --git a/zds/tutorialv2/tests/__init__.py b/zds/tutorialv2/tests/__init__.py index af18f67a13..132967f8a7 100644 --- a/zds/tutorialv2/tests/__init__.py +++ b/zds/tutorialv2/tests/__init__.py @@ -14,7 +14,6 @@ overridden_zds_app["content"]["repo_private_path"] = settings.BASE_DIR / "contents-private-test" overridden_zds_app["content"]["repo_public_path"] = settings.BASE_DIR / "contents-public-test" overridden_zds_app["content"]["extra_content_generation_policy"] = "SYNC" -overridden_zds_app["content"]["build_pdf_when_published"] = False class override_for_contents(override_settings): diff --git a/zds/tutorialv2/tests/tests_feeds.py b/zds/tutorialv2/tests/tests_feeds.py index d165c5d73b..aad9605710 100644 --- a/zds/tutorialv2/tests/tests_feeds.py +++ b/zds/tutorialv2/tests/tests_feeds.py @@ -30,6 +30,7 @@ overridden_zds_app = deepcopy(settings.ZDS_APP) overridden_zds_app["content"]["repo_private_path"] = settings.BASE_DIR / "contents-private-test" overridden_zds_app["content"]["repo_public_path"] = settings.BASE_DIR / "contents-public-test" +overridden_zds_app["content"]["extra_content_generation_policy"] = "NOTHING" @override_settings(MEDIA_ROOT=settings.BASE_DIR / "media-test") @@ -37,8 +38,6 @@ class LastTutorialsFeedsTest(TutorialTestMixin, TestCase): def setUp(self): self.overridden_zds_app = overridden_zds_app - # don't build PDF to speed up the tests - overridden_zds_app["content"]["build_pdf_when_published"] = False self.licence = LicenceFactory() self.subcategory = SubCategoryFactory() @@ -225,8 +224,6 @@ def test_content_control_chars(self): class LastArticlesFeedsTest(TutorialTestMixin, TestCase): def setUp(self): self.overridden_zds_app = overridden_zds_app - # don't build PDF to speed up the tests - overridden_zds_app["content"]["build_pdf_when_published"] = False self.licence = LicenceFactory() self.subcategory = SubCategoryFactory() @@ -411,8 +408,6 @@ def test_content_control_chars(self): class LastOpinionsFeedsTest(TutorialTestMixin, TestCase): def setUp(self): self.overridden_zds_app = overridden_zds_app - # don't build PDF to speed up the tests - overridden_zds_app["content"]["build_pdf_when_published"] = False self.subcategory = SubCategoryFactory() self.tag = TagFactory() diff --git a/zds/tutorialv2/tests/tests_front.py b/zds/tutorialv2/tests/tests_front.py index d3322afd39..a7e439160a 100644 --- a/zds/tutorialv2/tests/tests_front.py +++ b/zds/tutorialv2/tests/tests_front.py @@ -26,6 +26,7 @@ overridden_zds_app = deepcopy(settings.ZDS_APP) overridden_zds_app["content"]["repo_private_path"] = settings.BASE_DIR / "contents-private-test" overridden_zds_app["content"]["repo_public_path"] = settings.BASE_DIR / "contents-public-test" +overridden_zds_app["content"]["extra_content_generation_policy"] = "NOTHING" @override_settings(MEDIA_ROOT=settings.BASE_DIR / "media-test") @@ -52,8 +53,6 @@ def tearDown(self): def setUp(self): self.overridden_zds_app = overridden_zds_app - # don't build PDF to speed up the tests - overridden_zds_app["content"]["build_pdf_when_published"] = False self.staff = StaffProfileFactory().user diff --git a/zds/tutorialv2/tests/tests_utils.py b/zds/tutorialv2/tests/tests_utils.py index c3bcc62e2d..f1a5cb40dd 100644 --- a/zds/tutorialv2/tests/tests_utils.py +++ b/zds/tutorialv2/tests/tests_utils.py @@ -342,8 +342,6 @@ def test_generate_markdown(self): def test_generate_pdf(self): """ensure the behavior of the `python manage.py generate_pdf` commmand""" - self.overridden_zds_app["content"]["build_pdf_when_published"] = True # this test need PDF build, if any - tuto = PublishedContentFactory(type="TUTORIAL") # generate and publish a tutorial published = PublishedContent.objects.get(content_pk=tuto.pk) @@ -596,9 +594,6 @@ def setUp(self): self.user_author = ProfileFactory().user self.old_registry = {key: value for key, value in PublicatorRegistry.get_all_registered()} - self.old_build_pdf_when_published = self.overridden_zds_app["content"]["build_pdf_when_published"] - - self.overridden_zds_app["content"]["build_pdf_when_published"] = True def get_latex_file_path(self, published: PublishedContent): """ @@ -856,4 +851,3 @@ def check(path): def tearDown(self): super().tearDown() PublicatorRegistry.registry = self.old_registry - self.overridden_zds_app["content"]["build_pdf_when_published"] = self.old_build_pdf_when_published diff --git a/zds/tutorialv2/tests/tests_views/tests_content.py b/zds/tutorialv2/tests/tests_views/tests_content.py index 2c629e1109..35a58674f1 100644 --- a/zds/tutorialv2/tests/tests_views/tests_content.py +++ b/zds/tutorialv2/tests/tests_views/tests_content.py @@ -2732,8 +2732,6 @@ def test_publication_make_extra_contents(self): NOTE: this test will take time !""" PublicatorRegistry.registry["pdf"] = ZMarkdownRebberLatexPublicator(".pdf") PublicatorRegistry.registry["epub"] = ZMarkdownEpubPublicator() - # obviously, PDF builds have to be enabled - self.overridden_zds_app["content"]["build_pdf_when_published"] = True title = "C'est pas le plus important ici !" diff --git a/zds/tutorialv2/tests/tests_views/tests_published.py b/zds/tutorialv2/tests/tests_views/tests_published.py index 5277aa8fdd..9cf9f5689b 100644 --- a/zds/tutorialv2/tests/tests_views/tests_published.py +++ b/zds/tutorialv2/tests/tests_views/tests_published.py @@ -41,7 +41,7 @@ overridden_zds_app = deepcopy(settings.ZDS_APP) overridden_zds_app["content"]["repo_private_path"] = settings.BASE_DIR / "contents-private-test" overridden_zds_app["content"]["repo_public_path"] = settings.BASE_DIR / "contents-public-test" -overridden_zds_app["content"]["extra_content_generation_policy"] = "SYNC" +overridden_zds_app["content"]["extra_content_generation_policy"] = "NOTHING" @override_settings(MEDIA_ROOT=settings.BASE_DIR / "media-test") @@ -51,8 +51,6 @@ class PublishedContentTests(TutorialTestMixin, TestCase): def setUp(self): self.overridden_zds_app = overridden_zds_app overridden_zds_app["content"]["default_licence_pk"] = LicenceFactory().pk - # don't build PDF to speed up the tests - overridden_zds_app["content"]["build_pdf_when_published"] = False self.staff = StaffProfileFactory().user diff --git a/zds/utils/api/tests.py b/zds/utils/api/tests.py index 407d100f87..f9804a533f 100644 --- a/zds/utils/api/tests.py +++ b/zds/utils/api/tests.py @@ -1,6 +1,8 @@ +from copy import deepcopy import shutil import os from django.conf import settings +from django.test.utils import override_settings from django.urls import reverse from rest_framework import status from rest_framework.test import APITestCase @@ -12,13 +14,15 @@ from zds.tutorialv2.tests.factories import PublishableContentFactory from zds.tutorialv2.publication_utils import publish_content +overridden_zds_app = deepcopy(settings.ZDS_APP) +overridden_zds_app["content"]["extra_content_generation_policy"] = "NOTHING" + +@override_settings(ZDS_APP=overridden_zds_app) class TagListAPITest(APITestCase): def setUp(self): self.client = APIClient() caches[extensions_api_settings.DEFAULT_USE_CACHE].clear() - # don't build PDF to speed up the tests - settings.ZDS_APP["content"]["build_pdf_when_published"] = False def test_list_of_tags_empty(self): """ @@ -159,6 +163,3 @@ def tearDown(self): shutil.rmtree(settings.ZDS_APP["content"]["repo_public_path"]) if os.path.isdir(settings.MEDIA_ROOT): shutil.rmtree(settings.MEDIA_ROOT) - - # re-activate PDF build - settings.ZDS_APP["content"]["build_pdf_when_published"] = True