diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2fc8441..527a878 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,3 +18,18 @@ 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: Setup package + run: python -m pip install . + - name: run tests + run: pytest + diff --git a/tests/test_unit.py b/tests/test_unit.py new file mode 100644 index 0000000..5a247ea --- /dev/null +++ b/tests/test_unit.py @@ -0,0 +1,18 @@ +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()