Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
e7319132
Commit
e7319132
authored
7 years ago
by
Megan Henning
Browse files
Options
Downloads
Patches
Plain Diff
Add analysis info editing
parent
847a20f6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/api.py
+1
-0
1 addition, 0 deletions
api/api.py
api/handlers/refererhandler.py
+16
-0
16 additions, 0 deletions
api/handlers/refererhandler.py
tests/integration_tests/python/test_containers.py
+66
-0
66 additions, 0 deletions
tests/integration_tests/python/test_containers.py
with
83 additions
and
0 deletions
api/api.py
+
1
−
0
View file @
e7319132
...
...
@@ -245,6 +245,7 @@ endpoints = [
prefix
(
'
/analyses/<_id:{cid}>
'
,
[
route
(
'
/files
'
,
AnalysesHandler
,
h
=
'
download
'
,
m
=
[
'
GET
'
]),
route
(
'
/files/<filename:{fname}>
'
,
AnalysesHandler
,
h
=
'
download
'
,
m
=
[
'
GET
'
]),
route
(
'
/info
'
,
AnalysesHandler
,
h
=
'
modify_info
'
,
m
=
[
'
POST
'
]),
]),
prefix
(
'
/<:{cname}>/<:{cid}>/<cont_name:analyses>/<cid:{cid}>
'
,
[
route
(
'
/<list_name:notes>
'
,
NotesListHandler
,
m
=
[
'
POST
'
]),
...
...
This diff is collapsed.
Click to expand it.
api/handlers/refererhandler.py
+
16
−
0
View file @
e7319132
...
...
@@ -126,6 +126,22 @@ class AnalysesHandler(RefererHandler):
else
:
self
.
abort
(
404
,
'
Element not updated in container {} {}
'
.
format
(
self
.
storage
.
cont_name
,
_id
))
@validators.verify_payload_exists
def
modify_info
(
self
,
**
kwargs
):
_id
=
kwargs
.
get
(
'
_id
'
)
analysis
=
self
.
storage
.
get_container
(
_id
)
parent
=
self
.
storage
.
get_parent
(
analysis
[
'
parent
'
][
'
type
'
],
analysis
[
'
parent
'
][
'
id
'
])
permchecker
=
self
.
get_permchecker
(
parent
)
permchecker
(
noop
)(
'
PUT
'
)
payload
=
self
.
request
.
json_body
validators
.
validate_data
(
payload
,
'
info_update.json
'
,
'
input
'
,
'
POST
'
)
self
.
storage
.
modify_info
(
_id
,
payload
)
return
def
get
(
self
,
**
kwargs
):
_id
=
kwargs
.
get
(
'
_id
'
)
analysis
=
self
.
storage
.
get_container
(
_id
)
...
...
This diff is collapsed.
Click to expand it.
tests/integration_tests/python/test_containers.py
+
66
−
0
View file @
e7319132
...
...
@@ -1065,6 +1065,72 @@ def test_edit_subject_info(data_builder, as_admin, as_user):
assert
r
.
json
()[
'
info
'
]
==
{}
def
test_edit_analysis_info
(
data_builder
,
default_payload
,
file_form
,
as_admin
,
as_user
):
"""
Abridged version since it uses same storage layer as container info
"""
gear_doc
=
default_payload
[
'
gear
'
][
'
gear
'
]
gear_doc
[
'
inputs
'
]
=
{
'
csv
'
:
{
'
base
'
:
'
file
'
}}
gear
=
data_builder
.
create_gear
(
gear
=
gear_doc
)
project
=
data_builder
.
create_project
()
assert
as_admin
.
post
(
'
/projects/
'
+
project
+
'
/files
'
,
files
=
file_form
(
'
test.csv
'
)).
ok
r
=
as_admin
.
post
(
'
/projects/
'
+
project
+
'
/analyses
'
,
params
=
{
'
job
'
:
'
true
'
},
json
=
{
'
analysis
'
:
{
'
label
'
:
'
with-job
'
},
'
job
'
:
{
'
gear_id
'
:
gear
,
'
inputs
'
:
{
'
csv
'
:
{
'
type
'
:
'
project
'
,
'
id
'
:
project
,
'
name
'
:
'
test.csv
'
}}
}
})
assert
r
.
ok
analysis
=
r
.
json
()[
'
_id
'
]
r
=
as_admin
.
get
(
'
/analyses/
'
+
analysis
)
assert
r
.
ok
assert
not
r
.
json
()[
'
info
'
]
# Send improper payload
r
=
as_admin
.
post
(
'
/analyses/
'
+
analysis
+
'
/info
'
,
json
=
{
'
delete
'
:
[
'
map
'
],
'
replace
'
:
{
'
not_going
'
:
'
to_happen
'
}
})
assert
r
.
status_code
==
400
# Send improper payload
r
=
as_admin
.
post
(
'
/analyses/
'
+
analysis
+
'
/info
'
,
json
=
{
'
delete
'
:
{
'
a
'
:
'
map
'
},
})
assert
r
.
status_code
==
400
# Send improper payload
r
=
as_admin
.
post
(
'
/analyses/
'
+
analysis
+
'
/info
'
,
json
=
{
'
set
'
:
'
cannot do this
'
,
})
assert
r
.
status_code
==
400
# Attempt full replace of info
analysis_info
=
{
'
a
'
:
'
b
'
,
'
test
'
:
123
,
'
map
'
:
{
'
a
'
:
'
b
'
},
'
list
'
:
[
1
,
2
,
3
]
}
r
=
as_admin
.
post
(
'
/analyses/
'
+
analysis
+
'
/info
'
,
json
=
{
'
replace
'
:
analysis_info
})
assert
r
.
ok
r
=
as_admin
.
get
(
'
/analyses/
'
+
analysis
)
assert
r
.
ok
assert
r
.
json
()[
'
info
'
]
==
analysis_info
def
test_fields_list_requests
(
data_builder
,
file_form
,
as_admin
):
# Ensure sensitive keys are not returned on list endpoints
# Project: info and files.info
...
...
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