Skip to content

Commit

Permalink
test: update tests for data extract generation
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Feb 9, 2024
1 parent 0d86f87 commit 7993c86
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with osm_rawdata. If not, see <https:#www.gnu.org/licenses/>.
#
"""Tests for data extract generation."""

import logging
import os
Expand All @@ -36,6 +37,7 @@


def test_data_extract():
"""Test data extract works with zipped geojson default."""
pg = PostgresClient("underpass", f"{rootdir}/buildings.yaml")
aoi_file = open(f"{rootdir}/AOI_small.geojson", "r")
boundary = geojson.load(aoi_file)
Expand All @@ -44,20 +46,24 @@ def test_data_extract():


def test_data_extract_with_clipping():
# Sleep 5 seconds to reduce API load
time.sleep(5)
"""Clipping to only extract polygons with centroids inside AOI.
This only extracts on parking spot and a building.
"""
# Sleep 3 seconds to reduce API load
time.sleep(3)

pg = PostgresClient("underpass", f"{rootdir}/buildings.yaml")
aoi_file = open(f"{rootdir}/AOI_small.geojson", "r")
aoi_file = open(f"{rootdir}/AOI_small_clipped.geojson", "r")
boundary = geojson.load(aoi_file)
data_extract = pg.execQuery(boundary, clip_to_aoi=True)
print(data_extract)
assert len(data_extract.get("features")) == 13
assert len(data_extract.get("features")) == 2


def test_data_extract_flatgeobuf():
# Sleep 5 seconds to reduce API load
time.sleep(5)
"""Test bind_zip=False flatgeobuf for direct data streaming."""
# Sleep 3 seconds to reduce API load
time.sleep(3)

pg = PostgresClient("underpass", f"{rootdir}/buildings.yaml")
aoi_file = open(f"{rootdir}/AOI_small.geojson", "r")
Expand Down

0 comments on commit 7993c86

Please sign in to comment.