コード例 #1
0
def get_backward_compatibility_state_machines_path():
    python_version = "python" + str(sys.version_info.major) + "." + str(
        sys.version_info.minor)
    path = testing_utils.get_test_sm_path(
        os.path.join("unit_test_state_machines", "backward_compatibility",
                     python_version))
    return path
コード例 #2
0
def test_library_relocation(caplog):

    testing_utils.initialize_environment_core(
        libraries={"test_scripts": testing_utils.TEST_ASSETS_PATH})

    interface.open_folder_func = open_folder

    interface.show_notice_func = show_notice

    state_machine = storage.load_state_machine_from_path(
        testing_utils.get_test_sm_path(
            os.path.join("unit_test_state_machines",
                         "library_relocation_test")))

    rafcon.core.singleton.state_machine_manager.add_state_machine(
        state_machine)

    rafcon.core.singleton.state_machine_execution_engine.start(
        state_machine.state_machine_id)
    rafcon.core.singleton.state_machine_execution_engine.join()
    rafcon.core.singleton.state_machine_execution_engine.stop()

    try:
        assert state_machine.root_state.output_data["output_0"] == 27
    finally:
        testing_utils.shutdown_environment_only_core(caplog=caplog,
                                                     expected_warnings=0,
                                                     expected_errors=1)

    logger.info("State machine execution finished!")
コード例 #3
0
def test_drag_and_drop_test(caplog):
    testing_utils.run_gui(
        gui_config={
            'AUTO_BACKUP_ENABLED': False,
            'HISTORY_ENABLED': False
        },
        runtime_config={
            'MAIN_WINDOW_MAXIMIZED': False,
            'MAIN_WINDOW_SIZE': (1500, 800),
            'MAIN_WINDOW_POS': (0, 0),
            'LEFT_BAR_WINDOW_UNDOCKED': False,
            'RIGHT_BAR_WINDOW_UNDOCKED': False,
            'CONSOLE_WINDOW_UNDOCKED': False,
            'LEFT_BAR_HIDDEN': True,
            'RIGHT_BAR_HIDDEN': True,
            'CONSOLE_HIDDEN': True,
        },
        libraries={
            "unit_test_state_machines":
            testing_utils.get_test_sm_path("unit_test_state_machines")
        })
    import rafcon.core.singleton
    call_gui_callback(create_models)

    try:
        trigger_drag_and_drop_tests(
            rafcon.gui.singleton.state_machine_manager_model,
            rafcon.gui.singleton.main_window_controller)
    finally:
        testing_utils.close_gui()
        testing_utils.shutdown_environment(caplog=caplog,
                                           expected_warnings=1,
                                           expected_errors=0)
コード例 #4
0
def execute_preemption_of_all_state_machines_at_once():
    from rafcon.core.singleton import state_machine_execution_engine, state_machine_manager
    import rafcon.gui.singleton as gui_singleton

    menubar_ctrl = gui_singleton.main_window_controller.get_controller(
        'menu_bar_controller')
    call_gui_callback(
        menubar_ctrl.on_open_activate, None, None,
        testing_utils.get_test_sm_path(
            os.path.join("unit_test_state_machines",
                         "all_dialogs_parallel_preempted")))
    testing_utils.wait_for_gui()

    call_gui_callback(menubar_ctrl.on_start_activate, None, None)
    duration_waited = 0.
    period = 0.1
    while not state_machine_execution_engine.finished_or_stopped():
        time.sleep(period)
        duration_waited += period
        if duration_waited > 3.:
            call_gui_callback(menubar_ctrl.on_stop_activate, None, None)
            raise RuntimeError(
                "The state machine should finish in less then {0}".format(
                    duration_waited))
    print(
        "Run duration of execute_preemption_of_all_state_machines_at_once was: {0}"
        .format(duration_waited))
コード例 #5
0
ファイル: test_baking.py プロジェクト: ylshimp/RAFCON
def test_state_machine_baking(gui):
    import rafcon.core.id_generator
    from rafcon.gui.helpers import state_machine as gui_helper_state_machine

    state_machine_manager = gui.core_singletons.state_machine_manager
    sm_id_0 = rafcon.core.id_generator.state_machine_id_counter

    menu_bar_controller = gui.singletons.main_window_controller.menu_bar_controller

    gui(
        menu_bar_controller.on_open_activate, None, None,
        testing_utils.get_test_sm_path(
            os.path.join("unit_test_state_machines", "bake_sm")))

    state_machine1 = state_machine_manager.state_machines[sm_id_0 + 1]
    print("#1 ", state_machine1)
    print("#2 ", gui(state_machine1.mutable_hash).hexdigest())

    baking_path = os.path.join(testing_utils.RAFCON_TEMP_PATH_TEST_BASE,
                               "baking")
    # baking_path = os.path.join(testing_utils.RAFCON_TEMP_PATH_TEST_BASE_ONLY_USER_SAVE, "baking")

    gui(gui_helper_state_machine.bake_selected_state_machine, baking_path)

    gui(menu_bar_controller.on_open_activate, None, None,
        os.path.join(baking_path, "__generated__state_machine"))

    from rafcon.core.id_generator import generate_state_machine_id
    state_machine2 = state_machine_manager.state_machines[sm_id_0 + 4]
    print("#3 ", state_machine2)
    print("#4 ", gui(state_machine1.mutable_hash).hexdigest())

    mutable_hash_sm1 = gui(state_machine1.mutable_hash)
    mutable_hash_sm2 = gui(state_machine2.mutable_hash)
    assert mutable_hash_sm1.hexdigest() == mutable_hash_sm2.hexdigest()
コード例 #6
0
def test_start_script_valid_rmpm_env():
    """Tests the execution of ``rafcon_core`` in an environment created by RMPM
    """
    testing_utils.dummy_gui(None)
    import distutils.spawn
    rmpm_env = os.environ.copy()
    rmpm_env[
        "PATH"] = "/volume/software/common/packages/rmpm/latest/bin/{}:".format(
            os.getenv("DLRRM_HOST_PLATFORM",
                      "osl42-x86_64")) + rmpm_env["PATH"]
    if not distutils.spawn.find_executable("rmpm_do"):
        print("Could not find rmpm_do, skipping test")
        return
    start_path = testing_utils.get_test_sm_path(
        join("unit_test_state_machines", "start_script_test"))
    config = join(testing_utils.TESTS_PATH, "assets", "configs",
                  "valid_config", "config.yaml")
    cmd = "eval `rmpm_do env --env-format=embed_sh sw.common.rafcon` && rafcon_core -o {0} -c {1}" \
          "".format(start_path, config)
    print("\ntest_start_script_valid_config: \n", cmd)
    rafcon_process = subprocess.Popen(cmd,
                                      shell=True,
                                      stdout=subprocess.PIPE,
                                      env=rmpm_env)
    rafcon_process.wait()
    output = rafcon_process.communicate()[0]
    print("LOG: \n", output)
    assert rafcon_process.returncode == 0
コード例 #7
0
def test_preemption_of_all_state_machines_at_once(gui):
    gui(initialize_global_variables)
    with pytest.warns(log.RAFCONDeprecationWarning) as deprecations_warnings:
        from rafcon.core.singleton import state_machine_execution_engine, state_machine_manager
        import rafcon.gui.singleton as gui_singleton

        menubar_ctrl = gui_singleton.main_window_controller.get_controller(
            'menu_bar_controller')
        gui(
            menubar_ctrl.on_open_activate, None, None,
            testing_utils.get_test_sm_path(
                os.path.join("unit_test_state_machines",
                             "all_dialogs_parallel_preempted")))

        gui(menubar_ctrl.on_start_activate, None, None)
        duration_waited = 0.
        period = 0.1
        while not state_machine_execution_engine.finished_or_stopped():
            time.sleep(period)
            duration_waited += period
            if duration_waited > 3.:
                gui(menubar_ctrl.on_stop_activate, None, None)
                raise RuntimeError(
                    "The state machine should finish in less then {0}".format(
                        duration_waited))
        print(
            "Run duration of execute_preemption_of_all_state_machines_at_once was: {0}"
            .format(duration_waited))
        assert len([
            record for record in deprecations_warnings
            if record.category is log.RAFCONDeprecationWarning
        ]) == 4
