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
fd6b50da
Commit
fd6b50da
authored
6 years ago
by
vlorentz
Browse files
Options
Downloads
Patches
Plain Diff
Fix error handling + add test.
parent
4913fd66
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!61
Add api_origin_metadata_search.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/web/api/views/origin.py
+2
-3
2 additions, 3 deletions
swh/web/api/views/origin.py
swh/web/tests/api/views/test_origin.py
+9
-0
9 additions, 0 deletions
swh/web/tests/api/views/test_origin.py
with
11 additions
and
3 deletions
swh/web/api/views/origin.py
+
2
−
3
View file @
fd6b50da
...
...
@@ -4,10 +4,9 @@
# See top-level LICENSE file for more information
from
distutils.util
import
strtobool
from
rest_framework
import
status
from
rest_framework.response
import
Response
from
swh.web.common
import
service
from
swh.web.common.exc
import
BadInputExc
from
swh.web.common.utils
import
(
reverse
,
get_origin_visits
)
...
...
@@ -216,7 +215,7 @@ def api_origin_metadata_search(request):
if
not
fulltext
:
content
=
'"
fulltext
"
must be provided and non-empty.
'
r
eturn
Response
(
content
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
r
aise
BadInputExc
(
content
)
results
=
api_lookup
(
service
.
search_origin_metadata
,
fulltext
,
limit
)
...
...
This diff is collapsed.
Click to expand it.
swh/web/tests/api/views/test_origin.py
+
9
−
0
View file @
fd6b50da
...
...
@@ -289,3 +289,12 @@ class OriginApiTestCase(SWHWebTestCase, APITestCase):
self
.
assertEqual
(
rv
.
data
,
expected_data
)
mock_idx_storage
.
origin_intrinsic_metadata_search_fulltext
\
.
assert_called_with
(
conjunction
=
[
'
Jane Doe
'
],
limit
=
50
)
@patch
(
'
swh.web.common.service.idx_storage
'
)
def
test_api_origin_metadata_search_invalid
(
self
,
mock_idx_storage
):
rv
=
self
.
client
.
get
(
'
/api/1/origin/metadata-search/?fulltext=Jane%20Doe
'
)
# then
self
.
assertEqual
(
rv
.
status_code
,
400
,
rv
.
content
)
mock_idx_storage
.
assert_not_called
()
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