Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
elasticsearch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cubicweb
cubes
elasticsearch
Commits
d60fe2d6642f
Commit
d60fe2d6642f
authored
8 years ago
by
Arthur Lutz
Browse files
Options
Downloads
Patches
Plain Diff
[test] test pagination up to 150 results
parent
be9be3676bc8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_elastic_search.py
+26
-5
26 additions, 5 deletions
test/test_elastic_search.py
with
26 additions
and
5 deletions
test/test_elastic_search.py
+
26
−
5
View file @
d60fe2d6
...
...
@@ -106,10 +106,16 @@
def
mock_execute
(
*
args
,
**
kwargs
):
def
mock_execute_150
(
*
args
,
**
kwargs
):
return
mock_execute
(
100
)
def
mock_execute_15
(
*
args
,
**
kwargs
):
return
mock_execute
(
15
)
def
mock_execute_1
(
*
args
,
**
kwargs
):
return
mock_execute
(
1
)
def
mock_execute
(
nb_results
):
result
=
{
'
_source
'
:
{
'
description
'
:
'
test
'
,
'
cwuri
'
:
'
http://example.org/123
'
,
'
eid
'
:
123
,
'
title
'
:
'
test
'
},
'
_type
'
:
'
BaseContent
'
,
'
_score
'
:
1
}
...
...
@@ -110,11 +116,11 @@
result
=
{
'
_source
'
:
{
'
description
'
:
'
test
'
,
'
cwuri
'
:
'
http://example.org/123
'
,
'
eid
'
:
123
,
'
title
'
:
'
test
'
},
'
_type
'
:
'
BaseContent
'
,
'
_score
'
:
1
}
search
=
{
'
hits
'
:
{
'
hits
'
:
repeat
(
result
,
15
),
'
total
'
:
15
search
=
{
'
hits
'
:
{
'
hits
'
:
repeat
(
result
,
nb_results
),
'
total
'
:
nb_results
}}
return
FacetedResponse
(
search
,
search
)
...
...
@@ -123,5 +129,6 @@
class
ElasticSearchViewsTC
(
testlib
.
CubicWebTC
):
@patch
(
'
elasticsearch_dsl.search.Search.execute
'
,
new
=
mock_execute
)
# TODO generate X tests ranging the number of results from 1 to 150
@patch
(
'
elasticsearch_dsl.search.Search.execute
'
,
new
=
mock_execute_1
)
@patch
(
'
elasticsearch_dsl.connections.connections.get_connection
'
,
new
=
mock_cnx
)
...
...
@@ -127,5 +134,19 @@
@patch
(
'
elasticsearch_dsl.connections.connections.get_connection
'
,
new
=
mock_cnx
)
def
test_search_view
(
self
):
def
test_search_view_1
(
self
):
with
self
.
new_access
(
'
anon
'
).
web_request
()
as
req
:
# self._cw.form.get('search'))
self
.
view
(
'
esearch
'
,
req
=
req
,
template
=
None
)
@patch
(
'
elasticsearch_dsl.search.Search.execute
'
,
new
=
mock_execute_15
)
@patch
(
'
elasticsearch_dsl.connections.connections.get_connection
'
,
new
=
mock_cnx
)
def
test_search_view_15
(
self
):
with
self
.
new_access
(
'
anon
'
).
web_request
()
as
req
:
# self._cw.form.get('search'))
self
.
view
(
'
esearch
'
,
req
=
req
,
template
=
None
)
@patch
(
'
elasticsearch_dsl.search.Search.execute
'
,
new
=
mock_execute_150
)
@patch
(
'
elasticsearch_dsl.connections.connections.get_connection
'
,
new
=
mock_cnx
)
def
test_search_view_150
(
self
):
with
self
.
new_access
(
'
anon
'
).
web_request
()
as
req
:
# self._cw.form.get('search'))
self
.
view
(
'
esearch
'
,
req
=
req
,
template
=
None
)
...
...
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