示例#1
0
 def test__launch_application__launch_application_again__raises_exception(
         self) -> None:
     kill_all_open_flexloggers()
     with Application.launch():
         # We expect this to fail because we don't support multiple instances of FlexLogger
         # running at the same time.
         new_app = None
         try:
             with pytest.raises(RuntimeError):
                 new_app = Application.launch(timeout=20)
         finally:
             # if the test fails, try not to mess up future tests
             if new_app is not None:
                 new_app.close()
示例#2
0
 def test__open_project__active_project_path_matches_loaded_path(
         self) -> None:
     with copy_project("DefaultProject") as new_project_path:
         with Application.launch() as app:
             project = app.open_project(new_project_path)
             assert os.path.samefile(project.project_file_path,
                                     new_project_path)
示例#3
0
 def test__launch_application__close_application__using_application_raises_exception(
     self, ) -> None:
     kill_all_open_flexloggers()
     app = Application.launch()
     app.close()
     with pytest.raises(FlexLoggerError):
         app.open_project(get_project_path("DefaultProject"))
示例#4
0
 def test__launch_application__open_and_close_project__active_project_is_none(
         self) -> None:
     kill_all_open_flexloggers()
     with Application.launch() as app:
         project = app.open_project(get_project_path("DefaultProject"))
         project.close()
         active_project = app.get_active_project()
         assert active_project is None
示例#5
0
 def test__launch_application__open_project__active_project_matches_open_project(
         self) -> None:
     kill_all_open_flexloggers()
     with Application.launch() as app:
         project = app.open_project(get_project_path("DefaultProject"))
         active_project = app.get_active_project()
         assert active_project is not None
         assert project._identifier == active_project._identifier
示例#6
0
 def test__open_project__close_application__using_project_raises_exception(
         self) -> None:
     kill_all_open_flexloggers()
     app = Application.launch()
     project = app.open_project(get_project_path("DefaultProject"))
     app.close()
     with pytest.raises(FlexLoggerError):
         project.open_channel_specification_document()
示例#7
0
def main(project_path):
    """Launch FlexLogger, open a project, and get the loaded project's file path."""
    with Application.launch() as app:
        project = app.open_project(path=project_path)
        print("Project file path: " + str(project.project_file_path))
        print("Press Enter to close the project...")
        input()
        project.close()
    return 0
示例#8
0
 def test__make_change_to_project__close_application__no_save_dialog_box(
         self) -> None:
     kill_all_open_flexloggers()
     with copy_project("ProjectWithProducedData") as new_project_path:
         with Application.launch() as app:
             project = app.open_project(new_project_path)
             logging_specification = project.open_logging_specification_document(
             )
             logging_specification.set_log_file_name("SomeNewName")
示例#9
0
 def test__open_project__close_project__using_original_project_raises_exception(
         self) -> None:
     kill_all_open_flexloggers()
     project_path = get_project_path("DefaultProject")
     with Application.launch() as app:
         first_project = app.open_project(project_path)
         first_project.close()
         with pytest.raises(FlexLoggerError):
             first_project.open_channel_specification_document()
示例#10
0
    def test__launch_application__close_application__application_has_closed(
            self) -> None:
        kill_all_open_flexloggers()

        with Application.launch() as app:
            # Opening a project will make closing the application take longer
            app.open_project(get_project_path("DefaultProject"))

        assert_no_flexloggers_running()
示例#11
0
 def test__open_project__open_different_project__using_original_project_raises_exception(
     self, ) -> None:
     kill_all_open_flexloggers()
     project_path = get_project_path("DefaultProject")
     second_project_path = get_project_path("ProjectWithTestProperties")
     with Application.launch() as app:
         first_project = app.open_project(project_path)
         app.open_project(second_project_path)
         with pytest.raises(FlexLoggerError):
             first_project.open_channel_specification_document()
示例#12
0
 def test__disconnect_application__using_application_raises_exception(
         self) -> None:
     kill_all_open_flexloggers()
     original_app = Application.launch()
     try:
         new_app = Application(server_port=original_app.server_port)
         new_app.disconnect()
         with pytest.raises(FlexLoggerError):
             new_app.open_project(get_project_path("DefaultProject"))
     finally:
         original_app.close()
