diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/__test_data__/plugin/backends/__pycache__/.gitkeep | 0 | ||||
-rw-r--r-- | tests/__test_data__/plugin/backends/bar/.gitkeep | 0 | ||||
-rw-r--r-- | tests/__test_data__/plugin/backends/file | 0 | ||||
-rw-r--r-- | tests/__test_data__/plugin/backends/foo/.gitkeep | 0 | ||||
-rw-r--r-- | tests/__test_data__/plugin/filters/baz/.gitkeep | 0 | ||||
-rw-r--r-- | tests/__test_data__/plugin/filters/qux/.gitkeep | 0 | ||||
-rw-r--r-- | tests/test_plugin.py | 18 | ||||
-rw-r--r-- | tests/utils.py | 17 |
8 files changed, 35 insertions, 0 deletions
diff --git a/tests/__test_data__/plugin/backends/__pycache__/.gitkeep b/tests/__test_data__/plugin/backends/__pycache__/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__test_data__/plugin/backends/__pycache__/.gitkeep diff --git a/tests/__test_data__/plugin/backends/bar/.gitkeep b/tests/__test_data__/plugin/backends/bar/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__test_data__/plugin/backends/bar/.gitkeep diff --git a/tests/__test_data__/plugin/backends/file b/tests/__test_data__/plugin/backends/file new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__test_data__/plugin/backends/file diff --git a/tests/__test_data__/plugin/backends/foo/.gitkeep b/tests/__test_data__/plugin/backends/foo/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__test_data__/plugin/backends/foo/.gitkeep diff --git a/tests/__test_data__/plugin/filters/baz/.gitkeep b/tests/__test_data__/plugin/filters/baz/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__test_data__/plugin/filters/baz/.gitkeep diff --git a/tests/__test_data__/plugin/filters/qux/.gitkeep b/tests/__test_data__/plugin/filters/qux/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__test_data__/plugin/filters/qux/.gitkeep diff --git a/tests/test_plugin.py b/tests/test_plugin.py new file mode 100644 index 0000000..c9333f7 --- /dev/null +++ b/tests/test_plugin.py @@ -0,0 +1,18 @@ + + +from asciidoc.message import Message +from asciidoc.plugin import Plugin + +from .utils import Struct, TEST_DIR + +PLUGIN_DIR = TEST_DIR / 'plugin' +CONFIG = Struct(get_load_dirs=lambda: [str(PLUGIN_DIR)], verbose=True) + + +def test_plugin_list(capsys) -> None: + plugin = Plugin('backend', Message(None, None, CONFIG, None), CONFIG) + plugin.list([]) + captured = capsys.readouterr() + backend_dir = PLUGIN_DIR / 'backends' + assert captured.out == "{}\n{}\n".format(backend_dir / 'bar', backend_dir / 'foo') + assert captured.err == '' diff --git a/tests/utils.py b/tests/utils.py new file mode 100644 index 0000000..427c728 --- /dev/null +++ b/tests/utils.py @@ -0,0 +1,17 @@ +from pathlib import Path + +TEST_DIR = Path(__file__).resolve().parent / '__test_data__' + + +class Struct: + """ + Use this to make "mock" version of asciidoc classes. Usage is passing in kwargs, + and these are set to the properties of the class. + + >>> a = Struct(foo=1, bar=2) + >>> a.foo + 1 + >>> a.bar + 2 + """ + def __init__(self, **entries): self.__dict__.update(entries) |