Ejemplo n.º 1
0
 def test_delete_kudos_list(self, testbot):
     push_message('!sijis++')
     assert 'kudos updated for sijis' in pop_message()
     push_message('!tom++')
     assert 'kudos updated for tom' in pop_message()
     push_message('!kudos list')
     assert 'sijis, tom' in pop_message()
Ejemplo n.º 2
0
 def test_delete_karma_list(self, testbot):
     push_message("!sijis++")
     assert "karma updated for sijis" in pop_message()
     push_message("!tom++")
     assert "karma updated for tom" in pop_message()
     push_message("!karma list")
     assert "sijis, tom" in pop_message()
Ejemplo n.º 3
0
    def test_help(self):
        push_message('!help ErrBot')
        response = pop_message()
        self.assertIn('Available commands for ErrBot', response)
        self.assertIn('!about', response)

        push_message('!help beurk')
        self.assertEqual('That command is not defined.', pop_message())
Ejemplo n.º 4
0
    def test_help(self):
        push_message('!help ErrBot')
        response = pop_message()
        self.assertIn('Available commands for ErrBot', response)
        self.assertIn('!about', response)

        push_message('!help beurk')
        self.assertEqual('That command is not defined.', pop_message())
Ejemplo n.º 5
0
def webserver(testbot):
    push_message(
        "!config Webserver {{'HOST': 'localhost', 'PORT': {}, 'SSL':  None}}".
        format(WEBSERVER_PORT))
    pop_message()
    while not webserver_ready('localhost', WEBSERVER_PORT):
        logging.debug("Webserver not ready yet, sleeping 0.1 second")
        sleep(0.1)
Ejemplo n.º 6
0
    def test_botcommands(self, testbot):
        from errbot import holder
        rooms = holder.bot.rooms()
        room = holder.bot.query_room('*****@*****.**')
        assert len(rooms) == 1
        assert rooms[0] == room

        assert room.joined
        push_message("!room leave [email protected]")
        assert pop_message() == "Left the room [email protected]"
        room = holder.bot.query_room('*****@*****.**')
        assert not room.joined

        push_message("!room list")
        assert pop_message() == "I'm not currently in any rooms."

        push_message("!room destroy [email protected]")
        assert pop_message() == "Destroyed the room [email protected]"
        rooms = holder.bot.rooms()
        room = holder.bot.query_room('*****@*****.**')
        assert not room.exists
        assert room not in rooms

        push_message("!room create [email protected]")
        assert pop_message() == "Created the room [email protected]"
        rooms = holder.bot.rooms()
        room = holder.bot.query_room('*****@*****.**')
        assert room.exists
        assert room not in rooms
        assert not room.joined

        push_message("!room join [email protected]")
        assert pop_message() == "Joined the room [email protected]"
        rooms = holder.bot.rooms()
        room = holder.bot.query_room('*****@*****.**')
        assert room.exists
        assert room.joined
        assert room in rooms

        push_message("!room list")
        assert pop_message(
        ) == "I'm currently in these rooms:\n\[email protected]"

        push_message("!room occupants [email protected]")
        assert pop_message(
        ) == "Occupants in [email protected]:\n\terr@localhost"

        push_message("!room topic [email protected]")
        assert pop_message() == "No topic is set for [email protected]"
        push_message("!room topic [email protected] 'Err rocks!'")
        assert pop_message() == "Topic for [email protected] set."
        push_message("!room topic [email protected]")
        assert pop_message(
        ) == "Topic for [email protected]: Err rocks!"
Ejemplo n.º 7
0
    def test_backup(self):
        push_message('!repos install git://github.com/gbin/err-helloworld.git')
        self.assertIn('err-helloworld', pop_message(timeout=60))
        self.assertIn('reload', pop_message())
        push_message('!backup')
        msg = pop_message()
        self.assertIn('has been written in', msg)
        filename = re.search(r"'([A-Za-z0-9_\./\\-]*)'", msg).group(1)
        # At least the backup should mention the installed plugin

        self.assertIn('err-helloworld', open(filename).read())
        push_message('!repos uninstall err-helloworld')
