From f2ab2bac6b26f82730d5f5d7ab1e6d5f2f1060e3 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Sun, 19 Feb 2023 23:36:04 -0600 Subject: add yaml_parser tests, small refactor --- tests/test_yaml_parser.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/test_yaml_parser.py (limited to 'tests/test_yaml_parser.py') diff --git a/tests/test_yaml_parser.py b/tests/test_yaml_parser.py new file mode 100644 index 0000000..9a1b3c3 --- /dev/null +++ b/tests/test_yaml_parser.py @@ -0,0 +1,19 @@ +from importlib.resources import path as rpath +from pyssg.yaml_parser import get_parsed_yaml + + +def test_yaml_resource_read() -> None: + yaml: list[dict] = get_parsed_yaml('simple.yaml', 'tests.io_files') + assert len(yaml) == 1 + + +def test_yaml_path_read(test_dir: str) -> None: + yaml: list[dict] = get_parsed_yaml(f'{test_dir}/io_files/simple.yaml') + assert len(yaml) == 1 + + +def test_yaml_join() -> None: + yaml: dict = get_parsed_yaml('simple.yaml', 'tests.io_files')[0] + define_str: str = '$HOME/pyssg/site_example/' + assert yaml['define'] == define_str + assert yaml['path']['src'] == f'{define_str}src' -- cgit v1.2.3-54-g00ecf