def test_commands_for_random_tips(mocker: MockerFixture) -> None: new_key_bindings: Dict[str, keys.KeyBinding] = { "ALPHA": { "keys": ["a"], "help_text": "alpha", "excluded_from_random_tips": True, }, "BETA": { "keys": ["b"], "help_text": "beta", "excluded_from_random_tips": False, }, "GAMMA": { "keys": ["g"], "help_text": "gamma", }, "DELTA": { "keys": ["d"], "help_text": "delta", "excluded_from_random_tips": True, }, } mocker.patch.dict(keys.KEY_BINDINGS, new_key_bindings, clear=True) result = keys.commands_for_random_tips() assert len(result) == 2 assert new_key_bindings["BETA"] in result assert new_key_bindings["GAMMA"] in result
def test_commands_for_random_tips(mocker): new_key_bindings = { 'ALPHA': { 'keys': {'a'}, 'help_text': 'alpha', 'excluded_from_random_tips': True, }, 'BETA': { 'keys': {'b'}, 'help_text': 'beta', 'excluded_from_random_tips': False, }, 'GAMMA': { 'keys': {'g'}, 'help_text': 'gamma', }, 'DELTA': { 'keys': {'d'}, 'help_text': 'delta', 'excluded_from_random_tips': True, }, } # type: Dict[str, keys.KeyBinding] mocker.patch.dict(keys.KEY_BINDINGS, new_key_bindings, clear=True) result = keys.commands_for_random_tips() assert len(result) == 2 assert new_key_bindings['BETA'] in result assert new_key_bindings['GAMMA'] in result
def get_random_help(self) -> List[Any]: # Get random allowed hotkey (ie. eligible for being displayed as a tip) allowed_commands = commands_for_random_tips() if not allowed_commands: return ['Help(?): ', ] random_command = random.choice(allowed_commands) return [ 'Help(?): ', ('code', ' ' + ', '.join(random_command['keys']) + ' '), ' ' + random_command['help_text'], ]
def get_random_help(self) -> List[Any]: # Get random allowed hotkey (ie. eligible for being displayed as a tip) allowed_commands = commands_for_random_tips() if not allowed_commands: return ["Help(?): "] random_command = random.choice(allowed_commands) return [ "Help(?): ", ("footer_contrast", " " + ", ".join(random_command["keys"]) + " "), " " + random_command["help_text"], ]
def test_HELP_is_not_allowed_as_tip() -> None: assert keys.KEY_BINDINGS["HELP"]["excluded_from_random_tips"] is True assert keys.KEY_BINDINGS["HELP"] not in keys.commands_for_random_tips()
def test_HELP_is_not_allowed_as_tip(): assert (keys.KEY_BINDINGS['HELP']['excluded_from_random_tips'] is True) assert (keys.KEY_BINDINGS['HELP'] not in keys.commands_for_random_tips())