Ejemplo n.º 1
0
    def test_success_with_no_sites(self):
        with requests_mock.mock() as m:
            m.post(
                'https://fake.gov/ngwmn/geoserver/wfs',
                text=
                '{"type": "FeatureCollection","totalFeatures": 0, "features": []}'
            )
            result = get_sites('CODWR', service_root=self.test_service_root)

            self.assertEqual(result, [])
Ejemplo n.º 2
0
    def test_success_good_data(self):
        with requests_mock.mock() as m:
            m.post('https://fake.gov/ngwmn/geoserver/wfs',
                   text=MOCK_SITES_RESPONSE)
            result = get_sites('CODWR', service_root=self.test_service_root)

            self.assertIn("CQL_FILTER=(AGENCY_CD='CODWR')",
                          urllib.parse.unquote(m.request_history[0].text))
            self.assertEqual(len(result), 2)
            siteIds = list(map(lambda x: x.get('site_no'), result))
            self.assertIn('1127', siteIds)
            self.assertIn('1128', siteIds)
Ejemplo n.º 3
0
 def test_bad_request(self):
     with requests_mock.mock() as m:
         m.post('https://fake.gov/ngwmn/geoserver/wfs', status_code=500)
         with self.assertRaises(ServiceException):
             get_sites('CODWR', service_root=self.test_service_root)