Ejemplo n.º 8
0
    def test_botcommands(self, testbot):
        from errbot import holder
        rooms = holder.bot.rooms()
        room = holder.bot.query_room('*****@*****.**')
        assert len(rooms) == 1
        assert rooms[0] == room

        assert room.joined
        push_message("!room leave [email protected]")
        assert pop_message() == "Left the room [email protected]"
        room = holder.bot.query_room('*****@*****.**')
        assert not room.joined

        push_message("!room list")
        assert pop_message() == "I'm not currently in any rooms."

        push_message("!room destroy [email protected]")
        assert pop_message() == "Destroyed the room [email protected]"
        rooms = holder.bot.rooms()
        room = holder.bot.query_room('*****@*****.**')
        assert not room.exists
        assert room not in rooms

        push_message("!room create [email protected]")
        assert pop_message() == "Created the room [email protected]"
        rooms = holder.bot.rooms()
        room = holder.bot.query_room('*****@*****.**')
        assert room.exists
        assert room not in rooms
        assert not room.joined

        push_message("!room join [email protected]")
        assert pop_message() == "Joined the room [email protected]"
        rooms = holder.bot.rooms()
        room = holder.bot.query_room('*****@*****.**')
        assert room.exists
        assert room.joined
        assert room in rooms

        push_message("!room list")
        assert pop_message() == "I'm currently in these rooms:\n\[email protected]"

        push_message("!room occupants [email protected]")
        assert pop_message() == "Occupants in [email protected]:\n\terr@localhost"

        push_message("!room topic [email protected]")
        assert pop_message() == "No topic is set for [email protected]"
        push_message("!room topic [email protected] 'Err rocks!'")
        assert pop_message() == "Topic for [email protected] set."
        push_message("!room topic [email protected]")
        assert pop_message() == "Topic for [email protected]: Err rocks!"
Ejemplo n.º 9
0
    def test_unblacklist_and_blacklist(self):
        push_message('!unblacklist nosuchplugin')
        m = pop_message()
        self.assertIn("nosuchplugin isn't a valid plugin name. The current plugins are", m)
        self.assertIn('ChatRoom', m)

        push_message('!blacklist nosuchplugin')
        m = pop_message()
        self.assertIn("nosuchplugin isn't a valid plugin name. The current plugins are", m)
        self.assertIn('ChatRoom', m)

        push_message('!blacklist ChatRoom')
        self.assertEqual("Plugin ChatRoom is now blacklisted", pop_message())

        push_message('!blacklist ChatRoom')
        self.assertEqual("Plugin ChatRoom is already blacklisted", pop_message())

        push_message("!status plugins")
        self.assertIn("[B,L] ChatRoom", pop_message())

        push_message('!unblacklist ChatRoom')
        self.assertEqual('Plugin ChatRoom removed from blacklist', pop_message())

        push_message('!unblacklist ChatRoom')
        self.assertEqual('Plugin ChatRoom is not blacklisted', pop_message())

        push_message("!status plugins")
        self.assertIn("[L] ChatRoom", pop_message())
Ejemplo n.º 10
0
    def test_unblacklist_and_blacklist(self):
        push_message('!unblacklist nosuchplugin')
        m = pop_message()
        self.assertIn("nosuchplugin isn't a valid plugin name. The current plugins are", m)
        self.assertIn('ChatRoom', m)

        push_message('!blacklist nosuchplugin')
        m = pop_message()
        self.assertIn("nosuchplugin isn't a valid plugin name. The current plugins are", m)
        self.assertIn('ChatRoom', m)

        push_message('!blacklist ChatRoom')
        self.assertEqual("Plugin ChatRoom is now blacklisted", pop_message())

        push_message('!blacklist ChatRoom')
        self.assertEqual("Plugin ChatRoom is already blacklisted", pop_message())

        push_message("!status plugins")
        self.assertIn("[B,L] ChatRoom", pop_message())

        push_message('!unblacklist ChatRoom')
        self.assertEqual('Plugin ChatRoom removed from blacklist', pop_message())

        push_message('!unblacklist ChatRoom')
        self.assertEqual('Plugin ChatRoom is not blacklisted', pop_message())

        push_message("!status plugins")
        self.assertIn("[L] ChatRoom", pop_message())
