def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() self.client = self.app.test_client() self.basedir = os.path.abspath(os.path.dirname(__file__)) db.create_all() test_password = '******' Organization.insert_org() UserScope.insert_scopes() User.insert_user(password=test_password) self.client = self.app.test_client(use_cookies=False) # set the vars for the connection self.cmisUrl = \ 'https://alfresco.oceanobservatories.org/alfresco/s/api/cmis' self.cmisUsername = '******' self.cmisPassword = '******' self.cmisId = 'c161bc66-4f7e-4a4f-b5f2-aac9fbf1d3cd' # cmis is tested elsewhere from cmislib.model import CmisClient client = CmisClient(self.cmisUrl, self.cmisUsername, self.cmisPassword) repo = client.getRepository(self.cmisId)
def setUpClass(cls): # start Firefox try: cls.client = webdriver.Firefox() except: pass # skip these tests if the browser could not be started if cls.client: # create the application cls.app = create_app('TESTING_CONFIG') cls.app_context = cls.app.app_context() cls.app_context.push() # suppress logging to keep unittest output clean import logging logger = logging.getLogger('werkzeug') logger.setLevel("ERROR") # create the database and populate with some fake data db.create_all() test_password = '******' User.insert_user(password=test_password) UserRole.insert_roles() # start the Flask server in a thread threading.Thread(target=cls.app.run).start()
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() from sqlalchemy.orm.mapper import configure_mappers configure_mappers() db.create_all() test_username = '******' test_password = '******' Organization.insert_org() User.insert_user(username=test_username, password=test_password, email='*****@*****.**') OperatorEventType.insert_operator_event_types() self.client = self.app.test_client(use_cookies=False) UserScope.insert_scopes() admin = User.query.filter_by(user_name='admin').first() scope = UserScope.query.filter_by(scope_name='user_admin').first() admin.scopes.append(scope) db.session.add(admin) db.session.commit() joe = User.insert_user(username='******', password='******', email='*****@*****.**') bob = User.insert_user(username='******', password='******', email='*****@*****.**')
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() db.create_all() self.client = self.app.test_client(use_cookies=False) Organization.insert_org()
def setUpClass(cls): # start Firefox try: cls.client = webdriver.Firefox() except: pass # skip these tests if the browser could not be started if cls.client: # create the application cls.app = create_app('TESTING_CONIG') cls.app_context = cls.app.app_context() cls.app_context.push() # suppress logging to keep unittest output clean import logging logger = logging.getLogger('werkzeug') logger.setLevel("ERROR") # create the database and populate with some fake data db.create_all() test_password = '******' User.insert_user(password=test_password) UserRole.insert_roles() # start the Flask server in a thread threading.Thread(target=cls.app.run).start()
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() from sqlalchemy.orm.mapper import configure_mappers configure_mappers() db.create_all() test_username = '******' test_password = '******' Organization.insert_org() User.insert_user(username=test_username, password=test_password, email='*****@*****.**') OperatorEventType.insert_operator_event_types() self.client = self.app.test_client(use_cookies=False) UserScope.insert_scopes() admin = User.query.filter_by(user_name='admin').first() scope = UserScope.query.filter_by(scope_name='asset_manager').first() admin.scopes.append(scope) db.session.add(admin) db.session.commit() joe = User.insert_user(username='******', password='******', email='*****@*****.**') bob = User.insert_user(username='******', password='******', email='*****@*****.**')
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() db.create_all() self.client = self.app.test_client(use_cookies=False) User.insert_user(username=test_username, password=test_password) UserScope.insert_scopes()
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() db.create_all() self.client = self.app.test_client(use_cookies=False) Organization.insert_org() User.insert_user(username=test_username, password=test_password) UserScope.insert_scopes()
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() db.create_all() test_password = '******' User.insert_user(password=test_password) self.client = self.app.test_client(use_cookies=False)
def setUp(self): self.app = create_app("TESTING_CONFIG") self.app_context = self.app.app_context() self.app_context.push() db.create_all() test_password = "******" Organization.insert_org() User.insert_user(password=test_password, email="test@localhost") self.client = self.app.test_client(use_cookies=False)
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() self.client = self.app.test_client(use_cookies=False) # Set up the test case ref_des and date self.ref_des = 'RS03ASHS-MJ03B-05-OBSSPA302' self.year = '2015' self.month = '11' self.day = '30' self.date_str = '-'.join([self.year, self.month, self.day])
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() self.client = self.app.test_client() self.basedir = os.path.abspath(os.path.dirname(__file__)) # set the vars for the connection self.cmisUrl = \ 'https://alfresco.oceanobservatories.org/alfresco/s/api/cmis' self.cmisUsername = '******' self.cmisPassword = '******' self.cmisId = 'c161bc66-4f7e-4a4f-b5f2-aac9fbf1d3cd'
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() self.client = self.app.test_client(use_cookies=False) self.basedir = os.path.abspath(os.path.dirname(__file__)) with open(self.basedir + '/mock_data/asset.json', 'r') as f: doc = json.load(f) self.asset_json = doc with open(self.basedir + '/mock_data/event.json', 'r') as f: doc = json.load(f) self.event_json = doc
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() db.create_all() self.client = self.app.test_client(use_cookies=False) self.root = 'http://localhost:4000' test_username = '******' test_password = '******' self.content_type = 'application/json' self.headers = self.get_api_headers('admin', 'test')
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() db.create_all() test_username = '******' test_password = '******' Organization.insert_org() User.insert_user(username=test_username, password=test_password) self.client = self.app.test_client(use_cookies=False) UserScope.insert_scopes() admin = User.query.filter_by(user_name='admin').first() scope = UserScope.query.filter_by(scope_name='user_admin').first() admin.scopes.append(scope) db.session.add(admin) db.session.commit()
def badSetUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() self.client = self.app.test_client() self.basedir = os.path.abspath(os.path.dirname(__file__)) # set the vars for the connection self.cmisUrl = 'http://localhost/alfresco/badsetup' self.cmisUsername = '******' self.cmisPassword = '******' self.cmisId = 'not-correct-code' # cmis is tested elsewhere from cmislib.model import CmisClient client = CmisClient(self.cmisUrl, self.cmisUsername, self.cmisPassword) repo = client.getRepository(self.cmisId)
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() db.create_all() test_password = '******' Organization.insert_org() UserScope.insert_scopes() User.insert_user(password=test_password) self.client = self.app.test_client(use_cookies=False) self.basedir = os.path.abspath(os.path.dirname(__file__)) with open(self.basedir + '/mock_data/event_post.json', 'r') as f: doc = json.load(f) self.event_json_in = doc with open(self.basedir + '/mock_results/event_from.json', 'r') as f: doc = json.load(f) self.event_from_json = doc
def setUp(self): self.app = create_app("TESTING_CONFIG") self.app_context = self.app.app_context() self.app_context.push() db.create_all() test_username = "******" test_password = "******" Organization.insert_org() User.insert_user(username=test_username, password=test_password) self.client = self.app.test_client(use_cookies=False) UserScope.insert_scopes() admin = User.query.filter_by(user_name="admin").first() scope = UserScope.query.filter_by(scope_name="user_admin").first() cc_scope = UserScope.query.filter_by(scope_name="command_control").first() admin.scopes.append(scope) admin.scopes.append(cc_scope) db.session.add(admin) db.session.commit() self.headers = self.get_api_headers("admin", "test")
Specific testing of routes. ''' __author__ = 'Edna Donoughe' import unittest import json from base64 import b64encode from flask import url_for from ooiservices.app import create_app, db from ooiservices.app.models import PlatformDeployment, InstrumentDeployment, Stream, StreamParameter, VocabNames from ooiservices.app.models import Organization, User, UserScope import flask.ext.whooshalchemy as whooshalchemy import datetime as dt app = create_app('TESTING_CONFIG') app.config['WHOOSH_BASE'] = 'ooiservices/whoosh_index' whooshalchemy.whoosh_index(app, PlatformDeployment) ''' These tests are additional to the normal testing performed by coverage; each of these tests are to validate model logic outside of db management. ''' class UserTestCase(unittest.TestCase): def setUp(self): self.app = app self.app_context = self.app.app_context() self.app_context.push() db.create_all() test_username = '******' test_password = '******'
from flask.ext.script import Manager, Shell, Server, prompt_bool from flask.ext.migrate import Migrate, MigrateCommand import flask.ext.whooshalchemy as whooshalchemy from ooiservices.app.models import PlatformDeployment, User, UserScope, UserScopeLink from datetime import datetime import yaml if os.path.exists(os.path.join(basedir, '/app/config_local.yml')): with open(basedir + '/app/config_local.yml', 'r') as f: doc = yaml.load(f) else: with open(basedir + '/app/config.yml', 'r') as f: doc = yaml.load(f) env = doc['ENV_NAME'] app = create_app(env) manager = Manager(app) migrate = Migrate(app,db) app.config['WHOOSH_BASE'] = 'ooiservices/whoosh_index' whooshalchemy.whoosh_index(app, PlatformDeployment) ##------------------------------------------------------------------ ## M@Campbell 02/10/2015 ## ## Helper function to build index of models that are loaded manually (from .sql file) # # Usage: # From shell: # > from ooiservices.manage import rebuild_index # > rebuild_index(model_name) ##------------------------------------------------------------------
def setUp(self): self.app = create_app('TESTING_CONFIG') self.app_context = self.app.app_context() self.app_context.push() db.create_all()
COV = None if os.environ.get('FLASK_COVERAGE'): import coverage COV = coverage.coverage(branch=True, include=basedir + '/ooiservices/app/*') COV.start() from ooiservices.app import create_app, db from flask.ext.script import Manager, Shell, Server, prompt_bool from flask.ext.migrate import Migrate, MigrateCommand import flask.ext.whooshalchemy as whooshalchemy from ooiservices.app.models import PlatformDeployment, User, UserScope, UserScopeLink from datetime import datetime import yaml if os.path.exists(os.path.join(basedir, '/ooiservices/app/config_local.yml')): with open(basedir + '/ooiservices/app/config_local.yml', 'r') as f: doc = yaml.load(f) else: with open(basedir + '/ooiservices/app/config.yml', 'r') as f: doc = yaml.load(f) env = doc['ENV_NAME'] app = create_app(env) manager = Manager(app) migrate = Migrate(app, db) app.config['WHOOSH_BASE'] = 'ooiservices/whoosh_index' whooshalchemy.whoosh_index(app, PlatformDeployment) if __name__ == '__main__': app.run(host='localhost:4001', debug=True)
Specific testing of routes. ''' __author__ = 'Edna Donoughe' import unittest import json from base64 import b64encode from flask import url_for from ooiservices.app import create_app, db from ooiservices.app.models import PlatformDeployment, InstrumentDeployment, Stream, StreamParameter from ooiservices.app.models import Organization, User, UserScope import flask.ext.whooshalchemy as whooshalchemy import datetime as dt app = create_app('TESTING_CONFIG') app.config['WHOOSH_BASE'] = 'ooiservices/whoosh_index' whooshalchemy.whoosh_index(app, PlatformDeployment) ''' These tests are additional to the normal testing performed by coverage; each of these tests are to validate model logic outside of db management. ''' class UserTestCase(unittest.TestCase): def setUp(self): self.app = app self.app_context = self.app.app_context() self.app_context.push() db.create_all() test_username = '******' test_password = '******'
import os basedir = os.path.abspath(os.path.dirname(__file__)) COV = None if os.environ.get('FLASK_COVERAGE'): import coverage COV = coverage.coverage(branch=True,include=basedir + '/app/*') COV.start() from ooiservices.app import create_app, db from flask.ext.script import Manager, Shell, Server, prompt_bool from flask.ext.migrate import Migrate, MigrateCommand import flask.ext.whooshalchemy as whooshalchemy from ooiservices.app.models import PlatformDeployment, User, UserScope from datetime import datetime app = create_app('LOCAL_DEVELOPMENT') manager = Manager(app) migrate = Migrate(app,db) app.config['WHOOSH_BASE'] = 'ooiservices/whoosh_index' whooshalchemy.whoosh_index(app, PlatformDeployment) ##------------------------------------------------------------------ ## M@Campbell 02/10/2015 ## ## Helper function to build index of models that are loaded manually (from .sql file) # # Usage: # From shell: # > from ooiservices.manage import rebuild_index # > rebuild_index(model_name) ##------------------------------------------------------------------