Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-web
Commits
7e2590dc
Commit
7e2590dc
authored
9 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
Fix: person and origin have int id, not string
parent
4cf94124
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/web/ui/controller.py
+2
-2
2 additions, 2 deletions
swh/web/ui/controller.py
swh/web/ui/tests/test_controller.py
+8
-4
8 additions, 4 deletions
swh/web/ui/tests/test_controller.py
with
10 additions
and
6 deletions
swh/web/ui/controller.py
+
2
−
2
View file @
7e2590dc
...
...
@@ -190,7 +190,7 @@ def _api_lookup(criteria, lookup_fn, error_msg_if_not_found):
return
jsonify
(
res
)
@app.route
(
'
/api/1/origin/<
str
in
g
:origin_id>
'
)
@app.route
(
'
/api/1/origin/<in
t
:origin_id>
'
)
@jsonp
def
api_origin
(
origin_id
):
"""
Return information about origin.
"""
...
...
@@ -199,7 +199,7 @@ def api_origin(origin_id):
error_msg_if_not_found
=
'
Origin with id %s not found.
'
%
origin_id
)
@app.route
(
'
/api/1/person/<
str
in
g
:person_id>
'
)
@app.route
(
'
/api/1/person/<in
t
:person_id>
'
)
@jsonp
def
api_person
(
person_id
):
"""
Return information about person.
"""
...
...
This diff is collapsed.
Click to expand it.
swh/web/ui/tests/test_controller.py
+
8
−
4
View file @
7e2590dc
...
...
@@ -267,7 +267,7 @@ class ApiTestCase(unittest.TestCase):
def
api_origin
(
self
,
mock_service
):
# given
stub_origin
=
{
'
id
'
:
'
origin-0
'
,
'
id
'
:
1234
,
'
lister
'
:
'
uuid-lister-0
'
,
'
project
'
:
'
uuid-project-0
'
,
'
url
'
:
'
ftp://some/url/to/origin/0
'
,
...
...
@@ -276,7 +276,7 @@ class ApiTestCase(unittest.TestCase):
mock_service
.
lookup_origin
.
return_value
=
stub_origin
# when
rv
=
self
.
app
.
get
(
'
/api/1/origin/
origin-0
'
)
rv
=
self
.
app
.
get
(
'
/api/1/origin/
1234
'
)
# then
self
.
assertEquals
(
rv
.
status_code
,
200
)
...
...
@@ -285,6 +285,8 @@ class ApiTestCase(unittest.TestCase):
response_data
=
json
.
loads
(
rv
.
data
.
decode
(
'
utf-8
'
))
self
.
assertEquals
(
response_data
,
stub_origin
)
mock_service
.
lookup_origin
.
assert_called_with
(
1234
)
@patch
(
'
swh.web.ui.controller.service
'
)
@istest
def
api_origin_not_found
(
self
,
mock_service
):
...
...
@@ -292,16 +294,18 @@ class ApiTestCase(unittest.TestCase):
mock_service
.
lookup_origin
.
return_value
=
None
# when
rv
=
self
.
app
.
get
(
'
/api/1/origin/
origin-0
'
)
rv
=
self
.
app
.
get
(
'
/api/1/origin/
4321
'
)
# then
self
.
assertEquals
(
rv
.
status_code
,
404
)
self
.
assertEquals
(
rv
.
mimetype
,
'
application/json
'
)
response_data
=
json
.
loads
(
rv
.
data
.
decode
(
'
utf-8
'
))
self
.
assertEquals
(
response_data
,
{
'
error
'
:
'
Origin with id
origin-0
not found.
'
'
error
'
:
'
Origin with id
4321
not found.
'
})
mock_service
.
lookup_origin
.
assert_called_with
(
4321
)
@patch
(
'
swh.web.ui.controller.service
'
)
@istest
def
api_release
(
self
,
mock_service
):
...
...
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