Ejemplo n.º 11
0
 def test_whos_out(self, testbot):
     push_message("who's out?")
     msg = pop_message(0.2)
     assert len(msg) > 0
     assert 'Sarah Skiver:' in msg
     assert 'Charlie Brown:' in msg
     print(msg)
Ejemplo n.º 12
0
    def test_config_cycle(self):
        push_message('!config Webserver')
        m = pop_message()
        self.assertIn('Default configuration for this plugin (you can copy and paste this directly as a command)', m)
        self.assertNotIn('Current configuration', m)

        push_message("!config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}")
        self.assertIn('Plugin configuration done.', pop_message())

        push_message('!config Webserver')
        m = pop_message()
        self.assertIn('Current configuration', m)
        self.assertIn('localhost', m)

        push_message('!config Webserver')
        self.assertIn('localhost', pop_message())
Ejemplo n.º 13
0
    def test_mycommand_tellme_something_returns_random_output(self):
        p = get_plugin_obj_by_name('GarakBot')
        fp = StringIO(json.dumps(self.random_quotes2))
        p.garak_quote_ds = fp
        p.clear_garak_quote_datasource()
        push_message('! tellme something')
        a = pop_message()
        push_message('! tellme something')
        b = pop_message()
        push_message('! tellme something')
        c = pop_message()

        assert a is not None
        assert b is not None
        assert c is not None
        assert a != b != c
Ejemplo n.º 14
0
 def test_mycommand_tellme_something_returns_expected_output(self):
     p = get_plugin_obj_by_name('GarakBot')
     fp = StringIO(json.dumps(self.random_quotes))
     p.garak_quote_ds = fp
     p.clear_garak_quote_datasource()
     push_message('! tellme something')
     self.assertRegex(pop_message(), r'^\w+ Quote!')
Ejemplo n.º 15
0
    def test_config_cycle(self):
        # test the full configuration cycle help, get set and export, import
        push_message('!zap configs')
        self.assertIn('Done', pop_message())

        push_message('!config Webserver')
        m = pop_message()
        self.assertIn('Default configuration for this plugin (you can copy and paste this directly as a command)', m)
        self.assertNotIn('Current configuration', m)

        push_message("!config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}")
        self.assertIn('Plugin configuration done.', pop_message())

        push_message('!config Webserver')
        m = pop_message()
        self.assertIn('Current configuration', m)
        self.assertIn('localhost', m)

        push_message('!export configs')
        configs = pop_message()
        self.assertIn('localhost', configs)
        obj = literal_eval(configs)  # be sure it is parseable
        obj['Webserver']['HOST'] = 'localhost'

        push_message('!import configs ' + repr(obj))
        self.assertIn('Import is done correctly', pop_message())

        push_message('!config Webserver')
        self.assertIn('localhost', pop_message())
Ejemplo n.º 16
0
    def test_config_cycle(self):
        # test the full configuration cycle help, get set and export, import
        push_message('!zap configs')
        self.assertIn('Done', pop_message())

        push_message('!config Webserver')
        m = pop_message()
        self.assertIn('Default configuration for this plugin (you can copy and paste this directly as a command)', m)
        self.assertNotIn('Current configuration', m)

        push_message("!config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}")
        self.assertIn('Plugin configuration done.', pop_message())

        push_message('!config Webserver')
        m = pop_message()
        self.assertIn('Current configuration', m)
        self.assertIn('localhost', m)

        push_message('!export configs')
        configs = pop_message()
        self.assertIn('localhost', configs)
        obj = literal_eval(configs)  # be sure it is parseable
        obj['Webserver']['HOST'] = 'localhost'

        push_message('!import configs ' + repr(obj))
        self.assertIn('Import is done correctly', pop_message())

        push_message('!config Webserver')
        self.assertIn('localhost', pop_message())
Ejemplo n.º 17
0
    def test_time(self, testbot):
        push_message('!time Uranus')
        assert 'Mine is well...What about in yours?' in pop_message()

#    def test_location(self, testbot):
 #       push_message('!location set Interwebs')
