class TestUnitMenuInstrumentProtocol(MiUnitTestCase):
    """
    Test cases for instrument protocol class. Functions in this class provide
    instrument protocol unit tests and provide a tutorial on use of
    the protocol interface.
    """
    class SubMenu(BaseEnum):
        MAIN = "SUBMENU_MAIN"
        ONE = "SUBMENU_ONE"
        TWO = "SUBMENU_TWO"

    class Prompt(BaseEnum):
        CMD_PROMPT = "-->"
        CONTINUE_PROMPT = "Press ENTER to continue."
        MAIN_MENU = "MAIN -->"
        ONE_MENU = "MENU 1 -->"
        TWO_MENU = "MENU 2 -->"

    MENU = MenuInstrumentProtocol.MenuTree({
        SubMenu.MAIN: [],
        SubMenu.ONE: [Directions(command="1", response=Prompt.ONE_MENU)],
        SubMenu.TWO: [
            Directions(SubMenu.ONE),
            Directions(command="2", response=Prompt.CONTINUE_PROMPT)
        ]
    })

    def setUp(self):
        """
        """
        self.callback_result = None

        def protocol_callback(self, arg):
            callback_result = arg

        # Call no longer valid. MenuInstrumentProtocol now takes 4 args.
        #self.protocol = MenuInstrumentProtocol(protocol_callback)

    @unittest.skip("SKIP - Not Written")
    def test_navigation(self):
        """
        Test the navigate method to get between menus
        """
        pass
Esempio n. 2
0
MENU = MenuInstrumentProtocol.MenuTree({
    SubMenu.MAIN:[],
    SubMenu.CHANGE_PARAM:[Directions(command=Command.CHANGE_PARAM,
                                     response=Prompt.CHANGE_PARAM_MENU)],
    SubMenu.SHOW_PARAM:[Directions(SubMenu.CHANGE_PARAM),
                        Directions(command=Command.SHOW_PARAM,
                                   response=Prompt.CONTINUE_PROMPT)],
    SubMenu.SENSOR_POWER:[Directions(command=Command.SENSOR_POWER,
                                     response=Prompt.SENSOR_POWER_MENU)],
    SubMenu.CYCLE_TIME:[Directions(SubMenu.CHANGE_PARAM),
                        Directions(command=Command.CHANGE_CYCLE_TIME,
                                     response=Prompt.CYCLE_TIME_PROMPT)],
    SubMenu.VERBOSE:[Directions(SubMenu.CHANGE_PARAM),
                        Directions(command=Command.CHANGE_VERBOSE,
                                     response=Prompt.VERBOSE_PROMPT)],
    SubMenu.METADATA_POWERUP:[Directions(SubMenu.CHANGE_PARAM),
                        Directions(command=Command.CHANGE_METADATA_POWERUP,
                                     response=Prompt.METADATA_PROMPT)],
    SubMenu.METADATA_RESTART:[Directions(SubMenu.CHANGE_PARAM),
                        Directions(command=Command.CHANGE_METADATA_RESTART,
                                     response=Prompt.METADATA_PROMPT)],
    SubMenu.RES_SENSOR_POWER:[Directions(SubMenu.SENSOR_POWER),
                        Directions(command=Command.CHANGE_RES_SENSOR_POWER,
                                     response=Prompt.SENSOR_POWER_MENU)],
    SubMenu.INST_AMP_POWER:[Directions(SubMenu.SENSOR_POWER),
                        Directions(command=Command.CHANGE_INST_AMP_POWER,
                                     response=Prompt.SENSOR_POWER_MENU)],
    SubMenu.EH_ISOLATION_AMP_POWER:[Directions(SubMenu.SENSOR_POWER),
                        Directions(command=Command.CHANGE_EH_ISOLATION_AMP_POWER,
                                     response=Prompt.SENSOR_POWER_MENU)],
    SubMenu.HYDROGEN_POWER:[Directions(SubMenu.SENSOR_POWER),
                        Directions(command=Command.CHANGE_HYDROGEN_POWER,
                                     response=Prompt.SENSOR_POWER_MENU)],
    SubMenu.REFERENCE_TEMP_POWER:[Directions(SubMenu.SENSOR_POWER),
                        Directions(command=Command.CHANGE_REFERENCE_TEMP_POWER,
                                     response=Prompt.SENSOR_POWER_MENU)],
})