From ee53518f1518a5b3e0535775710324587c6eb4c1 Mon Sep 17 00:00:00 2001 From: fliiiix Date: Sat, 30 Sep 2023 20:38:10 +0200 Subject: [PATCH] Add first test --- .github/workflows/main.yml | 13 +++++++++++++ tests/test_unit.py | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/test_unit.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2fc8441..63de425 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,3 +18,16 @@ jobs: run: black --check --line-length 120 pandoc_plantuml_filter.py tests setup.py - name: black format check run: flake8 --max-line-length 120 pandoc_plantuml_filter.py tests setup.py + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: 3.11 + - name: Setup build and test environment + run: python -m pip install --upgrade pip setuptools wheel pytest pytest-mock + - name: run tests + run: pytest + diff --git a/tests/test_unit.py b/tests/test_unit.py new file mode 100644 index 0000000..41a1055 --- /dev/null +++ b/tests/test_unit.py @@ -0,0 +1,17 @@ +import pytest + +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()