#        assert 'Ok, None, trying to set your location to Interwebs' in pop_message()
#        assert self['None'] == 'Interwebs'
#        assert 0
Ejemplo n.º 18
0
    def test_coffeetime_muc(self, patch_msg_type, testbot):
        """TODO:
        Also test the other message if more than 1 user is present
        Unfortunately I was not able to patch this correctly yet."""

        push_message('!coffeetime')
        assert ("You are the only online person in the group :( \n"
                "What about getting your own coffee?"
                ) in pop_message()
Ejemplo n.º 19
0
def check_reply(expected):
    try:
        msg = pop_message(0.1)
    except queue.Empty:
        pytest.fail('No reply when expecting: ' + expected)
    assert len(msg) > 0
    if type(expected) == str:
        expected = [expected]
    for e in expected:
        assert e in msg
    check_no_further_reply(msg)
Ejemplo n.º 20
0
def check_reply(expected):
    try:
        msg = pop_message(0.1)
    except queue.Empty:
        pytest.fail('No reply when expecting: ' + str(expected))
    assert len(msg) > 0
    if 'Computer says nooo' in msg:
        pytest.fail('Error message received when expecting: ' + str(expected))
    if type(expected) == str:
        expected = [expected]
    for e in expected:
        assert e in msg
    check_no_further_reply(msg)
Ejemplo n.º 21
0
    def test_history(self):
        push_message('!uptime')
        pop_message()
        push_message('!history')
        self.assertIn('uptime', pop_message())

        orig_sender = self.bot.sender
        try:
            # Pretend to be someone else. History should be empty
            self.bot.sender = 'non_default_person@localhost'
            push_message('!history')
            self.assertRaises(Empty, pop_message, block=False)
            push_message('!echo should be a separate history')
            pop_message()
            push_message('!history')
            self.assertIn('should be a separate history', pop_message())
        finally:
            self.bot.sender = orig_sender
        # Pretend to be the original person again. History should still contain uptime
        push_message('!history')
        self.assertIn('uptime', pop_message())
Ejemplo n.º 22
0
    def test_history(self):
        from errbot.holder import bot

        push_message('!uptime')
        pop_message()
        push_message('!history')
        self.assertIn('uptime', pop_message())

        orig_sender = bot.sender
        try:
            # Pretend to be someone else. History should be empty
            bot.sender = 'non_default_person@localhost'
            push_message('!history')
            self.assertRaises(Empty, pop_message, block=False)
            push_message('!echo should be seperate history')
            pop_message()
            push_message('!history')
            self.assertIn('should be seperate history', pop_message())
        finally:
            bot.sender = orig_sender
        # Pretend to be the original person again. History should still contain uptime
        push_message('!history')
        self.assertIn('uptime', pop_message())
Ejemplo n.º 23
0
    def test_generate_certificate_creates_usable_cert(self):
        from config import BOT_DATA_DIR
        key_path = os.sep.join((BOT_DATA_DIR, "webserver_key.pem"))
        cert_path = os.sep.join((BOT_DATA_DIR, "webserver_certificate.pem"))

        push_message("!generate_certificate")
        assert "Generating" in pop_message(timeout=1)

        # Generating a certificate could be slow on weak hardware, so keep a safe
        # timeout on the first pop_message()
        assert "successfully generated" in pop_message(timeout=60)
        assert "is recommended" in pop_message(timeout=1)
        assert key_path in pop_message(timeout=1)

        webserver_config = {
            'HOST': 'localhost',
            'PORT': WEBSERVER_PORT,
            'SSL': {
                'certificate': cert_path,
                'key': key_path,
                'host': 'localhost',
                'port': WEBSERVER_SSL_PORT,
                'enabled': True,
            }
        }
        push_message("!config Webserver {!r}".format(webserver_config))
        pop_message()

        while not webserver_ready('localhost', WEBSERVER_SSL_PORT):
            log.debug("Webserver not ready yet, sleeping 0.1 second")
            sleep(0.1)

        assert requests.post(
            'https://localhost:{}/webhook1/'.format(WEBSERVER_SSL_PORT),
            JSONOBJECT,
            verify=False
        ).text == repr(json.loads(JSONOBJECT))
