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
20c52ce0
Commit
20c52ce0
authored
Dec 26, 2014
by
Oleg Marshev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove annotator-store.
parent
10cc35be
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
17 additions
and
61 deletions
+17
-61
notesapi/management/commands/create_index.py
+2
-2
notesapi/v1/tests/test_views.py
+1
-1
notesserver/settings/common.py
+0
-8
notesserver/settings/dev.py
+1
-11
notesserver/settings/test.py
+1
-14
notesserver/settings/yaml_config.py
+0
-10
notesserver/test_views.py
+9
-9
notesserver/views.py
+3
-3
requirements/base.txt
+0
-3
No files found.
notesapi/management/commands/create_index.py
View file @
20c52ce0
from
django.core.management.base
import
BaseCommand
from
django.core.management.base
import
BaseCommand
from
annotator.annotation
import
Annotation
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
help
=
'Creates the mapping in the index.'
help
=
'Creates the mapping in the index.'
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
Annotation
.
create_all
()
#TODO: cretate mapping using elasticutils
pass
notesapi/v1/tests/test_views.py
View file @
20c52ce0
...
@@ -354,7 +354,7 @@ class AnnotationViewTests(BaseAnnotationViewTests):
...
@@ -354,7 +354,7 @@ class AnnotationViewTests(BaseAnnotationViewTests):
@patch
(
'django.conf.settings.DISABLE_TOKEN_CHECK'
,
True
)
@patch
(
'django.conf.settings.DISABLE_TOKEN_CHECK'
,
True
)
class
AllowAllAnnotationViewTests
(
BaseAnnotationViewTests
):
class
AllowAllAnnotationViewTests
(
BaseAnnotationViewTests
):
"""
"""
Test
annotator behavior when authorization is not enforced
Test
service behavior when authorization is not enforced.
"""
"""
def
test_create_no_payload
(
self
):
def
test_create_no_payload
(
self
):
...
...
notesserver/settings/common.py
View file @
20c52ce0
...
@@ -16,9 +16,6 @@ SECRET_KEY = '*^owi*4%!%9=#h@app!l^$jz8(c*q297^)4&4yn^#_m#fq=z#l'
...
@@ -16,9 +16,6 @@ SECRET_KEY = '*^owi*4%!%9=#h@app!l^$jz8(c*q297^)4&4yn^#_m#fq=z#l'
CLIENT_ID
=
'edx-notes-id'
CLIENT_ID
=
'edx-notes-id'
CLIENT_SECRET
=
'edx-notes-secret'
CLIENT_SECRET
=
'edx-notes-secret'
ELASTICSEARCH_URL
=
'http://127.0.0.1:9200'
ELASTICSEARCH_INDEX
=
'edx-notes'
ES_URLS
=
[
'http://localhost:9200'
]
ES_URLS
=
[
'http://localhost:9200'
]
ES_INDEXES
=
{
'default'
:
'notes_index'
}
ES_INDEXES
=
{
'default'
:
'notes_index'
}
ES_DISABLED
=
False
ES_DISABLED
=
False
...
@@ -92,11 +89,6 @@ LOGGING = {
...
@@ -92,11 +89,6 @@ LOGGING = {
'level'
:
'WARNING'
,
'level'
:
'WARNING'
,
'propagate'
:
True
'propagate'
:
True
},
},
'annotator.elasticsearch'
:
{
'handlers'
:
[
'console'
],
'level'
:
'WARNING'
,
'propagate'
:
True
},
'urllib3'
:
{
'urllib3'
:
{
'handlers'
:
[
'console'
],
'handlers'
:
[
'console'
],
'level'
:
'DEBUG'
,
'level'
:
'DEBUG'
,
...
...
notesserver/settings/dev.py
View file @
20c52ce0
import
annotator
from
annotator
import
es
from
.common
import
*
from
.common
import
*
DEBUG
=
True
DEBUG
=
True
E
LASTICSEARCH_INDEX
=
'edx-notes-dev'
E
S_INDEXES
=
{
'default'
:
'notes_index_dev'
}
DATABASES
=
{
DATABASES
=
{
'default'
:
{
'default'
:
{
...
@@ -12,11 +10,3 @@ DATABASES = {
...
@@ -12,11 +10,3 @@ DATABASES = {
'NAME'
:
'default.db'
,
'NAME'
:
'default.db'
,
}
}
}
}
###############################################################################
# Override default annotator-store elasticsearch settings.
###############################################################################
es
.
host
=
ELASTICSEARCH_URL
es
.
index
=
ELASTICSEARCH_INDEX
annotator
.
elasticsearch
.
RESULTS_MAX_SIZE
=
RESULTS_MAX_SIZE
###############################################################################
notesserver/settings/test.py
View file @
20c52ce0
from
annotator
import
es
import
annotator
from
.common
import
*
from
.common
import
*
DATABASES
=
{
DATABASES
=
{
...
@@ -12,18 +10,8 @@ TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
...
@@ -12,18 +10,8 @@ TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
DISABLE_TOKEN_CHECK
=
False
DISABLE_TOKEN_CHECK
=
False
INSTALLED_APPS
+=
(
'django_nose'
,)
INSTALLED_APPS
+=
(
'django_nose'
,)
###############################################################################
# Override default annotator-store elasticsearch settings.
###############################################################################
es
.
host
=
ELASTICSEARCH_URL
es
.
index
=
ELASTICSEARCH_INDEX
annotator
.
elasticsearch
.
RESULTS_MAX_SIZE
=
RESULTS_MAX_SIZE
###############################################################################
ES_INDEXES
=
{
'default'
:
'notes_index_test'
}
ES_INDEXES
=
{
'default'
:
'notes_index_test'
}
LOGGING
=
{
LOGGING
=
{
'version'
:
1
,
'version'
:
1
,
'disable_existing_loggers'
:
False
,
'disable_existing_loggers'
:
False
,
...
@@ -52,4 +40,4 @@ LOGGING = {
...
@@ -52,4 +40,4 @@ LOGGING = {
'propagate'
:
False
,
'propagate'
:
False
,
}
}
},
},
}
}
\ No newline at end of file
notesserver/settings/yaml_config.py
View file @
20c52ce0
import
yaml
import
yaml
import
annotator
from
annotator
import
es
from
.common
import
*
# pylint: disable=unused-wildcard-import, wildcard-import
from
.common
import
*
# pylint: disable=unused-wildcard-import, wildcard-import
...
@@ -18,11 +16,3 @@ with open(CONFIG_ROOT / "edx-notes-api.yml") as yaml_file:
...
@@ -18,11 +16,3 @@ with open(CONFIG_ROOT / "edx-notes-api.yml") as yaml_file:
config_from_yaml
=
yaml
.
load
(
yaml_file
)
config_from_yaml
=
yaml
.
load
(
yaml_file
)
vars
()
.
update
(
config_from_yaml
)
vars
()
.
update
(
config_from_yaml
)
###############################################################################
# Override default annotator-store elasticsearch settings.
###############################################################################
es
.
host
=
ELASTICSEARCH_URL
es
.
index
=
ELASTICSEARCH_INDEX
annotator
.
elasticsearch
.
RESULTS_MAX_SIZE
=
RESULTS_MAX_SIZE
###############################################################################
notesserver/test_views.py
View file @
20c52ce0
...
@@ -17,12 +17,12 @@ class OperationalEndpointsTest(APITestCase):
...
@@ -17,12 +17,12 @@ class OperationalEndpointsTest(APITestCase):
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
data
,
{
"OK"
:
True
})
self
.
assertEquals
(
response
.
data
,
{
"OK"
:
True
})
@patch
(
'
annotator.elasticsearch.ElasticSearch.conn
'
)
@patch
(
'
notesserver.views.get_es
'
)
def
test_heartbeat_failure
(
self
,
mocked_
conn
):
def
test_heartbeat_failure
(
self
,
mocked_
get_es
):
"""
"""
Elasticsearch is not reachable.
Elasticsearch is not reachable.
"""
"""
mocked_
conn
.
ping
.
return_value
=
False
mocked_
get_es
.
return_value
.
ping
.
return_value
=
False
response
=
self
.
client
.
get
(
reverse
(
'heartbeat'
))
response
=
self
.
client
.
get
(
reverse
(
'heartbeat'
))
self
.
assertEquals
(
response
.
status_code
,
500
)
self
.
assertEquals
(
response
.
status_code
,
500
)
self
.
assertEquals
(
response
.
data
,
{
"OK"
:
False
,
"check"
:
"es"
})
self
.
assertEquals
(
response
.
data
,
{
"OK"
:
False
,
"check"
:
"es"
})
...
@@ -54,13 +54,13 @@ class OperationalAuthEndpointsTest(APITestCase):
...
@@ -54,13 +54,13 @@ class OperationalAuthEndpointsTest(APITestCase):
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
status_code
,
200
)
@patch
(
'notesserver.views.datetime'
,
datetime
=
Mock
(
wraps
=
datetime
.
datetime
))
@patch
(
'notesserver.views.datetime'
,
datetime
=
Mock
(
wraps
=
datetime
.
datetime
))
@patch
(
'
annotator.elasticsearch.ElasticSearch.conn
'
)
@patch
(
'
notesserver.views.get_es
'
)
def
test_selftest_data
(
self
,
mocked_
conn
,
mocked_datetime
):
def
test_selftest_data
(
self
,
mocked_
get_es
,
mocked_datetime
):
"""
"""
Test returned data on success.
Test returned data on success.
"""
"""
mocked_datetime
.
datetime
.
now
.
return_value
=
datetime
.
datetime
(
2014
,
12
,
11
)
mocked_datetime
.
datetime
.
now
.
return_value
=
datetime
.
datetime
(
2014
,
12
,
11
)
mocked_
conn
.
info
.
return_value
=
{}
mocked_
get_es
.
return_value
.
info
.
return_value
=
{}
response
=
self
.
client
.
get
(
reverse
(
'selftest'
))
response
=
self
.
client
.
get
(
reverse
(
'selftest'
))
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
self
.
assertEquals
(
...
@@ -71,11 +71,11 @@ class OperationalAuthEndpointsTest(APITestCase):
...
@@ -71,11 +71,11 @@ class OperationalAuthEndpointsTest(APITestCase):
}
}
)
)
@patch
(
'
annotator.elasticsearch.ElasticSearch.conn
'
)
@patch
(
'
notesserver.views.get_es
'
)
def
test_selftest_failure
(
self
,
mocked_
conn
):
def
test_selftest_failure
(
self
,
mocked_
get_es
):
"""
"""
Elasticsearch is not reachable on selftest.
Elasticsearch is not reachable on selftest.
"""
"""
mocked_
conn
.
info
.
side_effect
=
TransportError
()
mocked_
get_es
.
return_value
.
info
.
side_effect
=
TransportError
()
response
=
self
.
client
.
get
(
reverse
(
'selftest'
))
response
=
self
.
client
.
get
(
reverse
(
'selftest'
))
self
.
assertEquals
(
response
.
status_code
,
500
)
self
.
assertEquals
(
response
.
status_code
,
500
)
notesserver/views.py
View file @
20c52ce0
...
@@ -7,7 +7,7 @@ from rest_framework.views import APIView
...
@@ -7,7 +7,7 @@ from rest_framework.views import APIView
from
rest_framework.decorators
import
api_view
,
permission_classes
,
authentication_classes
from
rest_framework.decorators
import
api_view
,
permission_classes
,
authentication_classes
from
elasticsearch.exceptions
import
TransportError
from
elasticsearch.exceptions
import
TransportError
from
annotator
import
es
from
elasticutils
import
get_
es
@api_view
([
'GET'
])
@api_view
([
'GET'
])
...
@@ -28,7 +28,7 @@ def heartbeat(request): # pylint: disable=unused-argument
...
@@ -28,7 +28,7 @@ def heartbeat(request): # pylint: disable=unused-argument
"""
"""
ElasticSearch is reachable and ready to handle requests.
ElasticSearch is reachable and ready to handle requests.
"""
"""
if
es
.
conn
.
ping
():
if
get_es
()
.
ping
():
return
Response
({
"OK"
:
True
})
return
Response
({
"OK"
:
True
})
else
:
else
:
return
Response
({
"OK"
:
False
,
"check"
:
"es"
},
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
return
Response
({
"OK"
:
False
,
"check"
:
"es"
},
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
...
@@ -42,7 +42,7 @@ def selftest(request): # pylint: disable=unused-argument
...
@@ -42,7 +42,7 @@ def selftest(request): # pylint: disable=unused-argument
"""
"""
start
=
datetime
.
datetime
.
now
()
start
=
datetime
.
datetime
.
now
()
try
:
try
:
es_status
=
es
.
conn
.
info
()
es_status
=
get_es
()
.
info
()
except
TransportError
:
except
TransportError
:
return
Response
(
return
Response
(
{
"es_error"
:
traceback
.
format_exc
()},
{
"es_error"
:
traceback
.
format_exc
()},
...
...
requirements/base.txt
View file @
20c52ce0
...
@@ -4,8 +4,5 @@ djangorestframework==2.4.4
...
@@ -4,8 +4,5 @@ djangorestframework==2.4.4
django-rest-swagger==0.2.0
django-rest-swagger==0.2.0
elasticutils==0.10
elasticutils==0.10
elasticsearch==1.2.0
elasticsearch==1.2.0
annotator==0.12.0
django-cors-headers==0.13
django-cors-headers==0.13
PyJWT==0.3.0
PyJWT==0.3.0
git+https://github.com/edx/opaque-keys.git@0.1.2#egg=opaque-keys
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