mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-08-11 00:47:38 +00:00
fix(ci): harden publishing and validate examples
This commit is contained in:
@@ -2,12 +2,24 @@ import tempfile
|
||||
import unittest
|
||||
from base64 import b64encode
|
||||
from pathlib import Path
|
||||
|
||||
from tools.prepare_pdf_sources import normalize_markdown_asset_paths, prepare_pdf_sources
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
class PreparePdfSourcesTest(unittest.TestCase):
|
||||
def test_module_imports_with_running_python(self):
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-c", "import tools.prepare_pdf_sources"],
|
||||
cwd=Path(__file__).resolve().parents[1],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
|
||||
def test_normalizes_relative_markdown_and_html_image_paths(self):
|
||||
from tools.prepare_pdf_sources import normalize_markdown_asset_paths
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
book_dir = Path(tmp)
|
||||
(book_dir / "_images").mkdir()
|
||||
@@ -31,6 +43,8 @@ class PreparePdfSourcesTest(unittest.TestCase):
|
||||
self.assertEqual(count, 2)
|
||||
|
||||
def test_prepares_temp_tree_without_mutating_source_markdown(self):
|
||||
from tools.prepare_pdf_sources import prepare_pdf_sources
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
source = Path(tmp) / "source"
|
||||
target = Path(tmp) / "target"
|
||||
|
||||
Reference in New Issue
Block a user