-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mathieuripert/0.2
add tests
- Loading branch information
Showing
7 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.5" | ||
# command to install dependencies | ||
install: "pip install -r requirements.txt" | ||
# command to run tests | ||
script: python -m pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pandas | ||
geopandas | ||
shapely | ||
python-geohash | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
import json | ||
import pytest | ||
import geoh | ||
|
||
@pytest.fixture | ||
def geojson_sf(): | ||
__location__ = os.path.realpath(os.path.join( | ||
os.getcwd(), os.path.dirname(__file__))) | ||
geojson = json.loads( | ||
open(os.path.join(__location__, './geojson-sf.json')).read()) | ||
return geojson | ||
|
||
@pytest.fixture | ||
def geojson_none(): | ||
return { | ||
'type': 'FeatureCollection', | ||
'features': [None] | ||
} | ||
|
||
@pytest.fixture | ||
def malformed_geojson(): | ||
return { | ||
'type': 'FeatureCollection', | ||
'features': [{ | ||
'geometry': None, | ||
'type': 'Polygon', | ||
}] | ||
} | ||
|
||
@pytest.mark.parametrize("precision", [1, 2 ,3, 4, 5, 6]) | ||
def test_sf(geojson_sf, precision): | ||
geohashes = geoh.geohashes(geojson=geojson_sf, precision=precision) | ||
assert(len(geohashes) > 0) | ||
|
||
@pytest.mark.parametrize("precision", [1, 2, 3, 4, 5, 6]) | ||
def test_with_none_geojson(geojson_none, precision): | ||
geohashes = geoh.geohashes(geojson=geojson_none, precision=precision) | ||
assert(geohashes == []) | ||
|
||
|
||
@pytest.mark.parametrize("precision", [1, 2, 3, 4, 5, 6]) | ||
def test_with_malformed_geojson(malformed_geojson, precision): | ||
geohashes = geoh.geohashes(geojson=malformed_geojson, precision=precision) | ||
assert(geohashes == []) |