コード例 #8
0
ファイル: test_storage.py プロジェクト: DLR-RM/RAFCON
def test_on_clean_storing_with_name_in_path(caplog):
    testing_utils.dummy_gui(None)

    testing_utils.initialize_environment(gui_config={
        'HISTORY_ENABLED': False,
        'AUTO_BACKUP_ENABLED': False
    },
                                         gui_already_started=False)

    path_old_format = testing_utils.get_test_sm_path(
        os.path.join("unit_test_state_machines",
                     "id_to_name_plus_id_storage_format_test_do_not_update"))
    path_new_format = os.path.join(
        testing_utils.get_unique_temp_path(),
        "id_to_name_plus_id_storage_format_test_do_not_update")

    # gui imports better after initialization
    from rafcon.gui.models.state_machine import StateMachineModel

    shutil.copytree(path_old_format, path_new_format)
    from rafcon.core.storage import storage
    sm = storage.load_state_machine_from_path(path_new_format)
    check_state_recursively_if_state_scripts_are_valid(sm.root_state)
    sm.base_path = path_new_format
    sm_m = StateMachineModel(sm)
    try:
        on_save_activate(sm_m, logger)
        check_that_all_files_are_there(sm, with_print=False)
        check_id_and_name_plus_id_format(path_old_format, path_new_format,
                                         sm_m)
    finally:
        testing_utils.shutdown_environment(caplog=caplog,
                                           unpatch_threading=False)
コード例 #9
0
def test_preemption_behaviour_during_stop(caplog):
    testing_utils.initialize_environment_core()

    path = testing_utils.get_test_sm_path(
        os.path.join("unit_test_state_machines",
                     "preemption_behaviour_during_stop"))
    state_machine = storage.load_state_machine_from_path(path)
    rafcon.core.singleton.state_machine_manager.add_state_machine(
        state_machine)

    thread = threading.Thread(
        target=trigger_stop,
        args=[
            state_machine, rafcon.core.singleton.state_machine_execution_engine
        ])
    thread.start()

    rafcon.core.singleton.state_machine_execution_engine.start(
        state_machine.state_machine_id)
    rafcon.core.singleton.state_machine_execution_engine.join()

    rafcon.core.singleton.state_machine_manager.remove_state_machine(
        state_machine.state_machine_id)
    try:
        assert global_variable_manager.get_variable("s1") == 1
        assert global_variable_manager.get_variable("s2") == 1
        assert not global_variable_manager.variable_exist("s3")
    finally:
        testing_utils.shutdown_environment_only_core(caplog=caplog)
コード例 #10
0
 def setup_class(cls):
     # This methods runs on class creation and creates the state machine
     testing_utils.test_multithreading_lock.acquire()
     state_machine = global_storage.load_state_machine_from_path(
         testing_utils.get_test_sm_path(os.path.join("unit_test_state_machines", "action_block_execution_test")))
     cls.state_machine = state_machine
     state_machine_manager.add_state_machine(state_machine)
コード例 #11
0
def test_only_run_this_state(caplog):
    # run_selected
    # Initialize testing environment
    testing_utils.initialize_environment_core()
    # Load State Machine
    sm = storage.load_state_machine_from_path(testing_utils.get_test_sm_path(os.path.join(
        "unit_test_state_machines", "test_run_only_this_state")))
    rafcon.core.singleton.state_machine_manager.add_state_machine(sm)
    # Run only selected state machine
    rafcon.core.singleton.global_variable_manager.set_variable("test_value", 0)
    state_machine_execution_engine.run_only_selected_state("BSSKWR/YEKRMH/TZILCN", sm.state_machine_id)
    sm.join()

    assert rafcon.core.singleton.global_variable_manager.get_variable("test_value") == 1

    # Test running a state inside a concurrency state
    rafcon.core.singleton.global_variable_manager.set_variable("test_value_concurrency", 2)
    state_machine_execution_engine.run_only_selected_state("BSSKWR/IQURCQ/LLRMSU/VYGYRO", sm.state_machine_id)
    sm.join()

    # assert variable state
    try:
        assert rafcon.core.singleton.global_variable_manager.get_variable("test_value_concurrency") == 1
    # Shutdown testing environment
    finally:
        testing_utils.shutdown_environment_only_core(caplog=caplog)
コード例 #12
0
def test_backward_compatibility_storage(caplog):
    """This test ensures that old state machines storage formats can still be opened with the current RAFCON version"""
    path = get_backward_compatibility_state_machines_path()

    if not os.path.exists(path):
        logger.info(
            "test_backward_compatibility_storage: the current python interpreter version is not supported"
        )
        return

    run_gui(gui_config={
        'HISTORY_ENABLED': False,
        'AUTO_BACKUP_ENABLED': False
    },
            libraries={
                'unit_test_state_machines':
                testing_utils.get_test_sm_path("unit_test_state_machines")
            })

    try:
        logger.info("Run backward compatibility state machine for own version")
        run_backward_compatibility_state_machines(path)

        logger.info(
            "Run backward compatibility state machine for other versions")
        all_versions_path = testing_utils.get_test_sm_path(
            os.path.join("unit_test_state_machines", "backward_compatibility"))
        for python_version_folder in os.listdir(all_versions_path):
            full_python_version_path = os.path.join(all_versions_path,
                                                    python_version_folder)
            if os.path.isdir(full_python_version_path):
                if full_python_version_path == path:
                    pass
                else:
                    run_backward_compatibility_state_machines(
                        full_python_version_path)

    except Exception:
        raise
    finally:
        # two warning per minor version lower than the current RAFCON version
        state_machines = len([
            filename for filename in os.listdir(path)
            if os.path.isdir(os.path.join(path, filename))
        ])
        testing_utils.close_gui()
        testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0)
コード例 #13
0
def test_backward_stepping_preemptive_state(gui):
    gui(initialize_global_variables)

    from rafcon.core.singleton import state_machine_execution_engine

    menubar_ctrl = gui.singletons.main_window_controller.menu_bar_controller

    state_machine = gui(
        menubar_ctrl.on_open_activate, None, None,
        testing_utils.get_test_sm_path(os.path.join("unit_test_state_machines", "backward_step_preemtive_test"))
    )
    testing_utils.wait_for_gui()

    # reset the synchronization counter; although the tests run in different processes they share their memory
    # as the import statements are at the top of the file and not inside the parallel called functions
    with state_machine_execution_engine._status.execution_condition_variable:
        state_machine_execution_engine.synchronization_counter = 0

    gui(menubar_ctrl.on_step_mode_activate, None, None)
    current_state_machine_id = gui.singletons.state_machine_manager.active_state_machine_id
    state_machines_editor_tab_status_check(current_state_machine_id, active=True)  # execution start is synchronous

    wait_for_execution_engine_sync_counter(1, logger)

    # forward
    for i in range(3):
        gui(menubar_ctrl.on_step_into_activate, None, None)
        wait_for_execution_engine_sync_counter(2, logger)

    gui(menubar_ctrl.on_step_into_activate, None, None)
    wait_for_execution_engine_sync_counter(1, logger)

    # preemptive concurrency state must be finished before the next step
    while not state_machine.get_state_by_path("AOURYA/LXEMOO").final_outcome:
        time.sleep(0.010)

    gui(menubar_ctrl.on_step_into_activate, None, None)
    wait_for_execution_engine_sync_counter(1, logger)

    # "take turn" state reached

    # backward
    for i in range(1):
        gui(menubar_ctrl.on_backward_step_activate, None, None)
        wait_for_execution_engine_sync_counter(1, logger)

    for i in range(3):
        gui(menubar_ctrl.on_backward_step_activate, None, None)
        wait_for_execution_engine_sync_counter(2, logger)

    state_machines_editor_tab_status_check(current_state_machine_id, active=True)
    gui(menubar_ctrl.on_backward_step_activate, None, None)

    while not state_machine_execution_engine.finished_or_stopped():
        time.sleep(0.1)
    # stop or finished are asynchronous but the call_gui_callback makes the check synchronous
    gui(state_machines_editor_tab_status_check, current_state_machine_id, False)

    gui(verify_execute_preemptive_state_forwards_backwards)
