Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elbeejay committed May 24, 2024
1 parent 1d6d454 commit cb22de6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import geopandas as gpd
from shapely.geometry import Point, Polygon
from shapely import LineString
import shutil


Expand Down Expand Up @@ -50,6 +51,12 @@ def test_selector():
assert G == 1


def test_selector_non_int():
"""Test selector() if not an int."""
x = core.selector("y")
assert x == "y"


def test_flatten():
"""Test the flatten() function."""
# call the function
Expand Down Expand Up @@ -331,6 +338,19 @@ def test_custom_simplify():
pass


def test_cut():
"""Test the cut function."""
# define parameters
line = LineString([[0, 0], [1, 0], [1, 1]])
distance = 0.5
# call function
two_lines = core.cut(line, distance)
assert line.length == 2.0
assert two_lines[0].length == 0.5
assert two_lines[1].length == 1.5
assert line.length == (two_lines[0].length + two_lines[1].length)


def test_salt_long_lines():
"""Test the salt_long_lines function."""
pass
Expand Down
1 change: 1 addition & 0 deletions tests/test_core_integrative.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Integrative tests for core.py"""
10 changes: 10 additions & 0 deletions tests/test_load_osm_integrative.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ def test_OSM_to_network():
assert isinstance(otn, load_osm.OSM_to_network)
assert isinstance(otn.osmFile, str)
assert isinstance(otn.roads_raw, gpd.GeoDataFrame)


def test_OSM_to_network_ferries():
"""Test the OSM_to_network class with ferries."""
fpath = os.path.join("Tutorials", "tutorial_data", "iceland-latest.osm.pbf")
# load the class
otn = load_osm.OSM_to_network(fpath, includeFerries=True)
assert isinstance(otn, load_osm.OSM_to_network)
assert isinstance(otn.osmFile, str)
assert isinstance(otn.roads_raw, gpd.GeoDataFrame)

0 comments on commit cb22de6

Please sign in to comment.