Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
6a8477b3
Commit
6a8477b3
authored
3 years ago
by
ml bonhomme
Committed by
Erwan Rouchet
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
have both put and patch tests for updating processes of non-Workers mode
parent
d9088aed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1546
have both put and patch tests for updating processes of non-Workers mode
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/dataimport/tests/test_imports.py
+29
-2
29 additions, 2 deletions
arkindex/dataimport/tests/test_imports.py
with
29 additions
and
2 deletions
arkindex/dataimport/tests/test_imports.py
+
29
−
2
View file @
6a8477b3
...
...
@@ -605,17 +605,18 @@ class TestImports(FixtureAPITestCase):
def
test_update_process_wrong_mode
(
self
):
"""
Other p
rocess
mod
es tha
n
Workers cannot be
patched when there is more than only name attribute
P
rocesses tha
t 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
.
p
atch
(
response
=
self
.
client
.
p
ut
(
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment