def test_create_parametrization_makes_authorized_post_with_json_payload( mocker): c = ConversionApiClient() mocker.patch.object(c, 'authorized_post', autospec=True) post_boundary_reply = dict(id=sentinel.CLIPPING_AREA_ID) c.create_parametrization(boundary=post_boundary_reply, out_format=sentinel.OUT_FORMAT, detail_level=sentinel.DETAIL_LEVEL, out_srs=sentinel.OUT_SRS) c.authorized_post.assert_called_once_with(url=ANY, json_data=ANY)
def test_create_parametrization_posts_out_srs(mocker): c = ConversionApiClient() mocker.patch.object(c, 'authorized_post', autospec=True) post_boundary_reply = dict(id=sentinel.CLIPPING_AREA_ID) c.create_parametrization(boundary=post_boundary_reply, out_format=sentinel.OUT_FORMAT, detail_level=sentinel.DETAIL_LEVEL, out_srs=sentinel.OUT_SRS) args, kwargs = c.authorized_post.call_args assert kwargs['json_data']['out_srs'] == sentinel.OUT_SRS
def test_create_parametrization_posts_payload_with_structure_expected_by_conversion_service_api( mocker): c = ConversionApiClient() mocker.patch.object(c, 'authorized_post', autospec=True) post_boundary_reply = dict(id=sentinel.CLIPPING_AREA_ID) c.create_parametrization(boundary=post_boundary_reply, out_format=sentinel.OUT_FORMAT, detail_level=sentinel.DETAIL_LEVEL, out_srs=sentinel.OUT_SRS) args, kwargs = c.authorized_post.call_args assert_that( kwargs['json_data'].keys(), contains_inanyorder('out_format', 'out_srs', 'detail_level', 'clipping_area'))
def test_create_parametrization_returns_post_request_response_json_payload_as_dict( mocker): c = ConversionApiClient() mocker.patch.object(c, 'authorized_post', autospec=True) post_boundary_reply = dict(id=sentinel.CLIPPING_AREA_ID) result = \ c.create_parametrization(boundary=post_boundary_reply, out_format=sentinel.OUT_FORMAT, detail_level=sentinel.DETAIL_LEVEL, out_srs=sentinel.OUT_SRS) assert result == c.authorized_post.return_value.json.return_value
def send_to_conversion_service(self, clipping_area_json, incoming_request): from osmaxx.api_client.conversion_api_client import ConversionApiClient api_client = ConversionApiClient() extraction_format = self.file_format out_srs = self.extraction_order.coordinate_reference_system detail_level = self.extraction_order.detail_level parametrization_json = api_client.create_parametrization(boundary=clipping_area_json, out_format=extraction_format, detail_level=detail_level, out_srs=out_srs) job_json = api_client.create_job( parametrization_json, self.get_full_status_update_uri(incoming_request), user=self.extraction_order.orderer ) self.conversion_service_job_id = job_json['id'] self.status = job_json['status'] self.save() return job_json