Create test for wrdem.py.
[philipp/winterrodeln/wrpylib.git] / tests / test_wrdem.py
1 import unittest
2
3 from wrpylib.wrdem import get_ele_from_raster
4 from wrpylib.wrvalidators import LonLat
5
6
7 class TestWrDem(unittest.TestCase):
8     def setUp(self):
9         self.filename = '/home/philipp/daten/GeoData/dem/oesterreich_10m/dhm_lamb_10m.tif'
10         # https://www.data.gv.at/katalog/dataset/dgm
11
12     def test_get_ele_from_raster_inside_valid(self):
13         value = get_ele_from_raster(self.filename, LonLat(13.682109, 47.934012))
14         ele = round(int(value))
15         self.assertEqual(ele, 557)
16
17     def test_get_ele_from_raster_inside_invalid(self):
18         value = get_ele_from_raster(self.filename, LonLat(14.67656, 48.16182))
19         self.assertIsNone(value)
20
21     def test_get_ele_from_raster_outside(self):
22         value = get_ele_from_raster(self.filename, LonLat(8.67656, 47.16182))
23         self.assertIsNone(value)