Exemple #1
0
 def test_demo_parent_button_default(self):
     # Make sure the parent button behaves in the default state.
     # This ensures the enable flag can be computed (instead of crashing),
     # and the action allowed by it does not crash.
     demo = Demo(model=DemoPath())
     if get_action_enabled(parent_tool, demo):
         demo.perform(None, parent_tool, None)
Exemple #2
0
    def test_demo_init_no_children_to_be_set(self):
        # Test if there are no children, nothing is selected.
        model = DemoVirtualDirectory(resources=[])
        demo = Demo(model=model)
        demo.selected_node = None

        # when
        info = UIInfo(ui=UI(handler=Handler()))
        demo.init(info)

        # then
        self.assertIsNone(demo.selected_node)
Exemple #3
0
    def test_demo_init_set_children(self):
        # Test if there are children, the first one will be selected.
        resources = [DemoPath(), DemoPath()]
        model = DemoVirtualDirectory(resources=resources)
        demo = Demo(model=model)
        demo.selected_node = None

        # when
        info = UIInfo(ui=UI(handler=Handler()))
        demo.init(info)

        # then
        self.assertIs(demo.selected_node, resources[0])
Exemple #4
0
def _create_demo(infos=None, title=_TITLE):
    """ Create the demo object with everything setup ready to be launched.

    Parameters
    ----------
    infos : list of dict, or None
        List of responses specifying the demo resources.
        Each response is a dictionary, in the format as specified by an
        entry point.
        If none, then responses are loaded from existing entry points installed
        in the Python environment.
    title : str, optional
        Default application title.

    Returns
    -------
    demo : Demo
    """
    if infos is None:
        infos = get_responses()

    resources = [response_to_node(response) for response in infos]
    logger.info("Found %r resource(s).", len(resources))
    return Demo(
        title=title,
        model=DemoVirtualDirectory(resources=resources),
    )