Ejemplo n.º 24
0
    def test_generate_certificate_creates_usable_cert(self):
        from config import BOT_DATA_DIR
        key_path = os.sep.join((BOT_DATA_DIR, "webserver_key.pem"))
        cert_path = os.sep.join((BOT_DATA_DIR, "webserver_certificate.pem"))

        push_message("!generate_certificate")
        assert "Generating" in pop_message(timeout=1)

        # Generating a certificate could be slow on weak hardware, so keep a safe
        # timeout on the first pop_message()
        assert "successfully generated" in pop_message(timeout=60)
        assert "is recommended" in pop_message(timeout=1)
        assert key_path in pop_message(timeout=1)

        webserver_config = {
            'HOST': 'localhost',
            'PORT': WEBSERVER_PORT,
            'SSL': {
                'certificate': cert_path,
                'key': key_path,
                'host': 'localhost',
                'port': WEBSERVER_SSL_PORT,
                'enabled': True,
            }
        }
        push_message("!config Webserver {!r}".format(webserver_config))
        pop_message()

        while not webserver_ready('localhost', WEBSERVER_SSL_PORT):
            logging.debug("Webserver not ready yet, sleeping 0.1 second")
            sleep(0.1)

        assert requests.post(
            'https://localhost:{}/webhook1/'.format(WEBSERVER_SSL_PORT),
            JSONOBJECT,
            verify=False
        ).text == repr(json.loads(JSONOBJECT))
Ejemplo n.º 25
0
 def test_ping(self, testbot):
     push_message('!ping')
     assert 'pong' in pop_message()
Ejemplo n.º 26
0
 def test_webserver_webhook_test(self):
     push_message("!config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}")
     self.assertIn('Plugin configuration done.', pop_message())
     self.assertCommand("!webhook test /echo/ toto", 'Status code : 200')
Ejemplo n.º 27
0
    def test_load_reload_and_unload(self):
        for command in ('load', 'reload', 'unload'):
            push_message("!{}".format(command))
            m = pop_message()
            self.assertIn('Please tell me which of the following plugins to reload', m)
            self.assertIn('ChatRoom', m)

            push_message('!{} nosuchplugin'.format(command))
            m = pop_message()
            self.assertIn("nosuchplugin isn't a valid plugin name. The current plugins are", m)
            self.assertIn('ChatRoom', m)

        push_message('!reload ChatRoom')
        self.assertEqual('Plugin ChatRoom deactivated', pop_message())
        self.assertEqual('Plugin ChatRoom activated', pop_message())

        push_message("!status plugins")
        self.assertIn("[L] ChatRoom", pop_message())

        push_message('!unload ChatRoom')
        self.assertEqual('Plugin ChatRoom deactivated', pop_message())

        push_message("!status plugins")
        self.assertIn("[U] ChatRoom", pop_message())

        push_message('!unload ChatRoom')
        self.assertEqual('ChatRoom is not currently loaded', pop_message())

        push_message('!load ChatRoom')
        self.assertEqual('Plugin ChatRoom activated', pop_message())

        push_message("!status plugins")
        self.assertIn("[L] ChatRoom", pop_message())

        push_message('!load ChatRoom')
        self.assertEqual('ChatRoom is already loaded', pop_message())

        push_message('!unload ChatRoom')
        self.assertEqual('Plugin ChatRoom deactivated', pop_message())
        push_message('!reload ChatRoom')
        self.assertEqual('Plugin ChatRoom not in active list', pop_message())
        self.assertEqual('Plugin ChatRoom activated', pop_message())

        push_message('!blacklist ChatRoom')
        self.assertEqual("Plugin ChatRoom is now blacklisted", pop_message())

        push_message("!status plugins")
        self.assertIn("[B,L] ChatRoom", pop_message())

        # Needed else configuration for this plugin gets saved which screws up
        # other tests
        push_message('!unblacklist ChatRoom')
        pop_message()
Ejemplo n.º 28
0
 def test_root_help(self):
     push_message('!help')
     self.assertIn('Available help', pop_message())
Ejemplo n.º 29
0
 def test_encoding_preservation(self):
     push_message('!echo へようこそ')
     self.assertEquals('へようこそ', pop_message())
Ejemplo n.º 30
0
 def test_webserver_plugin_ok(self, testbot):
     push_message("!webstatus")
     assert "/echo/" in pop_message()
Ejemplo n.º 31
0
 def test_logtail(self):
     push_message('!log tail')
     self.assertIn('DEBUG', pop_message())
