Ejemplo n.º 1
0
    def test_process_response_raises_geocoder_error_when_status_not_ok(self):
        g = Geocoder()

        response = StringIO(no_results_response)
        url = "http://www.example.com"
        with self.assertRaises(GeocodeError) as ctx:
            g._process_response(response, url)
        self.assertEqual(GeocodeError.G_GEO_ZERO_RESULTS, ctx.exception.status)
        self.assertEqual(url, ctx.exception.url)
Ejemplo n.º 2
0
    def test_process_response_returns_results_when_status_is_ok(self):
        success_json = """{
           "results" : [
              {"one": "the one"},
              {"two": "the two"}
           ],
           "status" : "OK"
        }"""
        response = StringIO(success_json)
        url = "http://www.example.com"
        expected_result = [dict(one="the one"), dict(two="the two")]

        g = Geocoder()
        self.assertEqual(expected_result, g._process_response(response, url))