-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
import subprocess | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
__TEST_BASE_DIR__ = Path(os.path.dirname(__file__)) / "testdata" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"filename, expected_content", | ||
[ | ||
("single-diagram", ["\\includegraphics{plantuml-images/"]), | ||
("single-diagram-with-config", ["\\includegraphics", "width=0.6"]), | ||
("single-diagram-with-filename-and-subdirectory", ["\\includegraphics", "images/example.png"]), | ||
("single-diagram-with-filename-without-subdirectory", ["\\includegraphics", "example.png"]), | ||
( | ||
"single-diagram-reference", | ||
["\\includegraphics", "images/example.png", "\\includegraphics{images/example.png}"], | ||
), | ||
], | ||
) | ||
def test_digrams(mocker, tmp_path, filename, expected_content): | ||
# Note: suppress the call to plantuml on CI | ||
# otherwise we would need to install a lot of Java | ||
if os.getenv("GITHUB_ACTIONS"): | ||
mock = mocker.patch("subprocess.check_call") | ||
|
||
input_file = str(__TEST_BASE_DIR__ / f"{filename}.md") | ||
output_file = str(tmp_path / f"{filename}.tex") | ||
|
||
cmd = subprocess.run(["pandoc", input_file, "-o", output_file, "--filter", "pandoc-plantuml"]) | ||
assert cmd.returncode == 0 | ||
|
||
with open(output_file) as f: | ||
content = f.read() | ||
|
||
for line in expected_content: | ||
assert line in content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Single PlantUML diagram which referenced later | ||
|
||
```{ .plantuml width=60% plantuml-filename=images/example.png } | ||
[producer] -> [consumer]: data streaming | ||
``` | ||
|
||
# Reference | ||
![And here's the reference](images/example.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Single PlantUML diagram with config | ||
|
||
```{ .plantuml width=60% } | ||
[producer] -> [consumer]: data streaming | ||
``` |
5 changes: 5 additions & 0 deletions
5
tests/testdata/single-diagram-with-filename-and-subdirectory.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Single PlantUML diagram with filename and sub-directory | ||
|
||
```{ .plantuml width=60% plantuml-filename=images/example.png } | ||
[producer] -> [consumer]: data streaming | ||
``` |
5 changes: 5 additions & 0 deletions
5
tests/testdata/single-diagram-with-filename-without-subdirectory.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Single PlantUML diagram with filename without sub-directory | ||
|
||
```{ .plantuml width=60% plantuml-filename=example.png } | ||
[producer] -> [consumer]: data streaming | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Single PlantUML digaram | ||
|
||
```plantuml | ||
Alice -> Bob: Authentication Request | ||
Bob --> Alice: Authentication Response | ||
Alice -> Bob: Another authentication Request | ||
Alice <-- Bob: another authentication Response | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
\hypertarget{single-plantuml-digaram}{% | ||
\section{Single PlantUML digaram}\label{single-plantuml-digaram}} | ||
|
||
\includegraphics{plantuml-images/acaa833b0d9b8086a688680adabd34bb7ab81c9e.png} |