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
d38ff32d
Commit
d38ff32d
authored
5 years ago
by
Valentin Rigal
Browse files
Options
Downloads
Patches
Plain Diff
Succint ES test
parent
2cf28e16
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/documents/tests/test_search.py
+26
-3
26 additions, 3 deletions
arkindex/documents/tests/test_search.py
with
26 additions
and
3 deletions
arkindex/documents/tests/test_search.py
+
26
−
3
View file @
d38ff32d
...
...
@@ -3,7 +3,7 @@ from django.contrib.auth.models import AnonymousUser
from
django.urls
import
reverse
from
rest_framework
import
status
from
elasticsearch_dsl.connections
import
connections
from
arkindex_common.enums
import
EntityType
from
arkindex_common.enums
import
EntityType
,
MetaType
from
arkindex.project.tests
import
FixtureAPITestCase
from
arkindex.project.elastic
import
ESTranscription
from
arkindex.documents.models
import
Transcription
,
Element
,
Corpus
,
DataSource
,
MLToolType
...
...
@@ -96,7 +96,7 @@ class TestSearchAPI(FixtureAPITestCase):
"
_type
"
:
"
entity
"
,
}
def
test_element_search
(
self
):
def
test_element_
transcription_
search
(
self
):
elt
=
Element
.
objects
.
get
(
name
=
"
Volume 1, page 1r
"
)
ts
=
Transcription
.
objects
.
filter
(
text
=
"
PARIS
"
,
zone__image__path
=
'
img1
'
)
...
...
@@ -135,7 +135,7 @@ class TestSearchAPI(FixtureAPITestCase):
map
(
str
,
Corpus
.
objects
.
readable
(
AnonymousUser
()).
values_list
(
'
id
'
,
flat
=
True
)),
)
nested
=
kwargs
[
'
body
'
][
'
query
'
][
'
bool
'
][
'
must
'
][
0
][
'
nested
'
]
nested
=
kwargs
[
'
body
'
][
'
query
'
][
'
bool
'
][
'
should
'
][
0
][
'
nested
'
]
self
.
assertEqual
(
nested
[
'
score_mode
'
],
'
sum
'
)
self
.
assertEqual
(
nested
[
'
path
'
],
'
transcriptions
'
)
self
.
assertIn
(
'
inner_hits
'
,
nested
)
...
...
@@ -164,6 +164,29 @@ class TestSearchAPI(FixtureAPITestCase):
}},
])
def
test_element_reference_search
(
self
):
elt
=
Element
.
objects
.
get
(
name
=
"
Volume 1, page 1r
"
)
ref
=
elt
.
metadatas
.
create
(
type
=
MetaType
.
Reference
,
name
=
'
reference
'
,
value
=
'
reference1337
'
)
self
.
es_mock
.
count
.
return_value
=
{
'
count
'
:
1
}
self
.
es_mock
.
search
.
return_value
=
self
.
build_es_response
(
[
self
.
make_element_hit
(
elt
,
[]),
],
)
response
=
self
.
client
.
get
(
reverse
(
'
api:element-search
'
),
{
'
q
'
:
ref
.
value
[
2
:]})
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
args
,
kwargs
=
self
.
es_mock
.
search
.
call_args
ref_query
=
kwargs
[
'
body
'
][
'
query
'
][
'
bool
'
][
'
should
'
][
1
]
self
.
assertDictEqual
(
ref_query
,
{
"
wildcard
"
:
{
"
references
"
:
"
*{}*
"
.
format
(
ref
.
value
[
2
:])
}
})
def
test_iiif_transcription_search
(
self
):
# Filter to only get transcriptions from volume 1
unfiltered
=
Transcription
.
objects
.
filter
(
text
=
"
PARIS
"
)
...
...
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