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
d561c251
Commit
d561c251
authored
Feb 23, 2016
by
Muhammad Ammar
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #41 from edx/ammar/tnl-4119-fix-unicode-search
fix search when text and/or tags contain unicode data
parents
fcd1de13
87974174
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
Makefile
+1
-1
notesapi/v1/models.py
+1
-1
notesapi/v1/tests/test_views.py
+20
-0
No files found.
Makefile
View file @
d561c251
...
@@ -13,7 +13,7 @@ test: clean
...
@@ -13,7 +13,7 @@ test: clean
./manage.py
test
--settings
=
$(test_settings)
--with-coverage
--with-ignore-docstrings
\
./manage.py
test
--settings
=
$(test_settings)
--with-coverage
--with-ignore-docstrings
\
--exclude-dir
=
notesserver/settings
--cover-inclusive
--cover-branches
\
--exclude-dir
=
notesserver/settings
--cover-inclusive
--cover-branches
\
--cover-html
--cover-html-dir
=
build/coverage/html/
\
--cover-html
--cover-html-dir
=
build/coverage/html/
\
--cover-xml
--cover-xml-file
=
build/coverage/coverage.xml
\
--cover-xml
--cover-xml-file
=
build/coverage/coverage.xml
--verbosity
=
2
\
$
(
foreach package,
$(PACKAGES)
,--cover-package
=
$(package)
)
\
$
(
foreach package,
$(PACKAGES)
,--cover-package
=
$(package)
)
\
$(PACKAGES)
$(PACKAGES)
...
...
notesapi/v1/models.py
View file @
d561c251
...
@@ -35,6 +35,6 @@ class Note(models.Model):
...
@@ -35,6 +35,6 @@ class Note(models.Model):
note_dict
[
'ranges'
]
=
json
.
dumps
(
ranges
)
note_dict
[
'ranges'
]
=
json
.
dumps
(
ranges
)
note_dict
[
'user_id'
]
=
note_dict
.
pop
(
'user'
,
None
)
note_dict
[
'user_id'
]
=
note_dict
.
pop
(
'user'
,
None
)
note_dict
[
'tags'
]
=
json
.
dumps
(
note_dict
.
get
(
'tags'
,
list
()))
note_dict
[
'tags'
]
=
json
.
dumps
(
note_dict
.
get
(
'tags'
,
list
())
,
ensure_ascii
=
False
)
return
cls
(
**
note_dict
)
return
cls
(
**
note_dict
)
notesapi/v1/tests/test_views.py
View file @
d561c251
...
@@ -959,6 +959,26 @@ class AnnotationSearchViewTests(BaseAnnotationViewTests):
...
@@ -959,6 +959,26 @@ class AnnotationSearchViewTests(BaseAnnotationViewTests):
start
=
start
start
=
start
)
)
@ddt.unpack
@ddt.data
(
{
"text"
:
u"Ammar محمد عمار Muhammad"
,
"search"
:
u"محمد عمار"
,
"tags"
:
[
u"عمار"
,
u"Muhammad"
,
u"محمد"
]},
{
"text"
:
u"Ammar محمد عمار Muhammad"
,
"search"
:
u"محمد"
,
"tags"
:
[
u"محمد"
,
u"Muhammad"
]},
{
"text"
:
u"Ammar محمد عمار Muhammad"
,
"search"
:
u"عمار"
,
"tags"
:
[
u"ammar"
,
u"عمار"
]},
{
"text"
:
u"Muhammad Ammar"
,
"search"
:
u"عمار"
,
"tags"
:
[
u"ammar"
,
u"عمار"
]},
{
"text"
:
u"محمد عمار"
,
"search"
:
u"Muhammad"
,
"tags"
:
[
u"Muhammad"
,
u"عمار"
]}
)
@unittest.skipIf
(
settings
.
ES_DISABLED
,
"MySQL cannot do highlighting"
)
def
test_search_unicode_text_and_tags
(
self
,
text
,
search
,
tags
):
"""
Verify that search works as expected with unicode and non-unicode text and tags.
"""
self
.
_create_annotation
(
text
=
text
,
tags
=
tags
)
response
=
self
.
_get_search_results
(
text
=
search
)
self
.
assertEqual
(
response
[
"total"
],
1
)
self
.
assertEqual
(
response
[
"rows"
][
0
][
"text"
],
text
)
self
.
assertEqual
(
response
[
"rows"
][
0
][
"tags"
],
tags
)
@patch
(
'django.conf.settings.DISABLE_TOKEN_CHECK'
,
True
)
@patch
(
'django.conf.settings.DISABLE_TOKEN_CHECK'
,
True
)
class
AllowAllAnnotationViewTests
(
BaseAnnotationViewTests
):
class
AllowAllAnnotationViewTests
(
BaseAnnotationViewTests
):
...
...
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