Skip to content

Commit

Permalink
Correction de commentaires
Browse files Browse the repository at this point in the history
Suite à la revue de code de Situphen.

Co-authored-by: Situphen <[email protected]>
  • Loading branch information
philippemilink and Situphen committed Mar 28, 2022
1 parent 066ddbb commit 2c18381
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions zds/tutorialv2/tests/tests_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,10 @@ def test_export_only_ready_to_publish(self):
Test exported contents contain only ready_to_publish==True parts.
"""

# We need to produce at least the .tex file, so use the real PDF publicator:
# We save the current settings for the PDF publicator:
previous_pdf_publicator = PublicatorRegistry.get("pdf")
previous_build_pdf_when_published = self.overridden_zds_app["content"]["build_pdf_when_published"]
# We need to produce at least the LaTeX file, so we use the real PDF publicator:
PublicatorRegistry.registry["pdf"] = ZMarkdownRebberLatexPublicator(".pdf")
self.overridden_zds_app["content"]["build_pdf_when_published"] = True

Expand Down Expand Up @@ -314,20 +315,21 @@ def test_export_only_ready_to_publish(self):
self.assertIn(chapter2.title, content)
self.assertNotIn(chapter3.title, content)

# TODO: factorize getting texfile path with what is done in zds.tutorialv2.publication_utils.publish():
# TODO: factorize getting the LaTeX file path with what is done in zds.tutorialv2.publication_utils.publish_content()
tmp_path = os.path.join(
settings.ZDS_APP["content"]["repo_public_path"], published.content_public_slug + "__building"
)
build_extra_contents_path = os.path.join(tmp_path, settings.ZDS_APP["content"]["extra_contents_dirname"])
base_name = os.path.join(build_extra_contents_path, published.content_public_slug)
tex_file = base_name + ".tex"
# PDF generation may fail, only test the tex content:
# PDF generation may fail, we only test the LaTeX content:
with open(tex_file) as tex:
content = tex.read()
self.assertIn(chapter1.title, content)
self.assertIn(chapter2.title, content)
self.assertNotIn(chapter3.title, content)

# We set back the previous settings:
PublicatorRegistry.registry["pdf"] = previous_pdf_publicator
self.overridden_zds_app["content"]["build_pdf_when_published"] = previous_build_pdf_when_published

Expand Down

0 comments on commit 2c18381

Please sign in to comment.