def test_create_boundary_posts_to_clipping_area_resource(
        mocker, geos_multipolygon):
    c = ConversionApiClient()
    mocker.patch.object(c, 'authorized_post', autospec=True)
    c.create_boundary(geos_multipolygon, name=sentinel.NAME)
    args, kwargs = c.authorized_post.call_args
    assert kwargs['url'] == 'clipping_area/'
def test_create_boundary_posts_payload_with_structure_expected_by_conversion_service_api(
        mocker, geos_multipolygon):
    c = ConversionApiClient()
    mocker.patch.object(c, 'authorized_post', autospec=True)
    c.create_boundary(geos_multipolygon, name=sentinel.NAME)
    args, kwargs = c.authorized_post.call_args
    assert_that(kwargs['json_data'].keys(),
                contains_inanyorder('name', 'clipping_multi_polygon'))
def test_create_boundary_posts_geojson(mocker, geos_multipolygon):
    c = ConversionApiClient()
    mocker.patch.object(c, 'authorized_post', autospec=True)
    c.create_boundary(geos_multipolygon, name=sentinel.NAME)
    args, kwargs = c.authorized_post.call_args
    assert kwargs['json_data']['clipping_multi_polygon'] == {
        "type": "MultiPolygon",
        "coordinates": nested_list(geos_multipolygon.coords)
    }
예제 #4
0
 def send_to_conversion_service(self):
     from osmaxx.api_client.conversion_api_client import ConversionApiClient
     api_client = ConversionApiClient()
     bounding_geometry = self.bounding_geometry
     if self.excerpt_type == self.EXCERPT_TYPE_COUNTRY_BOUNDARY:
         bounding_geometry = self.simplified_buffered()
     return api_client.create_boundary(bounding_geometry, name=self.name)
def test_create_boundary_returns_post_request_response_json_payload_as_dict(
        mocker, geos_multipolygon):
    c = ConversionApiClient()
    mocker.patch.object(c, 'authorized_post', autospec=True)
    result = c.create_boundary(geos_multipolygon, name=sentinel.NAME)
    assert result == c.authorized_post.return_value.json.return_value
def test_create_boundary_posts_name(mocker, geos_multipolygon):
    c = ConversionApiClient()
    mocker.patch.object(c, 'authorized_post', autospec=True)
    c.create_boundary(geos_multipolygon, name=sentinel.NAME)
    args, kwargs = c.authorized_post.call_args
    assert kwargs['json_data']['name'] == sentinel.NAME
def test_create_boundary_makes_authorized_post_with_json_payload(
        mocker, geos_multipolygon):
    c = ConversionApiClient()
    mocker.patch.object(c, 'authorized_post', autospec=True)
    c.create_boundary(geos_multipolygon, name=sentinel.NAME)
    c.authorized_post.assert_called_once_with(url=ANY, json_data=ANY)