Skip to content

Commit 70682c2

Browse files
committed
Add wms test
1 parent 1b3ddc8 commit 70682c2

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

test/fixtures/4686-6267-14.jpeg

36.1 KB
Loading

test/tiles/1087767-1046604-21.jpg

14.3 KB
Loading

test/tiles/4686-6267-14.jpeg

36.1 KB
Loading

test/unit/test_utils.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
from PIL import Image
77

8-
from label_maker.utils import url, class_match, get_tile_tif
8+
from label_maker.utils import url, class_match, get_tile_tif, get_tile_wms
99

1010
class TestUtils(unittest.TestCase):
1111
"""Tests for utility functions"""
@@ -85,5 +85,21 @@ def test_get_tile_vrt(self):
8585
fixture_tile = Image.open('test/fixtures/{}.jpg'.format(tile))
8686
self.assertEqual(test_tile, fixture_tile)
8787

88+
def test_get_tile_wms(self):
89+
"""Test reading of tile from a WMS endpoint"""
90+
tile = '4686-6267-14'
91+
# create tiles directory
92+
dest_folder = 'test'
93+
tiles_dir = op.join(dest_folder, 'tiles')
94+
if not op.isdir(tiles_dir):
95+
makedirs(tiles_dir)
96+
97+
usgs_url = 'https://basemap.nationalmap.gov/arcgis/services/USGSImageryOnly/MapServer/WMSServer?SERVICE=WMS&REQUEST=GetMap&VERSION=1.1.1&LAYERS=0&STYLES=&FORMAT=image%2Fjpeg&TRANSPARENT=false&HEIGHT=256&WIDTH=256&SRS=EPSG%3A3857&BBOX={bbox}'
98+
99+
get_tile_wms(tile, usgs_url, tiles_dir, None)
100+
test_tile = Image.open('test/tiles/{}.jpeg'.format(tile))
101+
fixture_tile = Image.open('test/fixtures/{}.jpeg'.format(tile))
102+
self.assertEqual(test_tile, fixture_tile)
103+
88104
if __name__ == '__main__':
89105
unittest.main()

0 commit comments

Comments
 (0)