Ejemplo n.º 32
0
 def test_status(self):
     push_message('!status')
     self.assertIn('Yes I am alive', pop_message())
Ejemplo n.º 33
0
 def test_status_load(self):
     push_message('!status load')
     self.assertIn('Load ', pop_message())
Ejemplo n.º 34
0
    def test_load_reload_and_unload(self):
        for command in ('load', 'reload', 'unload'):
            push_message("!{}".format(command))
            m = pop_message()
            self.assertIn('Please tell me which of the following plugins to reload', m)
            self.assertIn('ChatRoom', m)

            push_message('!{} nosuchplugin'.format(command))
            m = pop_message()
            self.assertIn("nosuchplugin isn't a valid plugin name. The current plugins are", m)
            self.assertIn('ChatRoom', m)

        push_message('!reload ChatRoom')
        self.assertEqual('Plugin ChatRoom deactivated', pop_message())
        self.assertEqual('Plugin ChatRoom activated', pop_message())

        push_message("!status plugins")
        self.assertIn("[L] ChatRoom", pop_message())

        push_message('!unload ChatRoom')
        self.assertEqual('Plugin ChatRoom deactivated', pop_message())

        push_message("!status plugins")
        self.assertIn("[U] ChatRoom", pop_message())

        push_message('!unload ChatRoom')
        self.assertEqual('ChatRoom is not currently loaded', pop_message())

        push_message('!load ChatRoom')
        self.assertEqual('Plugin ChatRoom activated', pop_message())

        push_message("!status plugins")
        self.assertIn("[L] ChatRoom", pop_message())

        push_message('!load ChatRoom')
        self.assertEqual('ChatRoom is already loaded', pop_message())

        push_message('!unload ChatRoom')
        self.assertEqual('Plugin ChatRoom deactivated', pop_message())
        push_message('!reload ChatRoom')
        self.assertEqual('Plugin ChatRoom not in active list', pop_message())
        self.assertEqual('Plugin ChatRoom activated', pop_message())

        push_message('!blacklist ChatRoom')
        self.assertEqual("Plugin ChatRoom is now blacklisted", pop_message())

        push_message("!status plugins")
        self.assertIn("[B,L] ChatRoom", pop_message())

        # Needed else configuration for this plugin gets saved which screws up
        # other tests
        push_message('!unblacklist ChatRoom')
        pop_message()
Ejemplo n.º 35
0
 def test_about(self):
     push_message('!about')
     self.assertIn('Err version', pop_message())
Ejemplo n.º 36
0
 def test_status_load(self):
     push_message('!status load')
     self.assertIn('Load ', pop_message())
Ejemplo n.º 37
0
 def test_about(self):
     push_message('!about')
     self.assertIn('Err version', pop_message())
Ejemplo n.º 38
0
 def test_uptime(self):
     push_message('!uptime')
     self.assertIn('I\'ve been up for', pop_message())
Ejemplo n.º 39
0
 def test_status_gc(self):
     push_message('!status gc')
     self.assertIn('GC 0->', pop_message())
Ejemplo n.º 40
0
 def test_apropos(self):
     push_message('!apropos about')
     self.assertIn('!about: Returns some', pop_message())
Ejemplo n.º 41
0
 def test_uptime(self):
     push_message('!uptime')
     self.assertIn('I\'ve been up for', pop_message())
