lille_kimoce: add support for comment field (#33916)
This commit is contained in:
parent
380d7ca43f
commit
94c6de757d
|
@ -111,6 +111,11 @@ DEMAND_SCHEMA = {
|
|||
'description': 'second picture data',
|
||||
'type': 'any',
|
||||
'required': False
|
||||
},
|
||||
'comment': {
|
||||
'description': 'demand comment',
|
||||
'type': 'string',
|
||||
'required': False
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -232,6 +237,8 @@ class Kimoce(BaseResource):
|
|||
for param_name in ('picture1', 'picture2'):
|
||||
if post_data.get(param_name) and isinstance(post_data[param_name], dict) and post_data[param_name].get('content'):
|
||||
payload['pictures'].append({'content': post_data[param_name]['content']})
|
||||
if post_data.get('comment'):
|
||||
payload['comment'] = {'content': post_data['comment']}
|
||||
url = urljoin(self.base_url, 'demands')
|
||||
result = self.requests.post(url, json=payload, auth=HttpBearerAuth(self.get_token()))
|
||||
if result.status_code == 401:
|
||||
|
|
|
@ -347,6 +347,7 @@ def test_create_demand(mocked_post, app, setup):
|
|||
response = app.post_json(endpoint, params=data)
|
||||
assert mocked_post.call_count == 3
|
||||
assert mocked_post.call_args[1]['json']['pictures'][0]['content'] == 'base64encoded_picture'
|
||||
assert 'comment' not in mocked_post.call_args[1]['json']
|
||||
|
||||
data['lat'] = '48.85438994604021'
|
||||
data['lon'] = '2.3497223854064946'
|
||||
|
@ -355,3 +356,7 @@ def test_create_demand(mocked_post, app, setup):
|
|||
assert mocked_post.call_args[1]['json']['pictures'][0]['content'] == 'base64encoded_picture'
|
||||
assert mocked_post.call_args[1]['json']['coordinate']['latitude'] == '48.85438994604021'
|
||||
assert mocked_post.call_args[1]['json']['coordinate']['longitude'] == '2.3497223854064946'
|
||||
|
||||
data['comment'] = 'my comment'
|
||||
response = app.post_json(endpoint, params=data)
|
||||
assert mocked_post.call_args[1]['json']['comment']['content'] == 'my comment'
|
||||
|
|
Loading…
Reference in New Issue