toulouse-foederis: allow empty degree files (#82390)
gitea/passerelle/pipeline/head This commit looks good Details

This commit is contained in:
Corentin Sechet 2023-10-16 10:13:50 +02:00
parent 3d5ec0268c
commit 76f3860ad2
2 changed files with 47 additions and 29 deletions

View File

@ -35,7 +35,7 @@ ATTACHMENT_SCHEMA = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'title': _('Attachment and degree data.'),
'description': '',
'required': ['application_id', 'name', 'file'],
'required': ['application_id', 'name'],
'type': 'object',
'properties': {
'application_id': {
@ -56,6 +56,8 @@ ATTACHMENT_SCHEMA = {
},
'file': {
'description': _('File to attach.'),
'oneOf': [
{
'type': 'object',
'required': ['filename', 'content_type', 'content'],
'properties': {
@ -73,6 +75,9 @@ ATTACHMENT_SCHEMA = {
},
},
},
{'type': 'null'},
],
},
},
}
@ -705,7 +710,7 @@ class Resource(BaseResource, HTTPResource):
def attach_degree(self, request, post_data):
application_id = post_data['application_id']
degree_label = post_data['name']
file = post_data['file']
file = post_data.get('file')
degree_data = self.http_request(
'POST',
@ -715,6 +720,7 @@ class Resource(BaseResource, HTTPResource):
degree_id = degree_data[0]['id']
if file is not None:
self.http_request(
'POST',
f'data/diplome2/{degree_id}/fields/justificatif_diplome?viewIntegrationName=api_publik',

View File

@ -667,6 +667,18 @@ class TestEndpoints:
assert response.json['err'] == 0
with httmock.HTTMock(create_degree_handler, degree_file_handler, error_handler):
response = app.post_json(
'/toulouse-foederis/foederis/attach-degree',
params={
'application_id': '424242',
'name': 'DUT anarchisme',
'file': None,
},
)
assert response.json['err'] == 0
def test_migration_0003_no_null_no_charfield(migration):
with connection.cursor() as cur: