def test_create_job_makes_authorized_post_with_json_payload(mocker, user):
    c = ConversionApiClient()
    mocker.patch.object(c, 'authorized_post', autospec=True)
    post_parametrization_reply = dict(id=sentinel.PARAMETRIZATION_ID)
    c.create_job(parametrization=post_parametrization_reply,
                 callback_url=sentinel.CALLBACK_URL,
                 user=user)
    c.authorized_post.assert_called_once_with(url=ANY, json_data=ANY)
def test_create_job_posts_callback_url(mocker, user):
    c = ConversionApiClient()
    mocker.patch.object(c, 'authorized_post', autospec=True)
    post_parametrization_reply = dict(id=sentinel.PARAMETRIZATION_ID)
    c.create_job(parametrization=post_parametrization_reply,
                 callback_url=sentinel.CALLBACK_URL,
                 user=user)
    args, kwargs = c.authorized_post.call_args
    assert kwargs['json_data']['callback_url'] == sentinel.CALLBACK_URL
def test_create_job_posts_payload_with_structure_expected_by_conversion_servic_api(
        mocker, user):
    c = ConversionApiClient()
    mocker.patch.object(c, 'authorized_post', autospec=True)
    post_parametrization_reply = dict(id=sentinel.PARAMETRIZATION_ID)
    c.create_job(parametrization=post_parametrization_reply,
                 callback_url=sentinel.CALLBACK_URL,
                 user=user)
    args, kwargs = c.authorized_post.call_args
    assert_that(
        kwargs['json_data'].keys(),
        contains_inanyorder('callback_url', 'parametrization', 'queue_name'))
def test_create_job_returns_post_request_response_json_payload_as_dict(
        mocker, user):
    c = ConversionApiClient()
    mocker.patch.object(c, 'authorized_post', autospec=True)
    post_parametrization_reply = dict(id=sentinel.PARAMETRIZATION_ID)
    result = c.create_job(parametrization=post_parametrization_reply,
                          callback_url=sentinel.CALLBACK_URL,
                          user=user)
    assert result == c.authorized_post.return_value.json.return_value
示例#5
0
 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