Skip to content

Commit

Permalink
test: add test for parsing yaml with no join_ syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Oct 9, 2023
1 parent e0af460 commit 7a34c76
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/buildings_no_join.yaml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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() ---")

0 comments on commit 7a34c76

Please sign in to comment.