def setUpClass(cls): initialize_test_config() execution_db_help.setup_dbs() cls.app = create_app() cls.app.testing = True cls.context = cls.app.test_request_context() cls.context.push() cls.test_client = cls.app.test_client(cls) db.create_all() cls.role_rd = Role('message_guest') cls.role_rd.set_resources([{'name': 'messages', 'permissions': ['read', 'delete', 'update']}]) cls.role_r = Role('read_only') cls.role_r.set_resources([{'name': 'messages', 'permissions': ['read', 'update']}]) db.session.add(cls.role_rd) db.session.add(cls.role_r) try: db.session.commit() except IntegrityError: db.session.rollback() cls.user1 = UserWrapper('username', 'password', roles=[cls.role_rd.id]) cls.user2 = UserWrapper('username2', 'password2', roles=[cls.role_r.id]) cls.user3 = UserWrapper('username3', 'password3') cls.all_users = (cls.user1, cls.user2, cls.user3) db.session.add(cls.user1.user) db.session.add(cls.user2.user) db.session.add(cls.user3.user) try: db.session.commit() except IntegrityError: db.session.rollback()
def setUpClass(cls): initialize_test_config() execution_db_help.setup_dbs() app = create_app() cls.context = app.test_request_context() cls.context.push() create_user()
def setUpClass(cls): initialize_test_config() execution_db_help.setup_dbs() walkoff.config.app_apis = {'App1': {'actions': {'action1': None, 'action2': None, 'action3': None}}, 'App2': {}} cls.action_events = {event for event in WalkoffEvent if event.event_type == EventType.action and event != WalkoffEvent.SendMessage}
def setUpClass(cls): initialize_test_config() cls.execution_db = execution_db_help.setup_dbs() app = cls.execution_db.session.query(App).filter(App.name == 'TestApp').first() if app is not None: cls.execution_db.session.delete(app) for device in cls.execution_db.session.query(Device).all(): cls.execution_db.session.delete(device) cls.execution_db.session.commit()
def setUpClass(cls): initialize_test_config() server_secret_file = os.path.join(walkoff.config.Config.ZMQ_PRIVATE_KEYS_PATH, "server.key_secret") server_public, server_secret = auth.load_certificate(server_secret_file) client_secret_file = os.path.join(walkoff.config.Config.ZMQ_PRIVATE_KEYS_PATH, "client.key_secret") client_public, client_secret = auth.load_certificate(client_secret_file) cls.key = PrivateKey(client_secret[:nacl.bindings.crypto_box_SECRETKEYBYTES]) cls.server_key = PrivateKey(server_secret[:nacl.bindings.crypto_box_SECRETKEYBYTES]).public_key cls.box = Box(cls.key, cls.server_key)
def setUpClass(cls): initialize_test_config() app = create_app() cls.context = app.test_request_context() cls.context.push() execution_db_help.setup_dbs() create_user()
def setUpClass(cls): initialize_test_config() walkoff.config.Config.write_values_to_file() cls.app = create_app(walkoff.config.Config) cls.context = cls.app.test_request_context() cls.context.push() pids = spawn_worker_processes() cls.app.running_context.executor.initialize_threading(cls.app, pids)
def setUpClass(cls): initialize_test_config() execution_db_help.setup_dbs() app = create_app() cls.context = app.test_request_context() cls.context.push() multiprocessedexecutor.MultiprocessedExecutor.initialize_threading = mock_initialize_threading multiprocessedexecutor.MultiprocessedExecutor.wait_and_reset = mock_wait_and_reset multiprocessedexecutor.MultiprocessedExecutor.shutdown_pool = mock_shutdown_pool cls.executor = multiprocessedexecutor.MultiprocessedExecutor( MockRedisCacheAdapter(), LocalActionExecutionStrategy()) cls.executor.initialize_threading(app)
def setUpClass(cls): initialize_test_config() execution_db_help.setup_dbs() app = create_app(walkoff.config.Config) cls.context = app.test_request_context() cls.context.push() multiprocessedexecutor.MultiprocessedExecutor.initialize_threading = mock_initialize_threading multiprocessedexecutor.MultiprocessedExecutor.wait_and_reset = mock_wait_and_reset multiprocessedexecutor.MultiprocessedExecutor.shutdown_pool = mock_shutdown_pool cls.executor = multiprocessedexecutor.MultiprocessedExecutor( MockRedisCacheAdapter(), create_autospec(CaseLogger)) cls.executor.initialize_threading(app)
def setUpClass(cls): initialize_test_config() cls.app = create_app() cls.context = cls.app.test_request_context() cls.context.push() db.create_all() for user in [user for user in User.query.all() if user.username != 'admin']: db.session.delete(user) for role in [role for role in Role.query.all() if role.name != 'admin']: db.session.delete(role) for message in Message.query.all(): db.session.delete(message) db.session.commit()
def setUpClass(cls): initialize_test_config() execution_db_help.setup_dbs() app = create_app() cls.context = app.test_request_context() cls.context.push() multiprocessedexecutor.MultiprocessedExecutor.initialize_threading = mock_initialize_threading multiprocessedexecutor.MultiprocessedExecutor.wait_and_reset = mock_wait_and_reset multiprocessedexecutor.MultiprocessedExecutor.shutdown_pool = mock_shutdown_pool cls.executor = multiprocessedexecutor.MultiprocessedExecutor( MockRedisCacheAdapter(), LocalActionExecutionStrategy() ) cls.executor.initialize_threading(app)
def setUpClass(cls): initialize_test_config() cls.conf = walkoff.config.Config if cls != ServerTestCase and cls.setUp != ServerTestCase.setUp: original_setup = cls.setUp def setup_override(self, *args, **kwargs): ServerTestCase.setUp(self) return original_setup(self, *args, **kwargs) cls.setUp = setup_override if cls != ServerTestCase and cls.tearDown != ServerTestCase.tearDown: original_teardown = cls.tearDown def teardown_override(self, *args, **kwargs): cls.preTearDown(self) ServerTestCase.tearDown(self) return original_teardown(self, *args, **kwargs) cls.tearDown = teardown_override if (cls.conf.DATA_DIR_NAME not in os.listdir(cls.conf.TEST_PATH) or os.path.isfile(cls.conf.DATA_PATH)): if os.path.isfile(cls.conf.DATA_PATH): os.remove(cls.conf.DATA_PATH) os.makedirs(cls.conf.DATA_PATH) cls.app = create_app() cls.app.testing = True cls.context = cls.app.test_request_context() cls.context.push() create_user() if cls.patch: MultiprocessedExecutor.initialize_threading = mock_initialize_threading MultiprocessedExecutor.shutdown_pool = mock_shutdown_pool MultiprocessedExecutor.wait_and_reset = mock_wait_and_reset cls.app.running_context.executor.initialize_threading(cls.app) else: walkoff.config.Config.write_values_to_file() pids = spawn_worker_processes() cls.app.running_context.executor.initialize_threading( cls.app, pids)
def setUpClass(cls): initialize_test_config() cls.conf = walkoff.config.Config if cls != ServerTestCase and cls.setUp != ServerTestCase.setUp: original_setup = cls.setUp def setup_override(self, *args, **kwargs): ServerTestCase.setUp(self) return original_setup(self, *args, **kwargs) cls.setUp = setup_override if cls != ServerTestCase and cls.tearDown != ServerTestCase.tearDown: original_teardown = cls.tearDown def teardown_override(self, *args, **kwargs): cls.preTearDown(self) ServerTestCase.tearDown(self) return original_teardown(self, *args, **kwargs) cls.tearDown = teardown_override if (cls.conf.DATA_DIR_NAME not in os.listdir(cls.conf.TEST_PATH) or os.path.isfile(cls.conf.DATA_PATH)): if os.path.isfile(cls.conf.DATA_PATH): os.remove(cls.conf.DATA_PATH) os.makedirs(cls.conf.DATA_PATH) cls.app = create_app() cls.app.testing = True cls.context = cls.app.test_request_context() cls.context.push() create_user() if cls.patch: MultiprocessedExecutor.initialize_threading = mock_initialize_threading MultiprocessedExecutor.shutdown_pool = mock_shutdown_pool MultiprocessedExecutor.wait_and_reset = mock_wait_and_reset cls.app.running_context.executor.initialize_threading(cls.app) else: walkoff.config.Config.write_values_to_file() pids = spawn_worker_processes() cls.app.running_context.executor.initialize_threading(cls.app, pids)
def setUpClass(cls): initialize_test_config() cls.app = create_app(walkoff.config.Config) cls.context = current_app.test_request_context() cls.context.push() db.create_all() for user in [ user for user in User.query.all() if user.username != 'admin' ]: db.session.delete(user) for role in [ role for role in Role.query.all() if role.name != 'admin' ]: db.session.delete(role) for message in Message.query.all(): db.session.delete(message) db.session.commit()
def setUpClass(cls): initialize_test_config() execution_db_help.setup_dbs() cls.app = create_app() cls.context = cls.app.test_request_context() cls.context.push() db.create_all() for user in [user for user in User.query.all() if user.username != 'admin']: db.session.delete(user) for message in MessageHistory.query.all(): db.session.delete(message) db.session.commit() cls.user1 = User('username', 'password') cls.user2 = User('username2', 'pwwww3') db.session.add(cls.user1) db.session.add(cls.user2) db.session.commit()
def setUpClass(cls): initialize_test_config() execution_db_help.setup_dbs() cls.context = current_app.test_request_context() cls.context.push() db.create_all() for user in [ user for user in User.query.all() if user.username != 'admin' ]: db.session.delete(user) for message in MessageHistory.query.all(): db.session.delete(message) db.session.commit() cls.user1 = User('username', 'password') cls.user2 = User('username2', 'pwwww3') db.session.add(cls.user1) db.session.add(cls.user2) db.session.commit()
def setUpClass(cls): cls.uid1 = str(uuid4()) cls.uid2 = str(uuid4()) cls.uid3 = str(uuid4()) cls.uids = {cls.uid1, cls.uid2, cls.uid3} initialize_test_config() cls.app = create_app() cls.context = cls.app.test_request_context() cls.context.push() db.create_all() for user in [user for user in User.query.all() if user.username != 'admin']: db.session.delete(user) for role in [role for role in Role.query.all() if role.name != 'admin']: db.session.delete(role) for message in Message.query.all(): db.session.delete(message) db.session.commit()
def setUpClass(cls): initialize_test_config() execution_db_help.setup_dbs()
def setUpClass(cls): initialize_test_config() cls.context = current_app.test_request_context() cls.context.push() setup_dbs()
def setUpClass(cls): initialize_test_config() cls.cache = MockRedisCacheAdapter() cls.controller = ZmqWorkflowCommunicationSender() setup_dbs()
def setUpClass(cls): initialize_test_config() cls.app = create_app() cls.app.testing = True cls.context = cls.app.test_request_context() cls.context.push()
def setUpClass(cls): initialize_test_config() cls.execution_db = execution_db_help.setup_dbs() cls.cache = MockRedisCacheAdapter()
def setUpClass(cls): initialize_test_config() cls.conditions = walkoff.appgateway.get_all_conditions_for_app('HelloWorld') cls.transforms = walkoff.appgateway.get_all_transforms_for_app('HelloWorld')
def setUpClass(cls): initialize_test_config() cls.subscriptions = [Subscription(str(uuid4()), ['a', 'b', 'c']), Subscription(str(uuid4()), ['b'])] cls.cache = MockRedisCacheAdapter() cls.controller = WorkflowExecutionController(cls.cache) setup_dbs()
def setUpClass(cls): initialize_test_config()
def setUpClass(cls): initialize_test_config() cls.mapping = {'redis': MockRedisCacheAdapter}
def setUpClass(cls): initialize_test_config() walkoff.cache.cache_translation['redis'] = MockRedisCacheAdapter
def setUpClass(cls): initialize_test_config() if not os.path.exists(walkoff.config.Config.CACHE_PATH): os.mkdir(walkoff.config.Config.CACHE_PATH)