def test_unsupported_projection(self): source = ogc.WMSRasterSource(self.URI, self.layer) # Patch dict of known Proj->SRS mappings so that it does # not include any of the available SRSs from the WMS. with mock.patch.dict('cartopy.io.ogc_clients._CRS_TO_OGC_SRS', {ccrs.OSNI(approx=True): 'EPSG:29901'}, clear=True): msg = 'not available' with pytest.raises(ValueError, match=msg): source.validate_projection(ccrs.Miller())
def test_string_service(self): source = ogc.WMSRasterSource(self.URI, self.layer) if isinstance(WebMapService, type): # OWSLib < 0.13.0 assert isinstance(source.service, WebMapService) else: # OWSLib >= 0.13.0: WebMapService is a function that creates # instances of these two classes. from owslib.map.wms111 import WebMapService_1_1_1 from owslib.map.wms130 import WebMapService_1_3_0 assert isinstance(source.service, (WebMapService_1_1_1, WebMapService_1_3_0)) assert isinstance(source.layers, list) assert source.layers == [self.layer]
def test_supported_projection(self): source = ogc.WMSRasterSource(self.URI, self.layer) source.validate_projection(self.projection)
def test_extra_kwargs_non_empty(self): kwargs = {'another': 'kwarg'} source = ogc.WMSRasterSource(self.URI, self.layer, getmap_extra_kwargs=kwargs) self.assertEqual(source.getmap_extra_kwargs, kwargs)
def test_extra_kwargs_None(self): source = ogc.WMSRasterSource(self.URI, self.layer, getmap_extra_kwargs=None) self.assertEqual(source.getmap_extra_kwargs, {'transparent': True})
def test_extra_kwargs_empty(self): source = ogc.WMSRasterSource(self.URI, self.layer, getmap_extra_kwargs={}) self.assertEqual(source.getmap_extra_kwargs, {})
def test_no_layers(self): msg = 'One or more layers must be defined.' with self.assertRaisesRegexp(ValueError, msg): ogc.WMSRasterSource(self.URI, [])
def test_multiple_layers(self): source = ogc.WMSRasterSource(self.URI, self.layers) self.assertEqual(source.layers, self.layers)
def test_wms_service_instance(self): service = WebMapService(self.URI) source = ogc.WMSRasterSource(service, self.layer) self.assertIs(source.service, service)
def test_string_service(self): source = ogc.WMSRasterSource(self.URI, self.layer) self.assertIsInstance(source.service, WebMapService) self.assertIsInstance(source.layers, list) self.assertEqual(source.layers, [self.layer])
def test_multi_image_result(self): source = ogc.WMSRasterSource(self.URI, self.layer) crs = ccrs.PlateCarree(central_longitude=180) extent = [-15, 25, 45, 85] located_images = source.fetch_raster(crs, extent, RESOLUTION) self.assertEqual(len(located_images), 2)
def test_no_layers(self): match = r'One or more layers must be defined\.' with pytest.raises(ValueError, match=match): ogc.WMSRasterSource(self.URI, [])
def test_multiple_layers(self): source = ogc.WMSRasterSource(self.URI, self.layers) assert source.layers == self.layers
def test_unsupported_projection(self): source = ogc.WMSRasterSource(self.URI, self.layer) msg = 'was not convertible to a suitable WMS SRS.' with self.assertRaisesRegexp(ValueError, msg): source.validate_projection(ccrs.Miller())
def test_no_layers(self): msg = 'One or more layers must be defined.' with pytest.raises(ValueError, message=msg): ogc.WMSRasterSource(self.URI, [])