def setUp(self): self.app = load_test_app( os.path.join(os.path.dirname(__file__), 'config.py')) engine = connection.get_engine() # try to clear test tables first before create all tables default_model.Base.metadata.drop_all(engine) default_model.Base.metadata.create_all(engine)
def setUp(self): import deuce deuce.context = DummyContextObject deuce.context.project_id = self.create_project_id() global conf_dict self.app = load_test_app(config=conf_dict)
def setUp(self): self.app = load_test_app(os.path.join( os.path.dirname(__file__), 'config.py' )) self._storagedir = pecan.conf.block_storage_driver.options.path
def setUp(self): super(PlansTests, self).setUp() config_file = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", "api", "config.py" ) self.app = load_test_app(config_file)
def setUp(self): super(TestCase, self).setUp() self.useFixture(conf_fixture.ConfReloadFixture()) self.policy = self.useFixture(policy_fixture.PolicyFixture()) self.messaging_conf = self.useFixture(conffixture.ConfFixture(CONF)) self.messaging_conf.transport_driver = 'fake' cfg.CONF.set_override("auth_type", "admin_token", group='keystone_authtoken', enforce_type=True) cfg.CONF.set_override("auth_uri", "http://127.0.0.1/identity", group='keystone_authtoken', enforce_type=True) app_config_path = os.path.join(os.path.dirname(__file__), 'config.py') self.app = testing.load_test_app(app_config_path) self.token_info = { 'token': { 'project': { 'id': 'fake_project' }, 'user': { 'id': 'fake_user' } } } self.context = watcher_context.RequestContext( auth_token_info=self.token_info, project_id='fake_project', user_id='fake_user') self.policy = self.useFixture(policy_fixture.PolicyFixture()) def make_context(*args, **kwargs): # If context hasn't been constructed with token_info if not kwargs.get('auth_token_info'): kwargs['auth_token_info'] = copy.deepcopy(self.token_info) if not kwargs.get('project_id'): kwargs['project_id'] = 'fake_project' if not kwargs.get('user_id'): kwargs['user_id'] = 'fake_user' context = watcher_context.RequestContext(*args, **kwargs) return watcher_context.RequestContext.from_dict(context.to_dict()) p = mock.patch.object(watcher_context, 'make_context', side_effect=make_context) self.mock_make_context = p.start() self.addCleanup(p.stop) self.useFixture(conf_fixture.ConfFixture(cfg.CONF)) self._reset_singletons() self._base_test_obj_backup = copy.copy( objects_base.WatcherObject._obj_classes) self.addCleanup(self._restore_obj_registry) self.addCleanup(self._reset_singletons)
def setUp(self): super(FunctionalTest, self).setUp() self.app = load_test_app(os.path.join( os.path.dirname(__file__), 'config.py' )) self.public_regex = re.compile("^ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( ([^@]+@[^@]+))?$") self.private_regex = re.compile( "^-----BEGIN RSA PRIVATE KEY-----.*-----END RSA PRIVATE KEY-----$", re.DOTALL ) self.default_post = { 'hostname': 'localhost-test', 'check-chatops': '1', 'hubot-password': '******', 'admin-username': '******', 'password-1': 'adminpass1', 'password-2': 'adminpass1', 'username': '******', 'anon-data': '1', 'chatops': 'slack', 'selfsigned': '1', 'sshgen': '1', 'slack-token': 'slackapi' } ssh_keys = self.keypair_controller.keygen() self.default_post['gen-public'] = ssh_keys['public'] self.default_post['gen-private'] = ssh_keys['private']
def setUp(self): super(BaseRESTTestCase, self).setUp() self.permissions = ['is_admin'] os.environ['CR_CONFIG'] = os.path.join( os.path.dirname(__file__), '../../api', 'cr_test.conf' ) self.app = load_test_app(os.path.join( os.path.dirname(__file__), '../../api', 'config_test.py' )) self.cache = self.modules['cloudrunner_server.util.cache'] self.aero = self.cache.CacheRegistry() self.aero_reader = self.aero.reader().__enter__() self.modules = modules # assert correct database self.assertIsNone(p_conf.sqlalchemy.engine.url.database) self.assertEquals(p_conf.sqlalchemy.engine.url.drivername, "sqlite") self._user_id = 1 get_token = self._get_token self.aero_reader.get_user_token = get_token self.populate()
def setUpClass(cls): super(FunctionalTest, cls).setUpClass() tests_config.parse_args() # Make sure auth is disabled cfg.CONF.set_default('enable', False, group='auth') # Make sure RBAC is disabled cfg.CONF.set_override(name='enable', override=False, group='rbac') opts = cfg.CONF.api_pecan cfg_dict = { 'app': { 'root': opts.root, 'template_path': opts.template_path, 'modules': opts.modules, 'debug': opts.debug, 'auth_enable': opts.auth_enable, 'errors': { '__force_dict__': True } } } # TODO(manas) : register action types here for now. RunnerType registration can be moved # to posting to /runnertypes but that implies implementing POST. runners_registrar.register_runner_types() cls.app = load_test_app(config=cfg_dict)
def _do_setUpClass(cls): tests_config.parse_args() cfg.CONF.set_default('enable', cls.enable_auth, group='auth') cfg.CONF.set_override(name='enable', override=False, group='rbac') opts = cfg.CONF.api_pecan cfg_dict = { 'app': { 'root': opts.root, 'template_path': opts.template_path, 'modules': opts.modules, 'debug': opts.debug, 'auth_enable': opts.auth_enable, 'errors': { '__force_dict__': True }, 'guess_content_type_from_ext': False } } # TODO(manas) : register action types here for now. RunnerType registration can be moved # to posting to /runnertypes but that implies implementing POST. runners_registrar.register_runners() cls.app = load_test_app(config=cfg_dict)
def setUp(self): super(FunctionalTest, self).setUp() self.test_data_dir = ''.join((os.path.abspath(os.getcwd()), '/', self.test_data_subdir)) self.maildir = TempDir() self.useFixture(self.maildir) self.fake_getmtime_val = 123456.7 self.useFixture(MonkeyPatch('os.path.getmtime', self.fake_getmtime)) config = { 'app': { 'root': 'mailase.api.controllers.root.RootController', 'modules': ['mailase.api'], }, 'mail': { 'maildirs': self.maildir.path }, 'search': { 'server_url': ['http://localhost:9200'], 'index': 'mailase_test' } } self.app = load_test_app(config) self.mailboxes = {} self.mua_subdirs = {}
def _do_setUpClass(cls): tests_config.parse_args() cfg.CONF.set_default('enable', cls.enable_auth, group='auth') cfg.CONF.set_override(name='enable', override=False, group='rbac') opts = cfg.CONF.api_pecan cfg_dict = { 'app': { 'root': opts.root, 'template_path': opts.template_path, 'modules': opts.modules, 'debug': opts.debug, 'auth_enable': opts.auth_enable, 'errors': {'__force_dict__': True}, 'guess_content_type_from_ext': False } } # TODO(manas) : register action types here for now. RunnerType registration can be moved # to posting to /runnertypes but that implies implementing POST. runners_registrar.register_runner_types() cls.app = load_test_app(config=cfg_dict)
def setUpClass(cls): super(FunctionalTest, cls).setUpClass() tests_config.parse_args() # Make sure auth is disabled cfg.CONF.set_default('enable', False, group='auth') # Make sure RBAC is disabled cfg.CONF.set_override(name='enable', override=False, group='rbac') opts = cfg.CONF.api_pecan cfg_dict = { 'app': { 'root': opts.root, 'template_path': opts.template_path, 'modules': opts.modules, 'debug': opts.debug, 'auth_enable': opts.auth_enable, 'errors': {'__force_dict__': True} } } # TODO(manas) : register action types here for now. RunnerType registration can be moved # to posting to /runnertypes but that implies implementing POST. runners_registrar.register_runner_types() cls.app = load_test_app(config=cfg_dict)
def setUp(self): super(TestCase, self).setUp() self.app = testing.load_test_app(os.path.join( os.path.dirname(__file__), 'config.py' )) self.useFixture(conf_fixture.ConfFixture(cfg.CONF))
def app(request): _config = configuration.conf_from_file(config_file()).to_dict() config = deepcopy(_config) configuration.set_config(config, overwrite=True) # Set up a fake app app = TestApp(load_test_app(config)) return app
def _make_app(self, enable_acl=False): self.config = { 'app': { 'root': 'tricircle.api.controllers.root.RootController', 'modules': ['tricircle.api'], 'enable_acl': enable_acl, }, } return load_test_app(self.config)
def _make_app(self, enable_acl=False): self.config = { "app": { "root": "tricircle.api.controllers.root.RootController", "modules": ["tricircle.api"], "enable_acl": enable_acl, "errors": {400: "/error", "__force_dict__": True}, } } return load_test_app(self.config)
def app(request): config = configuration.conf_from_file(config_file()).to_dict() # Add the appropriate connection string to the app config. config['sqlalchemy'] = { 'url': '%s/%s' % (BIND, DBNAME), 'encoding': 'utf-8', 'poolclass': NullPool } # Set up a fake app app = TestApp(load_test_app(config)) return app
def setUp(self): # Load config from json test config jsonloader.conf.load_str_data(TestFunctional.config) self.conf = getattr(jsonloader.conf, "_config") self.conf["ca"]["output_path"] = tempfile.mkdtemp() # Set CA file permissions os.chmod(self.conf["ca"]["cert_path"], stat.S_IRUSR | stat.S_IFREG) os.chmod(self.conf["ca"]["key_path"], stat.S_IRUSR | stat.S_IFREG) app_conf = {"app": copy.deepcopy(config.app), "logging": copy.deepcopy(config.logging)} self.app = pecan_testing.load_test_app(app_conf)
def _make_app(self, enable_acl=False): self.config = { 'app': { 'root': 'trio2o.nova_apigw.controllers.root.RootController', 'modules': ['trio2o.nova_apigw'], 'enable_acl': enable_acl, 'errors': { 400: '/error', '__force_dict__': True } }, } return load_test_app(self.config)
def _make_app(self, enable_acl=False): self.config = { 'app': { 'root': 'tricircle.api.controllers.root.RootController', 'modules': ['tricircle.api'], 'enable_acl': enable_acl, 'errors': { 400: '/error', '__force_dict__': True } }, } return load_test_app(self.config)
def setUp(self): # Load config from json test config jsonloader.conf.load_str_data(TestFunctional.config) self.conf = getattr(jsonloader.conf, "_config") self.conf["ca"]["output_path"] = tempfile.mkdtemp() # Set CA file permissions os.chmod(self.conf["ca"]["cert_path"], stat.S_IRUSR | stat.S_IFREG) os.chmod(self.conf["ca"]["key_path"], stat.S_IRUSR | stat.S_IFREG) app_conf = { "app": copy.deepcopy(config.app), "logging": copy.deepcopy(config.logging) } self.app = pecan_testing.load_test_app(app_conf)
def app(request): config = configuration.conf_from_file(config_file()).to_dict() # Add the appropriate connection string to the app config. config['sqlalchemy'] = { 'url': '%s/%s' % (BIND, DBNAME), 'echo': True, 'echo_pool': True, 'pool_recycle': 3600, 'encoding': 'utf-8' } # Set up a fake app app = TestApp(load_test_app(config)) return app
def setUp(self): super(TestFunctional, self).setUp() # Load config from json test config jsonloader.conf.load_str_data(json.dumps(self.sample_conf)) jsonloader.conf.load_extensions() self.conf = jsonloader.conf._config ca_conf = self.conf["signing_ca"]["default_ca"] ca_conf["output_path"] = tempfile.mkdtemp() # Set CA file permissions os.chmod(ca_conf["cert_path"], stat.S_IRUSR | stat.S_IFREG) os.chmod(ca_conf["key_path"], stat.S_IRUSR | stat.S_IFREG) app_conf = {"app": copy.deepcopy(config.app), "logging": copy.deepcopy(config.logging)} self.app = pecan_testing.load_test_app(app_conf)
def setUp(self): super(TestCase, self).setUp() self.useFixture(conf_fixture.ConfReloadFixture()) self.app = testing.load_test_app(os.path.join( os.path.dirname(__file__), 'config.py' )) token_info = { 'token': { 'project': { 'id': 'fake_project' }, 'user': { 'id': 'fake_user' } } } self.context = watcher_context.RequestContext( auth_token_info=token_info, project_id='fake_project', user_id='fake_user') self.policy = self.useFixture(policy_fixture.PolicyFixture()) def make_context(*args, **kwargs): # If context hasn't been constructed with token_info if not kwargs.get('auth_token_info'): kwargs['auth_token_info'] = copy.deepcopy(token_info) if not kwargs.get('project_id'): kwargs['project_id'] = 'fake_project' if not kwargs.get('user_id'): kwargs['user_id'] = 'fake_user' context = watcher_context.RequestContext(*args, **kwargs) return watcher_context.RequestContext.from_dict(context.to_dict()) p = mock.patch.object(watcher_context, 'make_context', side_effect=make_context) self.mock_make_context = p.start() self.addCleanup(p.stop) self.useFixture(conf_fixture.ConfFixture(cfg.CONF)) self._base_test_obj_backup = copy.copy( objects_base.WatcherObject._obj_classes) self.addCleanup(self._restore_obj_registry)
def setUp(self): super(TestFunctional, self).setUp() # Load config from json test config jsonloader.conf.load_str_data(json.dumps(self.sample_conf)) jsonloader.conf.load_extensions() self.conf = jsonloader.conf._config ca_conf = self.conf["signing_ca"]["default_ca"] ca_conf["output_path"] = tempfile.mkdtemp() # Set CA file permissions os.chmod(ca_conf["cert_path"], stat.S_IRUSR | stat.S_IFREG) os.chmod(ca_conf["key_path"], stat.S_IRUSR | stat.S_IFREG) app_conf = { "app": copy.deepcopy(config.app), "logging": copy.deepcopy(config.logging) } self.app = pecan_testing.load_test_app(app_conf)
def _make_app(self, enable_acl=False): # Determine where we are so we can set up paths in the config root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', ) ) self.config = { 'app': { 'root': 'ceilometer.api.controllers.root.RootController', 'modules': ['ceilometer.api'], 'static_root': '%s/public' % root_dir, 'template_path': '%s/ceilometer/api/templates' % root_dir, 'enable_acl': enable_acl, }, 'logging': { 'loggers': { 'root': {'level': 'INFO', 'handlers': ['console']}, 'wsme': {'level': 'INFO', 'handlers': ['console']}, 'ceilometer': {'level': 'DEBUG', 'handlers': ['console'], }, }, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'simple' } }, 'formatters': { 'simple': { 'format': ('%(asctime)s %(levelname)-5.5s [%(name)s]' '[%(threadName)s] %(message)s') } }, }, } return load_test_app(self.config)
def setUp(self): super(TestCase, self).setUp() self.app = testing.load_test_app( os.path.join(os.path.dirname(__file__), 'config.py')) token_info = { 'token': { 'project': { 'id': 'fake_project' }, 'user': { 'id': 'fake_user' } } } self.context = magnum_context.RequestContext( auth_token_info=token_info, project_id='fake_project', user_id='fake_user') def make_context(*args, **kwargs): # If context hasn't been constructed with token_info if not kwargs.get('auth_token_info'): kwargs['auth_token_info'] = copy.deepcopy(token_info) if not kwargs.get('project_id'): kwargs['project_id'] = 'fake_project' if not kwargs.get('user_id'): kwargs['user_id'] = 'fake_user' context = magnum_context.RequestContext(*args, **kwargs) return magnum_context.RequestContext.from_dict(context.to_dict()) p = mock.patch.object(magnum_context, 'make_context', side_effect=make_context) self.mock_make_context = p.start() self.addCleanup(p.stop) self.useFixture(conf_fixture.ConfFixture(cfg.CONF)) self._base_test_obj_backup = copy.copy( objects_base.MagnumObject._obj_classes) self.addCleanup(self._restore_obj_registry)
def setUp(self): super(BaseRESTTestCase, self).setUp() self.permissions = ['is_admin'] os.environ['CR_CONFIG'] = os.path.join(os.path.dirname(__file__), '../../api', 'cr_test.conf') self.app = load_test_app( os.path.join(os.path.dirname(__file__), '../../api', 'config_test.py')) self.cache = self.modules['cloudrunner_server.util.cache'] self.aero = self.cache.CacheRegistry() self.aero_reader = self.aero.reader().__enter__() self.modules = modules # assert correct database self.assertIsNone(p_conf.sqlalchemy.engine.url.database) self.assertEquals(p_conf.sqlalchemy.engine.url.drivername, "sqlite") self._user_id = 1 get_token = self._get_token self.aero_reader.get_user_token = get_token self.populate()
def test_run_api_app_serve_specific_address(self, m_make, m_make_app): cfg.CONF.set_default("host", "localhost", group="api") m_make_app.return_value = load_test_app(config=api_config.PECAN_CONFIG) api.main() self.assertEqual(m_make.call_count, 1)
def test_run_api_app(self, m_make, m_make_app): m_make_app.return_value = load_test_app(config=api_config.PECAN_CONFIG) api.main() self.assertEqual(m_make.call_count, 1)
def setUp(self): cfg.CONF.set_override("enable_authentication", False) self.app = testing.load_test_app(os.path.join( os.path.dirname(__file__), 'config.py' ))
def setup_app(self): self.app = load_test_app( os.path.join(os.path.dirname(__file__), 'config.py'))
def setUp(self): self.app = testing.load_test_app(os.path.join( os.path.dirname(__file__), 'config.py' ))
def setUp(self): self.app = load_test_app( config.get_config_dict(':memory:', '0.0.0.0', 9090), )
def setUp(self): self.app = load_test_app( os.path.join(os.path.dirname(__file__), 'config.py')) self.addCleanup(set_config, {}, overwrite=True)
def setUp(self): super(PlansTests, self).setUp() config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..', '..', 'api', 'config.py') self.app = load_test_app(config_file)
def setUp(self): cfg.CONF.set_override("enable_authentication", False, enforce_type=True) self.app = testing.load_test_app( os.path.join(os.path.dirname(__file__), 'config.py'))
def setUp(self): self.app = load_test_app(copy.deepcopy(self.CONFIG))
def load_test_app(self, config): return load_test_app(config)
def test_invalid_auth_strategy(self): cfg.CONF.set_override('auth_strategy', 'badvalue') with testtools.ExpectedException(n_exc.InvalidConfigurationOption): load_test_app(os.path.join(os.path.dirname(__file__), 'config.py'))
def setup_app(self): self.app = load_test_app(os.path.join( os.path.dirname(__file__), 'config.py' )) self._gen_port()
def setUp(self): self.app = load_test_app(os.path.join( os.path.dirname(__file__), 'config.py' )) self.addCleanup(set_config, {}, overwrite=True)
def load_test_app(cls): cls.app = testing.load_test_app(getConfigFile())
def setUp(self): self.app = load_test_app(os.path.join(os.path.dirname(__file__), 'config.py' )) super(PecanEndPointFunctionalTest, self).setUp()
# LOG.debug("TestDatabase finished well") except Exception as exception: print("Exception" + str(exception)) # LOG.error("Exception in TestDatabase: " + str(exception)) def print_exception(): try: print "*** print_exc:" traceback.print_exc() print "*** format_exception:" print traceback.format_exc() print "*** extract_tb:" print traceback.extract_tb() print "*** format_tb:" print traceback.format_tb() except Exception as exception1: print "*** print_exc:" traceback.print_exc() if __name__ == "__main__": app = load_test_app(os.path.join(os.path.dirname(__file__), './config.py')) # main() insert_data() delete() # main4()