Skip to content
Snippets Groups Projects
Commit 2c9109e6 authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Allow Workers processes on non-folder elements without an image

parent fd2d5f97
No related branches found
No related tags found
1 merge request!1946Allow Workers processes on non-folder elements without an image
......@@ -381,10 +381,6 @@ class ElementsWorkflowSerializer(serializers.Serializer):
elt_type = data.get('element_type')
selection = data.get('selection')
# Ensure element is a folder or has a zone
if element and element.type.folder is False and (element.image_id is None or element.polygon is None):
raise ValidationError({'element': ['Element has to be a folder or an element with a zone.']})
if selection and not settings.ARKINDEX_FEATURES['selection']:
raise ValidationError({'selection': ['Selection is not available on this instance.']})
......
......@@ -345,21 +345,60 @@ class TestWorkflows(FixtureAPITestCase):
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
def test_create_element_workflow_non_folder_no_zone(self):
"""
An element that is not of a folder type and has no image or polygon
should still be usable to create a process
"""
self.client.force_login(self.user)
element = self.corpus.elements.create(type=self.pages.first().type, name='Kill me please')
response = self.client.post(
reverse('api:corpus-workflow'),
{
'corpus': str(self.corpus.id),
'element': str(element.id),
with self.assertNumQueries(12):
response = self.client.post(
reverse('api:corpus-workflow'),
{
'corpus': str(self.corpus.id),
'element': str(element.id),
},
format='json'
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
process = Process.objects.get(element=element, mode=ProcessMode.Workers)
self.assertDictEqual(response.json(), {
'name': None,
'id': str(process.id),
'state': 'unscheduled',
'corpus': str(self.volume.corpus.id),
'files': [],
'mode': 'workers',
'revision': process.revision,
'workflow': None,
'folder_type': None,
'element_type': None,
'element': {
'id': str(element.id),
'name': 'Kill me please',
'type': 'page',
'zone': None,
'corpus': {
'id': str(self.corpus.id),
'name': 'Unit Tests',
'public': True,
},
'rotation_angle': 0,
'mirrored': False,
'thumbnail_url': None,
'thumbnail_put_url': None,
},
format='json'
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertDictEqual(
response.json(),
{'element': ['Element has to be a folder or an element with a zone.']}
)
'template_id': None,
'load_children': False,
'use_cache': False,
'use_gpu': False,
'activity_state': ActivityState.Disabled.value,
'element_name_contains': None,
'model_id': None,
'train_folder_id': None,
'validation_folder_id': None,
'test_folder_id': None,
})
def test_create_element_workflow_mixed_selection_filters(self):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment