def output(self): """ Use a test target with an own marker_index. """ target = ElasticsearchTarget( host=self.host, port=self.port, http_auth=self.http_auth, index=self.index, doc_type=self.doc_type, update_id=self.update_id(), marker_index_hist_size=self.marker_index_hist_size) target.marker_index = MARKER_INDEX target.marker_doc_type = MARKER_DOC_TYPE return target
def output(self): """ Use a test target with an own marker_index. """ target = ElasticsearchTarget( host=self.host, port=self.port, index=self.index, doc_type=self.doc_type, update_id=self.update_id(), marker_index_hist_size=self.marker_index_hist_size ) target.marker_index = MARKER_INDEX target.marker_doc_type = MARKER_DOC_TYPE return target
def test_touch_and_exists(self): """ Basic test. """ target = ElasticsearchTarget(HOST, PORT, INDEX, DOC_TYPE, 'update_id', http_auth=HTTP_AUTH) target.marker_index = MARKER_INDEX target.marker_doc_type = MARKER_DOC_TYPE delete() self.assertFalse(target.exists(), 'Target should not exist before touching it') target.touch() self.assertTrue(target.exists(), 'Target should exist after touching it') delete()
HTTP_AUTH = os.getenv('ESINDEX_TEST_HTTP_AUTH', None) INDEX = 'esindex_luigi_test' DOC_TYPE = 'esindex_test_type' MARKER_INDEX = 'esindex_luigi_test_index_updates' MARKER_DOC_TYPE = 'esindex_test_entry' def _create_test_index(): """ Create content index, if if does not exists. """ es = elasticsearch.Elasticsearch(connection_class=Urllib3HttpConnection, host=HOST, port=PORT, http_auth=HTTP_AUTH) if not es.indices.exists(INDEX): es.indices.create(INDEX) _create_test_index() target = ElasticsearchTarget(HOST, PORT, INDEX, DOC_TYPE, 'update_id', http_auth=HTTP_AUTH) target.marker_index = MARKER_INDEX target.marker_doc_type = MARKER_DOC_TYPE class ElasticsearchTargetTest(unittest.TestCase): """ Test touch and exists. """ def test_touch_and_exists(self): """ Basic test. """ delete() self.assertFalse(target.exists(), 'Target should not exist before touching it') target.touch() self.assertTrue(target.exists(),
def _create_test_index(): """ Create content index, if if does not exists. """ es = elasticsearch.Elasticsearch(connection_class=Urllib3HttpConnection, host=HOST, port=PORT, http_auth=HTTP_AUTH) if not es.indices.exists(INDEX): es.indices.create(INDEX) _create_test_index() target = ElasticsearchTarget(HOST, PORT, INDEX, DOC_TYPE, 'update_id', http_auth=HTTP_AUTH) target.marker_index = MARKER_INDEX target.marker_doc_type = MARKER_DOC_TYPE class ElasticsearchTargetTest(unittest.TestCase): """ Test touch and exists. """ def test_touch_and_exists(self): """ Basic test. """ delete() self.assertFalse(target.exists(), 'Target should not exist before touching it') target.touch() self.assertTrue(target.exists(),