Exemplo n.º 1
0
 def test_sends_correct_payload_when_setting_default_style(
         self, m: requests_mock.Mocker):
     m.post('/geoserver/rest/styles')
     m.put('/geoserver/rest/layers/all_detections')
     geoserver.install_style('test-style-id')
     xml = et.fromstring(m.request_history[1].text)  # type: et.ElementTree
     self.assertEqual('detections', xml.findtext('defaultStyle/name'))
Exemplo n.º 2
0
 def test_throws_if_geoserver_is_unreachable_when_setting_default_style(
         self, m: requests_mock.Mocker):
     m.post('/geoserver/rest/styles')
     with patch('requests.put') as stub:
         stub.side_effect = ConnectionError()
         with self.assertRaises(geoserver.InstallError):
             geoserver.install_style('test-style-id')
Exemplo n.º 3
0
 def test_sends_correct_credentials_when_setting_default_style(
         self, m: requests_mock.Mocker):
     m.post('/geoserver/rest/styles')
     m.put('/geoserver/rest/layers/all_detections')
     geoserver.install_style('test-style-id')
     self.assertEqual('Basic dGVzdC11c2VybmFtZTp0ZXN0LXBhc3N3b3Jk',
                      m.request_history[1].headers['Authorization'])
Exemplo n.º 4
0
 def test_sends_correct_payload_when_creating_sld(self,
                                                  m: requests_mock.Mocker):
     m.post('/geoserver/rest/styles')
     m.put('/geoserver/rest/layers/all_detections')
     geoserver.install_style('test-style-id')
     xml = et.fromstring(m.request_history[0].text)  # type: et.ElementTree
     self.assertEqual('#FF00FF',
                      xml.findtext('.//sld:CssParameter', namespaces=XMLNS))
Exemplo n.º 5
0
 def test_calls_correct_url_when_setting_default_style(
         self, m: requests_mock.Mocker):
     m.post('/geoserver/rest/styles')
     m.put('/geoserver/rest/layers/all_detections')
     geoserver.install_style('test-style-id')
     self.assertEqual(
         'http://vcap-geoserver.test.localdomain/geoserver/rest/layers/all_detections',
         m.request_history[1].url)
Exemplo n.º 6
0
 def test_throws_if_geoserver_is_unreachable_when_creating_sld(self, _):
     with patch('requests.post') as stub:
         stub.side_effect = ConnectionError()
         with self.assertRaises(geoserver.InstallError):
             geoserver.install_style('test-style-id')
Exemplo n.º 7
0
 def test_throws_on_http_error_when_setting_default_style(
         self, m: requests_mock.Mocker):
     m.post('/geoserver/rest/styles')
     m.put('/geoserver/rest/layers/all_detections', status_code=500)
     with self.assertRaises(geoserver.InstallError):
         geoserver.install_style('test-style-id')