-
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.
Merge pull request #24 from timofurrer/update
Update
- Loading branch information
Showing
11 changed files
with
185 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.12 | ||
- name: Setup and install tools | ||
run: | | ||
python -m pip install --upgrade black flake8 | ||
- name: black format check | ||
run: black --check --line-length 120 pandoc_plantuml_filter.py tests setup.py | ||
- name: flake8 format check | ||
run: flake8 --max-line-length 120 pandoc_plantuml_filter.py tests setup.py | ||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: [3.8, 3.12] | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Setup build and test environment | ||
run: python -m pip install --upgrade pip setuptools wheel pytest pytest-mock | ||
- name: Setup package | ||
run: python -m pip install . | ||
- name: run unit tests | ||
run: pytest tests/test_unit.py | ||
- name: install dependencies for integration tests | ||
run: sudo apt update && sudo apt install -y pandoc plantuml | ||
- name: run integration tests | ||
run: pytest tests/test_integration.py | ||
|
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 @@ | ||
.env/ | ||
__pycache__/ | ||
example.png | ||
images/ | ||
missfont.log | ||
pandoc_plantuml_filter.egg-info/ | ||
plantuml-images/ | ||
sample.pdf |
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
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,43 @@ | ||
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, expected_files", | ||
[ | ||
("single-diagram", ["\\includegraphics{plantuml-images/"], []), | ||
("single-diagram-with-config", ["\\includegraphics", "width=0.6"], []), | ||
( | ||
"single-diagram-with-filename-and-subdirectory", | ||
["\\includegraphics", "images/example.png"], | ||
["images/example.png"], | ||
), | ||
("single-diagram-with-filename-without-subdirectory", ["\\includegraphics", "example.png"], ["example.png"]), | ||
( | ||
"single-diagram-reference", | ||
["\\includegraphics", "images/example.png", "\\includegraphics{images/example.png}"], | ||
["images/example.png"], | ||
), | ||
], | ||
) | ||
def test_digrams(mocker, tmp_path, filename, expected_content, expected_files): | ||
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 | ||
|
||
for file in expected_files: | ||
assert os.path.exists(file) |
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,14 @@ | ||
from pandoc_plantuml_filter import plantuml | ||
|
||
|
||
def test_call_plantuml_create_para_object(mocker): | ||
mocker.patch("os.path.isfile", return_value=False) | ||
mock = mocker.patch("subprocess.check_call") | ||
|
||
ret = plantuml(key="CodeBlock", value=[["", ["plantuml"], []], ""], format_=None, meta={}) | ||
|
||
assert isinstance(ret, dict) | ||
assert "t" in ret.keys() | ||
assert ret["t"] == "Para" | ||
|
||
mock.assert_called_once() |
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 | ||
``` |