Skip to content
Snippets Groups Projects
Commit 6a8477b3 authored by ml bonhomme's avatar ml bonhomme :bee: Committed by Erwan Rouchet
Browse files

have both put and patch tests for updating processes of non-Workers mode

parent d9088aed
No related branches found
No related tags found
1 merge request!1546have both put and patch tests for updating processes of non-Workers mode
......@@ -605,17 +605,18 @@ class TestImports(FixtureAPITestCase):
def test_update_process_wrong_mode(self):
"""
Other process modes than Workers cannot be patched when there is more than only name attribute
Processes that are not of Workers mode cannot be updated, except the 'name' field
"""
self.client.force_login(self.user)
forbidden_modes = list(DataImportMode)
forbidden_modes.remove(DataImportMode.Workers)
for mode in forbidden_modes:
dataimport = DataImport.objects.create(mode=mode, corpus=self.corpus, creator=self.user)
response = self.client.patch(
response = self.client.put(
reverse('api:import-details', kwargs={'pk': dataimport.id}),
{
'name': 'newName',
'template_id': None,
'element_name_contains': 'AAA',
'element_type': 'page',
'load_children': True
......@@ -628,6 +629,32 @@ class TestImports(FixtureAPITestCase):
{'__all__': ['Only processes of mode Workers can be updated']}
)
def test_update_process_wrong_mode_patch(self):
"""
Fields other than 'name' cannot be updated in processes that are not of Workers mode
"""
self.client.force_login(self.user)
forbidden_modes = list(DataImportMode)
forbidden_modes.remove(DataImportMode.Workers)
updated_fields = [
{'template_id': None},
{'element_name_contains': 'ipsum'},
{'element_type': 'page'},
{'load_children': True}
]
for mode in forbidden_modes:
dataimport = DataImport.objects.create(mode=mode, corpus=self.corpus, creator=self.user)
for params in updated_fields:
with self.subTest(**params):
response = self.client.patch(reverse('api:import-details', kwargs={'pk': dataimport.id}), params, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertDictEqual(
response.json(),
{'__all__': ['Only processes of mode Workers can be updated']}
)
def test_update_process_only_name(self):
"""
Whatever the process mode, name attribute (alone) can be updated
......
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