isere_ens: add new API version (#74256)
gitea-wip/passerelle/pipeline/pr-main This commit looks good Details
gitea/passerelle/pipeline/pr-main Something is wrong with the build of this commit Details
gitea/passerelle/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Thomas NOËL 2023-02-07 12:27:52 +01:00
parent db5a496b15
commit 46c9c2ccc4
2 changed files with 6 additions and 5 deletions

View File

@ -31,6 +31,7 @@ from passerelle.utils.jsonresponse import APIError
API_VERSION = [
('1.0.0', '1.0.0'),
('2.1.0', '2.1.0'),
('2.1.1', '2.1.1'),
]
API_VERSION_DEFAULT = '1.0.0'
@ -98,7 +99,7 @@ SITE_BOOKING_SCHOOL_SCHEMA = {
"pattern": "^[0-9]*$",
},
"group": {
"description": "school group id (API v2.1.0, use applicant if empty)",
"description": "school group id (API v2.1.0/v2.1.1, use applicant if empty)",
"type": "string",
"pattern": "^[0-9]*$",
},
@ -461,7 +462,7 @@ class IsereENS(BaseResource, HTTPResource):
payload['applicant'] = post_data['applicant']
else:
raise APIError(
'group or applicant are mandatory (API v2.1.0)',
'group or applicant are mandatory (API v2.1.0/v2.1.1)',
err_code='bad-request',
http_status=400,
)
@ -487,7 +488,7 @@ class IsereENS(BaseResource, HTTPResource):
display_order=5,
perm="can_access",
parameters={
"code": {"description": _('Booking Code (API v1.0.0) or External ID (API v2.1.0)')},
"code": {"description": _('Booking Code (API v1.0.0) or External ID (API v2.1.0/v2.1.1)')},
},
)
def get_site_booking(self, request, code):

View File

@ -518,13 +518,13 @@ def test_post_book(mocked_post, app, setup, api_version):
response = app.post_json(endpoint, params=book, status=400)
assert response.json['err'] == 'bad-request'
assert response.json['data'] is None
assert response.json['err_desc'] == 'group or applicant are mandatory (API v2.1.0)'
assert response.json['err_desc'] == 'group or applicant are mandatory (API v2.1.0/v2.1.1)'
del book['group']
response = app.post_json(endpoint, params=book, status=400)
assert response.json['err'] == 'bad-request'
assert response.json['data'] is None
assert response.json['err_desc'] == 'group or applicant are mandatory (API v2.1.0)'
assert response.json['err_desc'] == 'group or applicant are mandatory (API v2.1.0/v2.1.1)'
book['applicant'] = 'ecole 1'
response = app.post_json(endpoint, params=book)