forked from opengeos/leafmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_common.py
76 lines (45 loc) · 2.12 KB
/
test_common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
"""Tests for `leafmap` package."""
import os
import unittest
import geopandas
import pandas
from leafmap.common import *
class TestCommon(unittest.TestCase):
"""Tests for `common` module."""
def setUp(self):
"""Set up test fixtures, if any."""
self.in_csv = os.path.abspath("examples/data/world_cities.csv")
self.in_geojson = os.path.abspath("examples/data/cable-geo.geojson")
self.in_shp = os.path.abspath("examples/data/countries.shp")
self.in_kml = os.path.abspath("examples/data/states.kml")
self.in_kmz = os.path.abspath("examples/data/states.kmz")
self.in_cog = "https://opendata.digitalglobe.com/events/california-fire-2020/pre-event/2018-02-16/pine-gulch-fire20/1030010076004E00.tif"
def tearDown(self):
"""Tear down test fixtures, if any."""
def test_basemap_xyz_tiles(self):
self.assertIsInstance(basemap_xyz_tiles(), dict)
def test_csv_to_gdf(self):
self.assertIsInstance(csv_to_gdf(self.in_csv), geopandas.GeoDataFrame)
def test_csv_to_geojson(self):
self.assertIsInstance(csv_to_geojson(self.in_csv), dict)
def test_csv_to_pandas(self):
self.assertIsInstance(csv_to_pandas(self.in_csv), pandas.DataFrame)
def test_gdf_to_geojson(self):
self.assertIsInstance(gdf_to_geojson(csv_to_gdf(self.in_csv)), dict)
def test_kml_to_geojson(self):
self.assertIsInstance(kml_to_geojson(self.in_kml), dict)
def test_shp_to_gdf(self):
self.assertIsInstance(shp_to_gdf(self.in_shp), geopandas.GeoDataFrame)
def test_shp_to_geojson(self):
self.assertIsInstance(shp_to_geojson(self.in_shp), dict)
def test_vector_to_geojson(self):
self.assertIsInstance(vector_to_geojson(self.in_shp), dict)
def test_cog_bounds(self):
self.assertIsInstance(cog_bounds(self.in_cog), list)
self.assertEqual(len(cog_bounds(self.in_cog)), 4)
def test_cog_center(self):
self.assertIsInstance(cog_center(self.in_cog), tuple)
self.assertEqual(len(cog_center(self.in_cog)), 2)
if __name__ == "__main__":
unittest.main()