def test_default_values_are_set(self): es = Elasticsearch() app = Flask("MyApp") es.init_app(app) self.assertEqual(app.config["ELASTICSEARCH_CONNECTION"], "http://127.0.0.1:9200") self.assertEqual(app.config["ELASTICSEARCH_USERNAME"], "") self.assertEqual(app.config["ELASTICSEARCH_PASSWORD"], "") self.assertFalse(app.config["ELASTICSEARCH_USE_SSL"])
def test_default_values_are_set(self): es = Elasticsearch() app = Flask('MyApp') es.init_app(app) self.assertEqual(app.config['ELASTICSEARCH_CONNECTION'], 'http://127.0.0.1:9200') self.assertEqual(app.config['ELASTICSEARCH_USERNAME'], '') self.assertEqual(app.config['ELASTICSEARCH_PASSWORD'], '') self.assertFalse(app.config['ELASTICSEARCH_USE_SSL'])
def test_configuration_overrides_defaults(self): host_str = 'http://srv1.example.com:9200,http://srv2.example.com:9200' username = '******' password = '******' es = Elasticsearch() app = Flask('MyApp') app.config.from_pyfile('sample.cfg') es.init_app(app) self.assertEqual(app.config['ELASTICSEARCH_CONNECTION'], host_str) self.assertEqual(app.config['ELASTICSEARCH_USERNAME'], username) self.assertEqual(app.config['ELASTICSEARCH_PASSWORD'], password) self.assertTrue(app.config['ELASTICSEARCH_USE_SSL'])
def test_configuration_overrides_defaults(self): host_str = "http://srv1.example.com:9200,http://srv2.example.com:9200" username = "******" password = "******" es = Elasticsearch() app = Flask("MyApp") app.config.from_pyfile("sample.cfg") es.init_app(app) self.assertEqual(app.config["ELASTICSEARCH_CONNECTION"], host_str) self.assertEqual(app.config["ELASTICSEARCH_USERNAME"], username) self.assertEqual(app.config["ELASTICSEARCH_PASSWORD"], password) self.assertTrue(app.config["ELASTICSEARCH_USE_SSL"])
from models import Billing, db from utility import get_compute_costs, get_storage_costs, create_analysis_costs_json, create_storage_costs_json import datetime import calendar import click # TEST database call # from sqlalchemy import create_engine, MetaData, String, Table, Float, Column, select import logging from database import db, login_db, login_manager, User billingbp = Blueprint('billingbp', 'billingbp') logging.basicConfig() es_service = os.environ.get("ES_SERVICE", "localhost") es = Elasticsearch(['http://' + es_service + ':9200/']) @login_manager.user_loader def load_user(user_id): return User.query.get(int(user_id)) @billingbp.route('/login') def login(): if current_user.is_authenticated: redirect('https://{}'.format(os.getenv('DCC_DASHBOARD_HOST'))) else: redirect('https://{}/login'.format(os.getenv('DCC_DASHBOARD_HOST'))) @billingbp.route('/invoices') @login_required @cross_origin()
from flask import Flask, jsonify #import the FlaskElasticsearch package from flask.ext.elasticsearch import Elasticsearch #import json app = Flask(__name__) es = Elasticsearch() #Assumption: objectId is download_id #Parses the elasticSearch response and makes it as similar as possible to the ICGC Data #Portal. String "DUMMY" is used when no data for that field is available. def parse_ES_response(es_dict): #print es_dict protoDict = {'hits': []} for hit in es_dict['hits']['hits']: protoDict['hits'].append({ 'id': 'DUMMY', 'objectID': 'DUMMY', 'access': 'DUMMY', 'study': ['DUMMY'], 'dataCategorization': { 'dataType': hit['_source']['analysis_type'], 'experimentalStrategy': 'DUMMY' }, 'fileCopies': [{ 'repoDataBundleId': 'DUMMY', 'repoDataSetIds': [],
def test_extension_supports_factory_pattern(self): es = Elasticsearch() self.assertTrue(es is not None)