Commit 0f680628 by Oleg Marshev

Remove annotator-store.

parent d3c1929d
from django.core.management.base import BaseCommand
from annotator.annotation import Annotation
class Command(BaseCommand):
help = 'Creates the mapping in the index.'
def handle(self, *args, **options):
Annotation.create_all()
#TODO: cretate mapping using elasticutils
pass
......@@ -354,7 +354,7 @@ class AnnotationViewTests(BaseAnnotationViewTests):
@patch('django.conf.settings.DISABLE_TOKEN_CHECK', True)
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):
......
......@@ -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_SECRET = 'edx-notes-secret'
ELASTICSEARCH_URL = 'http://127.0.0.1:9200'
ELASTICSEARCH_INDEX = 'edx-notes'
ES_URLS = ['http://localhost:9200']
ES_INDEXES = {'default': 'notes_index'}
ES_DISABLED = False
......@@ -92,11 +89,6 @@ LOGGING = {
'level': 'WARNING',
'propagate': True
},
'annotator.elasticsearch': {
'handlers': ['console'],
'level': 'WARNING',
'propagate': True
},
'urllib3': {
'handlers': ['console'],
'level': 'DEBUG',
......
import annotator
from annotator import es
from .common import *
DEBUG = True
ELASTICSEARCH_INDEX = 'edx-notes-dev'
ES_INDEXES = {'default': 'notes_index_dev'}
DATABASES = {
'default': {
......@@ -12,11 +10,3 @@ DATABASES = {
'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
###############################################################################
from annotator import es
import annotator
from .common import *
DATABASES = {
......@@ -12,18 +10,8 @@ TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
DISABLE_TOKEN_CHECK = False
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'}
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
......@@ -52,4 +40,4 @@ LOGGING = {
'propagate': False,
}
},
}
\ No newline at end of file
}
import yaml
import annotator
from annotator import es
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:
config_from_yaml = yaml.load(yaml_file)
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
###############################################################################
......@@ -17,12 +17,12 @@ class OperationalEndpointsTest(APITestCase):
self.assertEquals(response.status_code, 200)
self.assertEquals(response.data, {"OK": True})
@patch('annotator.elasticsearch.ElasticSearch.conn')
def test_heartbeat_failure(self, mocked_conn):
@patch('notesserver.views.get_es')
def test_heartbeat_failure(self, mocked_get_es):
"""
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'))
self.assertEquals(response.status_code, 500)
self.assertEquals(response.data, {"OK": False, "check": "es"})
......@@ -54,13 +54,13 @@ class OperationalAuthEndpointsTest(APITestCase):
self.assertEquals(response.status_code, 200)
@patch('notesserver.views.datetime', datetime=Mock(wraps=datetime.datetime))
@patch('annotator.elasticsearch.ElasticSearch.conn')
def test_selftest_data(self, mocked_conn, mocked_datetime):
@patch('notesserver.views.get_es')
def test_selftest_data(self, mocked_get_es, mocked_datetime):
"""
Test returned data on success.
"""
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'))
self.assertEquals(response.status_code, 200)
self.assertEquals(
......@@ -71,11 +71,11 @@ class OperationalAuthEndpointsTest(APITestCase):
}
)
@patch('annotator.elasticsearch.ElasticSearch.conn')
def test_selftest_failure(self, mocked_conn):
@patch('notesserver.views.get_es')
def test_selftest_failure(self, mocked_get_es):
"""
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'))
self.assertEquals(response.status_code, 500)
......@@ -7,7 +7,7 @@ from rest_framework.views import APIView
from rest_framework.decorators import api_view, permission_classes, authentication_classes
from elasticsearch.exceptions import TransportError
from annotator import es
from elasticutils import get_es
@api_view(['GET'])
......@@ -28,7 +28,7 @@ def heartbeat(request): # pylint: disable=unused-argument
"""
ElasticSearch is reachable and ready to handle requests.
"""
if es.conn.ping():
if get_es().ping():
return Response({"OK": True})
else:
return Response({"OK": False, "check": "es"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
......@@ -42,7 +42,7 @@ def selftest(request): # pylint: disable=unused-argument
"""
start = datetime.datetime.now()
try:
es_status = es.conn.info()
es_status = get_es().info()
except TransportError:
return Response(
{"es_error": traceback.format_exc()},
......
......@@ -4,8 +4,5 @@ djangorestframework==2.4.4
django-rest-swagger==0.2.0
elasticutils==0.10
elasticsearch==1.2.0
annotator==0.12.0
django-cors-headers==0.13
PyJWT==0.3.0
git+https://github.com/edx/opaque-keys.git@0.1.2#egg=opaque-keys
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment