예제 #1
0
 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())
예제 #2
0
 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]
예제 #3
0
 def test_supported_projection(self):
     source = ogc.WMSRasterSource(self.URI, self.layer)
     source.validate_projection(self.projection)
예제 #4
0
 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)
예제 #5
0
 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})
예제 #6
0
 def test_extra_kwargs_empty(self):
     source = ogc.WMSRasterSource(self.URI,
                                  self.layer,
                                  getmap_extra_kwargs={})
     self.assertEqual(source.getmap_extra_kwargs, {})
예제 #7
0
 def test_no_layers(self):
     msg = 'One or more layers must be defined.'
     with self.assertRaisesRegexp(ValueError, msg):
         ogc.WMSRasterSource(self.URI, [])
예제 #8
0
 def test_multiple_layers(self):
     source = ogc.WMSRasterSource(self.URI, self.layers)
     self.assertEqual(source.layers, self.layers)
예제 #9
0
 def test_wms_service_instance(self):
     service = WebMapService(self.URI)
     source = ogc.WMSRasterSource(service, self.layer)
     self.assertIs(source.service, service)
예제 #10
0
 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])
예제 #11
0
 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)
예제 #12
0
 def test_no_layers(self):
     match = r'One or more layers must be defined\.'
     with pytest.raises(ValueError, match=match):
         ogc.WMSRasterSource(self.URI, [])
예제 #13
0
 def test_multiple_layers(self):
     source = ogc.WMSRasterSource(self.URI, self.layers)
     assert source.layers == self.layers
예제 #14
0
 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())
예제 #15
0
 def test_no_layers(self):
     msg = 'One or more layers must be defined.'
     with pytest.raises(ValueError, message=msg):
         ogc.WMSRasterSource(self.URI, [])