def test_configured_callbacks(mocker, empty_config, widget_a, widget_b): module = SampleModule(config=empty_config, widgets=[widget_a, widget_b]) cmd = "sample-tool arg1 arg2 arg3" module.set("left-click", cmd) module.register_callbacks() cli = mocker.patch("core.input.util.cli") cli.execute.return_value = "" core.input.trigger({ "button": core.input.LEFT_MOUSE, "instance": module.id, }) cli.execute.assert_called_once_with(cmd, wait=False, shell=True)
def test_configured_callbacks(self): cfg = core.config.Config([]) module = TestModule(config=cfg, widgets=[self.someWidget, self.anotherWidget]) cmd = "sample-tool arg1 arg2 arg3" module.set("left-click", cmd) module.register_callbacks() with unittest.mock.patch("core.input.util.cli") as cli: cli.execute.return_value = "" core.input.trigger( {"button": core.input.LEFT_MOUSE, "instance": module.id,} ) cli.execute.assert_called_once_with(cmd, wait=False, shell=True)
def test_configured_callbacks_with_parameters(mocker, empty_config, widget_a): module = SampleModule(config=empty_config, widgets=[widget_a]) cmd = "sample-tool {instance} {name}" module.set("left-click", cmd) module.register_callbacks() cli = mocker.patch("core.input.util.cli") cli.execute.return_value = "" core.input.trigger({ "button": core.input.LEFT_MOUSE, "instance": module.id, "name": "sample-name", }) cli.execute.assert_called_once_with( cmd.format(instance=module.id, name="sample-name"), wait=False, shell=True, )
def test_configured_callbacks_with_parameters(self): cfg = core.config.Config([]) module = TestModule(config=cfg, widgets=[self.someWidget]) cmd = "sample-tool {instance} {name}" module.set("left-click", cmd) module.register_callbacks() with unittest.mock.patch("core.input.util.cli") as cli: cli.execute.return_value = "" core.input.trigger( { "button": core.input.LEFT_MOUSE, "instance": module.id, "name": "sample-name", } ) cli.execute.assert_called_once_with( cmd.format(instance=module.id, name="sample-name"), wait=False, shell=True, )