From 7a34c76db5d62ec7cc089bd870ca9e8f2168a844 Mon Sep 17 00:00:00 2001 From: spwoodcock Date: Mon, 9 Oct 2023 18:44:35 +0100 Subject: [PATCH] test: add test for parsing yaml with no join_ syntax --- tests/buildings_no_join.yaml | 21 +++++++++++++++++++++ tests/test_config.py | 23 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/buildings_no_join.yaml diff --git a/tests/buildings_no_join.yaml b/tests/buildings_no_join.yaml new file mode 100644 index 0000000..7014fd4 --- /dev/null +++ b/tests/buildings_no_join.yaml @@ -0,0 +1,21 @@ +select: +from: + - nodes + - ways_poly +where: + tags: + - building: yes + amenity: not null + - join_and: + - building:material: wood + roof:material: metal +keep: + - building:levels + - building:material + - roof:material + - roof:shape + - roof:levels + - cusine + - convenience + - diesel + - version diff --git a/tests/test_config.py b/tests/test_config.py index 76526eb..417df59 100755 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -81,6 +81,27 @@ def test_formats(): assert qc.config["outputType"] == "shp" and qc.config["fileName"] == "Pokhara_all_features" +def test_yaml_no_joins(): + qc = QueryConfig() + qc.parseYaml(f"{rootdir}/buildings_no_join.yaml") + + selected = qc.config["select"] + assert len(selected.keys()) == 3 + assert len(list(selected.values())[0]) == 4 + + where = qc.config["where"] + assert len(where.keys()) == 3 + + nodes = list(where.values())[0] + assert len(nodes) == 4 + + building = nodes[0]["building"] + assert building == ["yes"] + + op = nodes[0]["op"] + assert op == "or" + + def test_everything(): # this query contains only the geometry, we want everything within this polygon qc = QueryConfig() @@ -98,4 +119,6 @@ def test_everything(): test_levels() print("--- test_filters ---") test_filters() + print("--- test_yaml_no_joins ---") + test_yaml_no_joins() print("--- done() ---")