def enable(): """Enable wild pokemon spawning and chatter in channel""" if nick == chan: return "Use in a channel" elif not chan in enabledChans: enabledChans.append(chan) return colors.get_color('green')+"Texemon enabled in {}".format(chan) else: return colors.get_color('yellow')+"Texemon already enabled in {}".format(chan)
def disable(): """Disable wild pokemon spawning and chatter in channel""" if nick == chan: return "Use in a channel" elif chan in enabledChans: enabledChans.remove(chan) return colors.get_color('red')+"Texemon disabled in {}".format(chan) else: return colors.get_color('green')+"Texemon is not enabled, nothing to disable in {}".format(chan)
def test_get_random_color(): assert get_color("random") in ["\x03" + i for i in IRC_COLOUR_DICT.values()] assert get_color("random", return_formatted=False) in list(IRC_COLOUR_DICT.values()) with mock.patch( 'cloudbot.util.colors.randint', return_value=4 # chosen by fair dice roll, guranteed to be random. ): assert get_color('random') == '\x0304'
def test_get_random_color(): assert get_color("random") in ["\x03" + i for i in IRC_COLOUR_DICT.values()] assert get_color("random", return_formatted=False) in list(IRC_COLOUR_DICT.values())
def test_get_color(): assert get_color("red") == "\x0304" assert get_color("red", return_formatted=False) == "04"
def test_invalid_color(): with pytest.raises(KeyError) as excinfo: get_color("cake") assert 'not in the list of available colours' in str(excinfo.value)
def test_get_random_color(): assert get_color("random") in [ "\x03" + i for i in IRC_COLOUR_DICT.values() ] assert get_color("random", return_formatted=False) in list(IRC_COLOUR_DICT.values())