Ejemplo n.º 42
0
    def test_plugin_cycle(self):
        push_message('!repos install git://github.com/gbin/err-helloworld.git')
        self.assertIn('err-helloworld', pop_message(timeout=60))
        self.assertIn('reload', pop_message())

        push_message('!help hello')  # should appear in the help
        self.assertEqual("this command says hello", pop_message())

        push_message('!hello')  # should respond
        self.assertEqual('Hello World !', pop_message())

        push_message('!reload HelloWorld')
        self.assertEqual('Plugin HelloWorld deactivated', pop_message())
        self.assertEqual('Plugin HelloWorld activated', pop_message())

        push_message('!hello')  # should still respond
        self.assertEqual('Hello World !', pop_message())

        push_message('!blacklist HelloWorld')
        self.assertEqual('Plugin HelloWorld is now blacklisted', pop_message())
        push_message('!unload HelloWorld')
        self.assertEqual('Plugin HelloWorld deactivated', pop_message())

        push_message('!hello')  # should not respond
        self.assertIn('Command "hello" not found', pop_message())

        push_message('!unblacklist HelloWorld')
        self.assertEqual('Plugin HelloWorld removed from blacklist', pop_message())
        push_message('!load HelloWorld')
        self.assertEqual('Plugin HelloWorld activated', pop_message())

        push_message('!hello')  # should respond back
        self.assertEqual('Hello World !', pop_message())

        push_message('!repos uninstall err-helloworld')
        self.assertEqual('/me is unloading plugin HelloWorld', pop_message())
        self.assertEqual('Plugins unloaded and repo err-helloworld removed', pop_message())

        push_message('!hello')  # should not respond
        self.assertIn('Command "hello" not found', pop_message())
Ejemplo n.º 43
0
 def test_status_plugins(self):
     push_message('!status plugins')
     self.assertIn('L=Loaded, U=Unloaded', pop_message())
Ejemplo n.º 44
0
 def test_status_plugins(self):
     push_message('!status plugins')
     self.assertIn('L=Loaded, U=Unloaded', pop_message())
Ejemplo n.º 45
0
 def test_status_gc(self):
     push_message('!status gc')
     self.assertIn('GC 0->', pop_message())
Ejemplo n.º 46
0
 def test_encoding_preservation(self):
     push_message('!echo へようこそ')
     self.assertEquals('へようこそ', pop_message())
Ejemplo n.º 47
0
 def test_apropos(self):
     push_message('!apropos about')
     self.assertIn('!about: Returns some', pop_message())
Ejemplo n.º 48
0
    def test_plugin_cycle(self):
        push_message('!repos install git://github.com/gbin/err-helloworld.git')
        self.assertIn('err-helloworld', pop_message(timeout=60))
        self.assertIn('reload', pop_message())

        push_message('!repos export')  # should appear in the export
        self.assertEqual("{'err-helloworld': 'git://github.com/gbin/err-helloworld.git'}", pop_message())

        push_message('!help hello')  # should appear in the help
        self.assertEqual("this command says hello", pop_message())

        push_message('!hello')  # should respond
        self.assertEqual('Hello World !', pop_message())

        push_message('!reload HelloWorld')
        self.assertEqual('Plugin HelloWorld deactivated', pop_message())
        self.assertEqual('Plugin HelloWorld activated', pop_message())

        push_message('!hello')  # should still respond
        self.assertEqual('Hello World !', pop_message())

        push_message('!blacklist HelloWorld')
        self.assertEqual('Plugin HelloWorld is now blacklisted', pop_message())
        push_message('!unload HelloWorld')
        self.assertEqual('Plugin HelloWorld deactivated', pop_message())

        push_message('!hello')  # should not respond
        self.assertIn('Command "hello" not found', pop_message())

        push_message('!unblacklist HelloWorld')
        self.assertEqual('Plugin HelloWorld removed from blacklist', pop_message())
        push_message('!load HelloWorld')
        self.assertEqual('Plugin HelloWorld activated', pop_message())

        push_message('!hello')  # should respond back
        self.assertEqual('Hello World !', pop_message())

        push_message('!repos uninstall err-helloworld')
        self.assertEqual('/me is unloading plugin HelloWorld', pop_message())
        self.assertEqual('Plugins unloaded and repo err-helloworld removed', pop_message())

        push_message('!hello')  # should not respond
        self.assertIn('Command "hello" not found', pop_message())
Ejemplo n.º 49
0
 def test_webserver_webhook_test(self):
     push_message("!config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}")
     self.assertIn('Plugin configuration done.', pop_message())
     self.assertCommand("!webhook test /echo/ toto", 'Status code : 200')
Ejemplo n.º 50
0
 def test_logtail(self):
     push_message('!log tail')
     self.assertIn('DEBUG', pop_message())
Ejemplo n.º 51
0
 def test_root_help(self):
     push_message('!help')
     self.assertIn('Available help', pop_message())
Ejemplo n.º 52
0
 def test_status(self):
     push_message('!status')
     self.assertIn('Yes I am alive', pop_message())