def main(project_path):
    """Launch FlexLogger, open a project, and disables a channel."""
    with Application.launch() as app:
        project = app.open_project(path=project_path)
        channel_name = input("Enter the name of the channel to disable: ")
        channel_specification = project.open_channel_specification_document()
        channel_specification.set_channel_enabled(channel_name, False)
        print("Channel disabled. Press Enter to close the project...")
        input()
        project.close()
    return 0
示例#14
0
    def test__connect_to_application__close_application__application_has_closed(
            self) -> None:
        kill_all_open_flexloggers()
        app = Application.launch()
        # Opening a project will make closing the application take longer
        app.open_project(get_project_path("DefaultProject"))

        app2 = Application(app.server_port)
        app2.close()

        assert_no_flexloggers_running()
示例#15
0
def main(project_path):
    """Launch FlexLogger, open a project, start and stop the test session."""
    with Application.launch() as app:
        project = app.open_project(path=project_path)
        test_session = project.test_session
        test_session.start()
        print("Test started. Press Enter to stop the test and close the project...")
        input()
        test_session.stop()
        project.close()
    return 0
def app() -> Iterator[Application]:
    """Fixture for launching FlexLogger.

    This is useful to improve test time by not launching/closing FlexLogger in every test.
    """
    app = Application.launch()
    yield app
    try:
        app.close()
    except FlexLoggerError:
        # utils.kill_all_open_flexloggers may have killed this process already, that's fine
        pass
def main(project_path):
    """Launch FlexLogger, open a project, and gets the log file base path and name."""
    with Application.launch() as app:
        project = app.open_project(path=project_path)
        logging_specification = project.open_logging_specification_document()
        log_file_base_path = logging_specification.get_log_file_base_path()
        log_file_name = logging_specification.get_log_file_name()
        print("Log file base path: " + log_file_base_path)
        print("Log file name: " + log_file_name)
        print("Press Enter to close the project...")
        input()
        project.close()
    return 0
示例#18
0
def main(project_path):
    """Launch FlexLogger, open a project, and get the value of a channel."""
    with Application.launch() as app:
        project = app.open_project(path=project_path)
        channel_name = input(
            "Enter the name of the channel to get the value of: ")
        channel_specification = project.open_channel_specification_document()
        channel_value = channel_specification.get_channel_value(channel_name)
        print("Channel value:")
        print(channel_value)
        print("Press Enter to close the project...")
        input()
        project.close()
    return 0
def main(project_path):
    """Launch FlexLogger, open a project, and sets the value of a test property."""
    with Application.launch() as app:
        project = app.open_project(path=project_path)
        test_property_name = input(
            "Enter the name of the test property to set the value of: ")
        test_property_value = input("Enter the test property value: ")
        logging_specification = project.open_logging_specification_document()
        logging_specification.set_test_property(test_property_name,
                                                test_property_value)
        print("Test property set. Press Enter to close the project...")
        input()
        project.close()
    return 0
def main(argv: List[str]) -> int:
    """Connect to FlexLogger and start a test"""
    with Application.launch() as app:
        project = app.open_project(argv[0])
        temp_dir = argv[1]
        logging_specification = project.open_logging_specification_document()
        logging_specification.set_log_file_base_path(temp_dir)
        logging_specification.set_log_file_name("ShouldNotExist.tdms")
        logging_specification.set_test_property("prompts on start",
                                                "some value", True)
        project.test_session.start()
        # Make sure that if this does start running, it will actually log data
        # before we close the project.
        time.sleep(5)
    return 0
示例#21
0
 def test__launch_flexlogger_and_disconnect__connect_to_existing_and_open_project__is_not_None(
     self, ) -> None:
     kill_all_open_flexloggers()
     project_path = get_project_path("DefaultProject")
     server_port = -1
     try:
         with Application.launch() as app:
             server_port = app.server_port
             # This should prevent FlexLogger from closing when app goes out of scope
             app.disconnect()
         with Application(server_port=server_port) as app:
             project = app.open_project(project_path)
             assert project is not None
     finally:
         if server_port != -1:
             Application(server_port=server_port).close()
def main(project_path):
    """Launch FlexLogger, open a project, start the test session and add a note."""
    with Application.launch() as app:
        project = app.open_project(path=project_path)
        test_session = project.test_session
        test_session.start()
        note = input("Test started. Enter a note to log: ")
        test_session.add_note(note)
        print(
            "Note added. Press Enter to stop the test and close the project..."
        )
        input()

        test_session.stop()
        project.close()
    return 0
示例#23
0
def main(project_path):
    """Interactively manage the state of the FlexLogger project test session.

    Launch FlexLogger, open the specified project and interactively
    manage the state of the FlexLogger project test session.
    """
    print("Launching FlexLogger . . .")
    with Application.launch() as app:
        print("Loading FlexLogger project . . .")
        project = app.open_project(path=project_path)
        test_session = project.test_session

        _show_interactive_menu(test_session)

        print("Closing FlexLogger project . . .")
        project.close()
    return 0
def main(project_path):
    """Interactively get and set FlexLogger channel values.

    Launch FlexLogger, open the specified project and interactively
    get and set FlexLogger channel values.
    """
    print("Launching FlexLogger . . .")
    with Application.launch() as app:
        print("Loading FlexLogger project . . .")
        project = app.open_project(path=project_path)
        channel_specification_document = project.open_channel_specification_document(
        )

        _show_interactive_menu(channel_specification_document)

        print("Closing FlexLogger project . . .")
        project.close()
    return 0
def test_sequence1(config_file_path, modbus_config_path):
    """Launch FlexLogger, reference the CSV file,
    open the specified FlexLogger projects,
    and control a simulated DUT and Modbus thermal chamber.

    The CSV lists the path to the FlexLogger projects,
    DUT commands, thermal chamber commands, and test times.

    To use this example with your DUT or other external hardware,
    replace the 'dut_control' function with your specific DUT's API
    or communication methods, and replace the 'temp_chamber_control'
    function with your specific chamber's API or communication methods,
    as needed.

    This example is configured to communicate with a Cincinnati Sub-Zero (CSZ) EZT-570i
    Environmental Chamber Controller through a Modbus TCP communication channel. This example may
    malfunction if used with a different environmental chamber controller.
    """
    # Configure INI File parsing structure
    config = configparser.ConfigParser()
    config["Modbus"] = {"IP": "0.0.0.0", "Port": "502"}

    # read ini file
    config.read(modbus_config_path)
    ip = config["Modbus"]["IP"]
    mport = config["Modbus"]["Port"]

    print("\nLaunching FlexLogger...")
    with Application.launch() as app:
        print("FlexLogger Launched Successfully!\n")
        dut_control("powerOn")
        dut_control("updateFirmware")
        # Configure Modbus TCP connection to the Thermal Chamber
        client = ModbusClient(ip, port=mport)
        # Connect to the Thermal Chamber
        client.connect()
        test1(app_reference=app,
              clienthandle=client,
              config_path=config_file_path)
        dut_control("powerOff")
        # Close Modbus TCP connection to the Thermal Chamber
        client.close()
    print("FlexLogger Closed Successfully")
    return
def main(project_path):
    """Interactively configure the FlexLogger logging specification.

    Launch FlexLogger, open the specified project and interactively
    configuring the FlexLogger logging specification.
    """
    print("Launching FlexLogger . . .")
    with Application.launch() as app:
        print("Loading FlexLogger project . . .")
        project = app.open_project(path=project_path)
        test_session = project.test_session
        logging_specification_document = project.open_logging_specification_document(
        )

        _show_interactive_menu(test_session, logging_specification_document)

        print("Closing FlexLogger project . . .")
        project.close()
    return 0
def test_sequence1(config_file_path):
    """Launch FlexLogger, reference the CSV file,
    open the specified FlexLogger projects,
    and control a simulated DUT.

    The CSV lists the path to the FlexLogger projects,
    DUT commands, and test times.

    To use this example with your DUT or other external hardware,
    replace the 'dut_control' function with your specific DUT's API
    or communication methods, as needed.
    """
    print("\nLaunching FlexLogger...")
    with Application.launch() as app:
        print("FlexLogger Launched Successfully!\n")
        dut_control("powerOn")
        dut_control("updateFirmware")
        test1(app, config_file_path)
        dut_control("powerOff")
    print("FlexLogger Closed Successfully")
    return
示例#28
0
 def test__open_project_that_does_not_exist__raises_exception(self) -> None:
     kill_all_open_flexloggers()
     project_path = get_project_path("DoesNotExist")
     with Application.launch() as app:
         with pytest.raises(FlexLoggerError):
             app.open_project(project_path)
示例#29
0
 def test__launch_application__active_project_is_none(self) -> None:
     kill_all_open_flexloggers()
     with Application.launch() as app:
         active_project = app.get_active_project()
         assert active_project is None