コード例 #14
0
def open_folder(query):
    if "library2_for_relocation_test" in query:
        return None  # the first relocation has to be aborted
    else:
        return testing_utils.get_test_sm_path(
            os.path.join("unit_test_state_machines",
                         "library_relocation_test_source",
                         "library1_for_relocation_test_relocated"))
コード例 #15
0
ファイル: test_runtime_value.py プロジェクト: ylshimp/RAFCON
def test_runtime_values(caplog):
    state_machine_manager.delete_all_state_machines()

    sm = state_machine_execution_engine.execute_state_machine_from_path(
        path=testing_utils.get_test_sm_path(os.path.join("unit_test_state_machines", "library_runtime_value_test")))
    state_machine_manager.remove_state_machine(sm.state_machine_id)
    assert sm.root_state.output_data["data_output_port1"] == 114
    testing_utils.assert_logger_warnings_and_errors(caplog)
コード例 #16
0
def test_user_input_gaphas(caplog):
    run_gui(gui_config={'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False},
            libraries={'unit_test_state_machines': testing_utils.get_test_sm_path("unit_test_state_machines")})
    try:
        create_and_resize_state()
    except Exception as e:
        raise
    finally:
        testing_utils.close_gui()
        testing_utils.shutdown_environment(caplog=caplog)
コード例 #17
0
def test_unchanged_storage_format(caplog):
    """This test ensures that the state machine storage format does not change in patch releases"""

    from rafcon.core.storage import storage
    from rafcon.gui.models.state_machine import StateMachineModel
    import rafcon

    path = get_backward_compatibility_state_machines_path()
    if not os.path.exists(path):
        logger.info(
            "test_unchanged_storage_format: the current python interpreter version is not supported"
        )
        return

    testing_utils.initialize_environment(
        gui_config={
            'HISTORY_ENABLED': False,
            'AUTO_BACKUP_ENABLED': False
        },
        libraries={
            'unit_test_state_machines':
            testing_utils.get_test_sm_path("unit_test_state_machines")
        },
        gui_already_started=False)
    try:
        current_rafcon_version = StrictVersion(rafcon.__version__).version
        current_minor = "{}.{}".format(current_rafcon_version[0],
                                       current_rafcon_version[1])
        for filename in os.listdir(path):
            if filename.startswith(current_minor):
                old_state_machine_path = os.path.join(path, filename)
                break
        else:
            assert False, "There is no state machine for the current RAFCON minor version {}".format(
                current_minor)

        state_machine = storage.load_state_machine_from_path(
            old_state_machine_path)
        state_machine_m = StateMachineModel(state_machine)
        new_state_machine_path = testing_utils.get_unique_temp_path()
        storage.save_state_machine_to_path(state_machine,
                                           new_state_machine_path, True, True)
        state_machine_m.store_meta_data(copy_path=new_state_machine_path)

        old_state_machine_hash = calculate_state_machine_hash(
            old_state_machine_path)
        new_state_machine_hash = calculate_state_machine_hash(
            new_state_machine_path)
        assert old_state_machine_hash.digest(
        ) == new_state_machine_hash.digest()
    except Exception:
        raise
    finally:
        testing_utils.shutdown_environment(caplog=caplog,
                                           unpatch_threading=False)
コード例 #18
0
ファイル: test_start.py プロジェクト: DLR-RM/RAFCON
def test_start():
    """ Test core.start.py script run on console which open a state machine, run it and final
    checks the output file on consistency.
    """
    start_path = testing_utils.get_test_sm_path(
        join("unit_test_state_machines", "start_script_test"))
    args = (['-o', start_path, '-c', testing_utils.RAFCON_TEMP_PATH_CONFIGS])

    start.main(optional_args=args)
    start.signal_handler(signal.SIGINT)
    state_machine_manager.delete_all_state_machines()
コード例 #19
0
def create_state_machine():
    state_machine_path = testing_utils.get_test_sm_path(os.path.join("unit_test_state_machines", "history_test"))
    state_machine = storage.load_state_machine_from_path(state_machine_path)
    state_dict = {
        'Container': state_machine.get_state_by_path("CONT2"),
        'State1': state_machine.get_state_by_path("CONT2/STATE1"),
        'State2': state_machine.get_state_by_path("CONT2/STATE2"),
        'State3': state_machine.get_state_by_path("CONT2/STATE3"),
        'Nested': state_machine.get_state_by_path("CONT2/STATE3/NESTED"),
        'Nested2': state_machine.get_state_by_path("CONT2/STATE3/NESTED2")
    }
    return state_machine, state_dict
コード例 #20
0
def test_dynamic_state_insertion_and_deletion_inside_library(caplog):
    testing_utils.run_gui(
        gui_config={'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False},
        libraries={'unit_test_state_machines': testing_utils.get_test_sm_path("unit_test_state_machines")}
    )
    try:
        execute_dynamic_state_insertion("dynamic_state_deletion_inside_library")
    except Exception:
        raise
    finally:
        testing_utils.close_gui()
        testing_utils.shutdown_environment(caplog=caplog, expected_warnings=23)
コード例 #21
0
def test_error_propagation(caplog):
    testing_utils.initialize_environment_core()

    sm = state_machine_execution_engine.execute_state_machine_from_path(
        path=testing_utils.get_test_sm_path(
            os.path.join("unit_test_state_machines",
                         "error_propagation_test")))
    state_machine_manager.remove_state_machine(sm.state_machine_id)
    try:
        assert sm.root_state.output_data["error_check"] == "successfull"
    finally:
        testing_utils.shutdown_environment_only_core(caplog=caplog,
                                                     expected_warnings=1,
                                                     expected_errors=2)
コード例 #22
0
def test_last_wins_value_collection_for_data_ports(caplog):

    sm_path = testing_utils.get_test_sm_path(os.path.join("unit_test_state_machines", "last_data_wins_test"))
    sm_loaded = storage.load_state_machine_from_path(sm_path)

    root_state = sm_loaded.root_state

    state_machine = StateMachine(root_state)
    testing_utils.test_multithreading_lock.acquire()

    rafcon.core.singleton.state_machine_manager.add_state_machine(state_machine)
    rafcon.core.singleton.state_machine_execution_engine.start(state_machine.state_machine_id)
    rafcon.core.singleton.state_machine_execution_engine.join()
    rafcon.core.singleton.state_machine_manager.remove_state_machine(state_machine.state_machine_id)
    testing_utils.shutdown_environment_only_core(caplog=caplog)
コード例 #23
0
def test_preemption_behaviour_in_preemption_state(caplog):
    testing_utils.initialize_environment_core()

    sm = state_machine_execution_engine.execute_state_machine_from_path(
        path=testing_utils.get_test_sm_path(
            os.path.join("unit_test_state_machines",
                         "preemption_behaviour_test_sm")))
    rafcon.core.singleton.state_machine_manager.remove_state_machine(
        sm.state_machine_id)
    from rafcon.core.singleton import global_variable_manager
    try:
        assert global_variable_manager.get_variable("s2") == 1.0
        assert not global_variable_manager.variable_exist("s3")
    finally:
        testing_utils.shutdown_environment_only_core(caplog=caplog)
コード例 #24
0
def test_start_script_valid_config():
    """ Test rafcon_core console call which run a rafcon instance with handed config.yaml file, open a state machine,
    run it and final checks the output file on consistency.
    """
    testing_utils.dummy_gui(None)
    script = join(testing_utils.RAFCON_BIN_PATH, "rafcon_core")
    start_path = testing_utils.get_test_sm_path(
        join("unit_test_state_machines", "start_script_test"))
    config = join(testing_utils.TESTS_PATH, "assets", "configs",
                  "valid_config", "config.yaml")
    output = str(
        subprocess.check_output([script, '-o', start_path, '-c', config]))
    print("\ntest_start_script_valid_config")
    assert "enter state_1" in output
    assert "enter state_2" in output
コード例 #25
0
def test_custom_entry_point(caplog):
    testing_utils.initialize_environment_core()

    start_state_id = "RWUZOP/ZDWBKU/HADSLI"
    sm = rafcon.core.singleton.state_machine_execution_engine.execute_state_machine_from_path(
        path=testing_utils.get_test_sm_path(
            os.path.join("unit_test_state_machines",
                         "test_custom_entry_point")),
        start_state_path=start_state_id)
    rafcon.core.singleton.state_machine_manager.remove_state_machine(
        sm.state_machine_id)
    try:
        assert not rafcon.core.singleton.global_variable_manager.variable_exist(
            "start_id21")
    finally:
        testing_utils.shutdown_environment_only_core(caplog=caplog)
コード例 #26
0
def test_repetitive_ungroup_state_and_group_states(caplog):
    """Check if repetitive group and ungroup works"""
    libraries = {
        "unit_test_state_machines":
        testing_utils.get_test_sm_path("unit_test_state_machines")
    }
    testing_utils.run_gui(gui_config={'HISTORY_ENABLED': True},
                          libraries=libraries)
    try:
        trigger_repetitive_group_ungroup()
    except Exception:
        raise
    finally:
        testing_utils.close_gui()
        testing_utils.shutdown_environment(caplog=caplog,
                                           expected_warnings=0,
                                           expected_errors=1)
コード例 #27
0
def execute_all_generic_libraries_with_keyboard_only(gui):
    menubar_ctrl = gui.singletons.main_window_controller.menu_bar_controller
    gui(
        menubar_ctrl.on_open_activate, None, None,
        testing_utils.get_test_sm_path(
            os.path.join("unit_test_state_machines", "all_generic_libraries")))
    testing_utils.wait_for_gui()

    gui(menubar_ctrl.on_start_activate, None, None)
    import time
    from pykeyboard import PyKeyboard
    time.sleep(0.5)
    k = PyKeyboard()
    k.tap_key('Return', 7, 0.5)
    k.tap_key('Tab', 2, 0.5)
    k.tap_key('Return', 5, 0.5)
    gui(menubar_ctrl.on_stop_activate, None, None)
コード例 #28
0
def test_backward_compatibility_storage(gui):
    """This test ensures that old state machines storage formats can still be opened with the current RAFCON version"""
    path = get_backward_compatibility_state_machines_path()

    if not os.path.exists(path):
        logger.info(
            "test_backward_compatibility_storage: the current python interpreter version is not supported"
        )
        return

    logger.info("Run backward compatibility state machine for own version")
    run_backward_compatibility_state_machines(gui, path)

    logger.info("Run backward compatibility state machine for other versions")
    all_versions_path = testing_utils.get_test_sm_path(
        os.path.join("unit_test_state_machines", "backward_compatibility"))
    run_backward_compatibility_state_machines(gui, all_versions_path)
コード例 #29
0
ファイル: test_baking.py プロジェクト: alexanderdurr/RAFCON
def test_state_machine_baking(caplog):
    testing_utils.dummy_gui(caplog)

    testing_utils.run_gui(
        gui_config={
            'HISTORY_ENABLED': False,
            'AUTO_BACKUP_ENABLED': False
        },
        libraries={
            'unit_test_state_machines':
            testing_utils.get_test_sm_path("unit_test_state_machines")
        })
    try:
        trigger_baking_commands()
    finally:
        testing_utils.close_gui()
        testing_utils.shutdown_environment(caplog=caplog)
コード例 #30
0
def test_start_script_state():
    """ Test core.start.py script run by python call which open a state machine, run from a specific state and  final
    checks the output file on consistency.
    """
    testing_utils.dummy_gui(None)
    script = join(testing_utils.RAFCON_PATH, "core", "start.py")
    start_path = testing_utils.get_test_sm_path(
        join("unit_test_state_machines", "start_script_test"))
    state_path = "UTUOSC/AHWBOG"
    print(start_path)
    output = str(
        subprocess.check_output([
            sys.executable, script, '-o', start_path, '-s', state_path, '-c',
            testing_utils.RAFCON_TEMP_PATH_CONFIGS
        ]))
    print("\ntest_start_script_state")
    assert "enter state_1" not in output
    assert "enter state_2" in output