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
a1fae635
Commit
a1fae635
authored
Dec 26, 2014
by
Tim Babych
Committed by
Oleg Marshev
Jan 05, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_es()
parent
23c49ecc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
notesapi/v1/tests/test_views.py
+9
-10
No files found.
notesapi/v1/tests/test_views.py
View file @
a1fae635
...
@@ -16,7 +16,6 @@ from notesapi.v1.models import NoteMappingType, note_searcher
...
@@ -16,7 +16,6 @@ from notesapi.v1.models import NoteMappingType, note_searcher
TEST_USER
=
"test_user_id"
TEST_USER
=
"test_user_id"
es
=
get_es
()
class
BaseAnnotationViewTests
(
APITestCase
):
class
BaseAnnotationViewTests
(
APITestCase
):
"""
"""
...
@@ -63,25 +62,25 @@ class BaseAnnotationViewTests(APITestCase):
...
@@ -63,25 +62,25 @@ class BaseAnnotationViewTests(APITestCase):
def
tearDown
(
self
):
def
tearDown
(
self
):
for
note_id
in
note_searcher
.
all
()
.
values_list
(
'id'
):
for
note_id
in
note_searcher
.
all
()
.
values_list
(
'id'
):
es
.
delete
(
get_es
()
.
delete
(
index
=
settings
.
ES_INDEXES
[
'default'
],
index
=
settings
.
ES_INDEXES
[
'default'
],
doc_type
=
NoteMappingType
.
get_mapping_type_name
(),
doc_type
=
NoteMappingType
.
get_mapping_type_name
(),
id
=
note_id
[
0
][
0
]
id
=
note_id
[
0
][
0
]
)
)
es
.
indices
.
refresh
()
get_es
()
.
indices
.
refresh
()
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
es
.
indices
.
create
(
index
=
settings
.
ES_INDEXES
[
'default'
],
ignore
=
400
)
get_es
()
.
indices
.
create
(
index
=
settings
.
ES_INDEXES
[
'default'
],
ignore
=
400
)
es
.
indices
.
refresh
()
get_es
()
.
indices
.
refresh
()
@classmethod
@classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
"""
"""
* deletes the test index
* deletes the test index
"""
"""
es
.
indices
.
delete
(
index
=
settings
.
ES_INDEXES
[
'default'
])
get_es
()
.
indices
.
delete
(
index
=
settings
.
ES_INDEXES
[
'default'
])
es
.
indices
.
refresh
()
get_es
()
.
indices
.
refresh
()
def
_create_annotation
(
self
,
refresh
=
True
,
**
kwargs
):
def
_create_annotation
(
self
,
refresh
=
True
,
**
kwargs
):
"""
"""
...
@@ -92,14 +91,14 @@ class BaseAnnotationViewTests(APITestCase):
...
@@ -92,14 +91,14 @@ class BaseAnnotationViewTests(APITestCase):
url
=
reverse
(
'api:v1:annotations'
)
url
=
reverse
(
'api:v1:annotations'
)
response
=
self
.
client
.
post
(
url
,
opts
,
format
=
'json'
)
response
=
self
.
client
.
post
(
url
,
opts
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
es
.
indices
.
refresh
()
get_es
()
.
indices
.
refresh
()
return
response
.
data
.
copy
()
return
response
.
data
.
copy
()
def
_get_annotation
(
self
,
annotation_id
):
def
_get_annotation
(
self
,
annotation_id
):
"""
"""
Fetch annotation directly from elasticsearch.
Fetch annotation directly from elasticsearch.
"""
"""
es
.
indices
.
refresh
()
get_es
()
.
indices
.
refresh
()
url
=
reverse
(
'api:v1:annotations_detail'
,
kwargs
=
{
'annotation_id'
:
annotation_id
})
url
=
reverse
(
'api:v1:annotations_detail'
,
kwargs
=
{
'annotation_id'
:
annotation_id
})
response
=
self
.
client
.
get
(
url
,
self
.
headers
)
response
=
self
.
client
.
get
(
url
,
self
.
headers
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
...
@@ -222,7 +221,7 @@ class AnnotationViewTests(BaseAnnotationViewTests):
...
@@ -222,7 +221,7 @@ class AnnotationViewTests(BaseAnnotationViewTests):
url
=
reverse
(
'api:v1:annotations_detail'
,
kwargs
=
{
'annotation_id'
:
data
[
'id'
]})
url
=
reverse
(
'api:v1:annotations_detail'
,
kwargs
=
{
'annotation_id'
:
data
[
'id'
]})
print
payload
print
payload
response
=
self
.
client
.
put
(
url
,
payload
,
format
=
'json'
)
response
=
self
.
client
.
put
(
url
,
payload
,
format
=
'json'
)
es
.
indices
.
refresh
()
get_es
()
.
indices
.
refresh
()
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
annotation
=
self
.
_get_annotation
(
data
[
'id'
])
annotation
=
self
.
_get_annotation
(
data
[
'id'
])
...
...
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