Skip to content

Commit 43c7b14

Browse files
Copilotoscarlevin
andcommitted
Add test for pretext generate datafile (#1126)
* Initial plan * Add test for pretext generate datafile Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com> Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/2dcc278a-da1e-4d0d-9c35-f17aa1fa7f57 * Fix pelican landing page links for print/single-file targets (#1128) * Initial plan * Fix: print targets get better links in pelican generated site When output_filename is not set for single-file output formats (PDF, EPUB, KINDLE, BRAILLE), deploy_path() now scans the output directory for the actual output file and returns a path including the filename. This allows the pelican-generated landing page to link directly to the PDF (or other single-file output) rather than the directory containing it. Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com> Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/870d27e1-a45a-439c-943b-f8852da66683 * format * add copilot instructions --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com> Co-authored-by: Oscar Levin <oscar.levin@unco.edu> * Initial plan * Fix formatting with black and rebase onto main Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com> Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/2aff3401-df98-4e89-ad7d-d303784b6b77 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com> Co-authored-by: Oscar Levin <oscar.levin@unco.edu>
1 parent 89a2726 commit 43c7b14

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
x,y
2+
1,2
3+
3,4
4+
5,6
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<project ptx-version="2">
3+
<targets>
4+
<target name="web" format="html" />
5+
</targets>
6+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<publication>
3+
<!-- directories are relative to the main source PreTeXt file -->
4+
<source>
5+
<directories external="../assets" generated="../generated-assets"/>
6+
</source>
7+
</publication>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<pretext xmlns:xi="http://www.w3.org/2001/XInclude">
4+
<book xml:id="datafile-test-book">
5+
<title>Datafile Test</title>
6+
<chapter xml:id="ch-data">
7+
<title>Data</title>
8+
<section xml:id="sec-data">
9+
<title>Section</title>
10+
<datafile label="data-csv" filename="data.csv">
11+
<pre source="data.csv"/>
12+
</datafile>
13+
</section>
14+
</chapter>
15+
</book>
16+
</pretext>

tests/test_cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,15 @@ def test_generate_graphics_asymptote_server(
414414
assert (graphics_path / "generated-assets" / "asymptote" / "test.html").exists()
415415

416416

417+
def test_generate_datafile(tmp_path: Path, script_runner: ScriptRunner) -> None:
418+
datafile_path = tmp_path / "datafile"
419+
shutil.copytree(EXAMPLES_DIR / "projects" / "datafile", datafile_path)
420+
assert script_runner.run(
421+
[PTX_CMD, "-v", "debug", "generate", "datafile"], cwd=datafile_path
422+
).success
423+
assert (datafile_path / "generated-assets" / "datafile" / "data-csv.xml").exists()
424+
425+
417426
# @pytest.mark.skip(
418427
# reason="Waiting on upstream changes to interactive preview generation"
419428
# )

0 commit comments

Comments
 (0)