Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-notes-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-notes-api
Commits
6ddfa002
Commit
6ddfa002
authored
Feb 04, 2016
by
muhammad-ammar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix unicode error when search with highlighting
TNL-4101
parent
333ce86a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletions
+20
-1
notesapi/v1/serializers.py
+1
-1
notesapi/v1/tests/test_views.py
+19
-0
No files found.
notesapi/v1/serializers.py
View file @
6ddfa002
...
...
@@ -56,7 +56,7 @@ class NotesElasticSearchSerializer(serializers.Serializer): # pylint: disable=a
Return note text.
"""
if
note
.
highlighted
:
return
note
.
highlighted
[
0
]
.
decode
(
'unicode_escape'
)
return
note
.
highlighted
[
0
]
return
note
.
text
def
get_ranges
(
self
,
note
):
...
...
notesapi/v1/tests/test_views.py
View file @
6ddfa002
...
...
@@ -738,6 +738,25 @@ class AnnotationSearchViewTests(BaseAnnotationViewTests):
response
=
self
.
_get_search_results
(
text
=
u"Свят"
)
self
.
assertEqual
(
response
[
'rows'
][
0
][
'text'
],
u'Веселих свят'
)
@ddt.unpack
@ddt.data
(
{
"text"
:
u"Веселих свят"
,
'text_to_search'
:
u"веселих"
,
'result'
:
u"{}Веселих{} свят"
},
{
"text"
:
"The Hunger games"
,
'text_to_search'
:
"Hunger"
,
'result'
:
"The {}Hunger{} games"
}
)
@unittest.skipIf
(
settings
.
ES_DISABLED
,
"MySQL cannot do highlighting"
)
def
test_search_with_highlighting
(
self
,
text
,
text_to_search
,
result
):
"""
Tests searching of unicode and non-unicode text with highlighting enabled.
"""
start_tag
=
"{elasticsearch_highlight_start}"
end_tag
=
"{elasticsearch_highlight_end}"
self
.
_create_annotation
(
text
=
text
)
response
=
self
.
_get_search_results
(
text
=
text_to_search
,
highlight
=
True
)
self
.
assertEqual
(
response
[
'total'
],
1
)
self
.
assertEqual
(
response
[
'rows'
][
0
][
'text'
],
result
.
format
(
start_tag
,
end_tag
))
def
test_search_multiword
(
self
):
"""
Tests searching of complex words and word combinations
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment