Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fliiiix committed Oct 1, 2023
1 parent 6ecc5d9 commit 22a4123
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ jobs:
run: python -m pip install --upgrade pip setuptools wheel pytest pytest-mock
- name: Setup package
run: python -m pip install .
- name: run tests
run: pytest
- 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

35 changes: 35 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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):
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
8 changes: 8 additions & 0 deletions tests/testdata/single-diagram-reference.md
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)
5 changes: 5 additions & 0 deletions tests/testdata/single-diagram-with-config.md
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
```
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
```
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
```
9 changes: 9 additions & 0 deletions tests/testdata/single-diagram.md
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
```

0 comments on commit 22a4123

Please sign in to comment.