def load_validator_schema(): """Load file-level .csv schemas into the broker database.""" logger.info('Loading validator schemas') SchemaLoader.load_all_from_path(validator_config_path)
def load_validator_schema(): """Load file-level .csv schemas into the broker database.""" logger.info('Loading validator schemas') SchemaLoader.load_all_from_path(validator_config_path)
def setUpClass(cls): """Set up resources to be shared within a test class""" # TODO: refactor into a pytest class fixtures and inject as necessary # update application's db config options so unittests # run against test databases configure_logging() suite = cls.__name__.lower() config = dataactcore.config.CONFIG_DB cls.num = randint(1, 9999) config['db_name'] = 'unittest{}_{}_data_broker'.format(cls.num, suite) dataactcore.config.CONFIG_DB = config create_database(CONFIG_DB['db_name']) run_migrations() app = create_app() app.config['TESTING'] = True app.config['DEBUG'] = False cls.app = TestApp(app) sess = GlobalDB.db().session # set up default e-mails for tests test_users = { 'admin_user': '******', 'agency_user': '******', 'agency_user_2': '*****@*****.**', 'no_permissions_user': '******', 'editfabs_user': '******' } admin_password = '******' cgac = CGAC(cgac_code='000', agency_name='Example Agency') sess.add(cgac) sess.commit() # Allow us to augment default test failure msg w/ more detail cls.longMessage = True # Upload files to S3 (False = skip re-uploading on subsequent runs) cls.uploadFiles = True # Run tests for local broker or not cls.local = CONFIG_BROKER['local'] # This needs to be set to the local directory for error reports if local is True cls.local_file_directory = CONFIG_SERVICES['error_report_path'] # drop and re-create test job db/tables setup_job_tracker_db() # drop and re-create test error db/tables setup_error_db() # drop and re-create test validation db setup_validation_db() # setup Schema SchemaLoader.load_all_from_path(validator_config_path) load_sql_rules() create_user_with_password(test_users["admin_user"], admin_password, Bcrypt(), website_admin=True) cls.userId = None cls.test_users = test_users # constants to use for default submission start and end dates cls.SUBMISSION_START_DEFAULT = datetime(2015, 10, 1) cls.SUBMISSION_END_DEFAULT = datetime(2015, 10, 31)