Exemple #1
0
    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()
Exemple #2
0
def modified_setup_worker_env():
    import tests.config
    import walkoff.config.config
    from tests.util.execution_db_help import setup_dbs
    import apps
    walkoff.appgateway.cache_apps(tests.config.test_apps_path)
    walkoff.config.config.load_app_apis(apps_path=tests.config.test_apps_path)
    setup_dbs()
    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):
     execution_db_help.setup_dbs()
     walkoff.appgateway.cache_apps(config.test_apps_path)
     walkoff.config.config.load_app_apis(apps_path=config.test_apps_path)
     multiprocessedexecutor.MultiprocessedExecutor.initialize_threading = mock_initialize_threading
     multiprocessedexecutor.MultiprocessedExecutor.wait_and_reset = mock_wait_and_reset
     multiprocessedexecutor.MultiprocessedExecutor.shutdown_pool = mock_shutdown_pool
     multiprocessedexecutor.multiprocessedexecutor.initialize_threading()
Exemple #5
0
    def setUpClass(cls):
        import walkoff.server.flaskserver
        cls.context = walkoff.server.flaskserver.app.test_request_context()
        cls.context.push()

        execution_db_help.setup_dbs()

        initialize_default_resources_admin()
        db.create_all()
 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()
     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}
Exemple #8
0
    def setUpClass(cls):
        execution_db_help.setup_dbs()

        app = executiondb.execution_db.session.query(App).filter(
            App.name == 'TestApp').first()
        if app is not None:
            executiondb.execution_db.session.delete(app)
        for device in executiondb.execution_db.session.query(Device).all():
            executiondb.execution_db.session.delete(device)
        executiondb.execution_db.session.commit()
    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):
        execution_db_help.setup_dbs()

        from walkoff.multiprocessedexecutor.multiprocessedexecutor import spawn_worker_processes
        walkoff.config.config.num_processes = 2
        pids = spawn_worker_processes(
            worker_environment_setup=modified_setup_worker_env)
        multiprocessedexecutor.initialize_threading(pids)
        walkoff.appgateway.cache_apps(config.test_apps_path)
        walkoff.config.config.load_app_apis(apps_path=config.test_apps_path)
        walkoff.config.config.num_processes = 2
    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)
Exemple #12
0
    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):
        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 (tests.config.test_data_dir_name not in os.listdir(tests.config.test_path)
                or os.path.isfile(tests.config.test_data_path)):
            if os.path.isfile(tests.config.test_data_path):
                os.remove(tests.config.test_data_path)
            os.makedirs(tests.config.test_data_path)

        execution_db_help.setup_dbs()

        walkoff.appgateway.cache_apps(path=tests.config.test_apps_path)
        walkoff.config.config.app_apis = {}
        walkoff.config.config.load_app_apis(apps_path=tests.config.test_apps_path)
        walkoff.config.config.num_processes = 2

        from walkoff.server import flaskserver
        cls.context = flaskserver.app.test_request_context()
        cls.context.push()

        from walkoff.server.app import create_user
        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
            flaskserver.running_context.executor.initialize_threading()
        else:
            from walkoff.multiprocessedexecutor.multiprocessedexecutor import spawn_worker_processes
            pids = spawn_worker_processes(worker_environment_setup=modified_setup_worker_env)
            flaskserver.running_context.executor.initialize_threading(pids)
Exemple #14
0
 def setUpClass(cls):
     execution_db_help.setup_dbs()
     cls.context = flaskserver.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):
        execution_db_help.setup_dbs()

        cls.context = flaskserver.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()
Exemple #17
0
    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()
        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()
        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()
Exemple #20
0
 def setUpClass(cls):
     initialize_test_config()
     cls.execution_db = execution_db_help.setup_dbs()
     cls.cache = MockRedisCacheAdapter()
 def setUpClass(cls):
     initialize_test_config()
     cls.cache = MockRedisCacheAdapter()
     cls.controller = ZmqWorkflowCommunicationSender()
     setup_dbs()
Exemple #22
0
    def setUpClass(cls):
        cls.context = walkoff.server.flaskserver.app.test_request_context()
        cls.context.push()
        db.create_all()

        execution_db_help.setup_dbs()
Exemple #23
0
 def setUpClass(cls):
     initialize_test_config()
     cls.context = current_app.test_request_context()
     cls.context.push()
     setup_dbs()
 def setUpClass(cls):
     initialize_test_config()
     execution_db_help.setup_dbs()
 def setUpClass(cls):
     initialize_test_config()
     execution_db_help.setup_dbs()
 def setUpClass(cls):
     execution_db_help.setup_dbs()
     walkoff.appgateway.cache_apps(test_apps_path)
 def setUpClass(cls):
     initialize_test_config()
     cls.cache = MockRedisCacheAdapter()
     cls.controller = ZmqWorkflowCommunicationSender()
     setup_dbs()
 def setUpClass(cls):
     execution_db_help.setup_dbs()
Exemple #29
0
 def setUp(self):
     execution_db_help.setup_dbs()
Exemple #30
0
 def setUpClass(cls):
     cls.context = server.app.test_request_context()
     cls.context.push()
     setup_dbs()
Exemple #31
0
 def setUpClass(cls):
     execution_db_help.setup_dbs()
     walkoff.appgateway.clear_cache()
     walkoff.appgateway.cache_apps(path=test_apps_path)
     walkoff.config.config.load_app_apis(test_apps_path)
Exemple #32
0
 def setUpClass(cls):
     initialize_test_config()
     cls.execution_db = execution_db_help.setup_dbs()
     cls.cache = MockRedisCacheAdapter()
 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()