コード例 #1
0
    def test_generate_certificate_creates_usable_cert(self):
        key_path = os.sep.join((BOT_DATA_DIR, "webserver_key.pem"))
        cert_path = os.sep.join((BOT_DATA_DIR, "webserver_certificate.pem"))

        pushMessage("!generate_certificate")
        self.assertTrue("Generating" in popMessage(timeout=1))

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

        pushMessage(
            "!config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL': {'certificate': '%s', 'key': '%s', 'host': 'localhost', 'port': 3142, 'enabled': True}}"
            % (cert_path, key_path))
        popMessage()

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

        self.assertEquals(
            requests.post('https://localhost:3142/webhook1/',
                          JSONOBJECT,
                          verify=False).text, repr(json.loads(JSONOBJECT)))
コード例 #2
0
ファイル: commands_tests.py プロジェクト: avallark/err
    def test_help(self):
        pushMessage('!help ErrBot')
        response = popMessage()
        self.assertIn('Available commands for ErrBot', response)
        self.assertIn('!about', response)

        pushMessage('!help beurk')
        self.assertEqual('That command is not defined.', popMessage())
コード例 #3
0
 def test_calculate(self):
     """Test calculate command
     """
     pushMessage('!calculate 1+2')
     self.assertEqual(popMessage(), '3')
     
     pushMessage('!calculate 1+2*(5-1)')
     self.assertEqual(popMessage(), '9')
コード例 #4
0
ファイル: commands_tests.py プロジェクト: sanketsudake/err
    def test_help(self):
        pushMessage('!help ErrBot')
        response = popMessage()
        self.assertIn('Available commands for ErrBot', response)
        self.assertIn('!about', response)

        pushMessage('!help beurk')
        self.assertEqual('That command is not defined.', popMessage())
コード例 #5
0
ファイル: webhooks_tests.py プロジェクト: DazWorrall/err
    def setUp(self, extra_test_file=None):
        plugin_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep + 'webhooks_tests'
        super(TestWebhooks, TestWebhooks).setUp(self, extra_test_file=plugin_dir)

        pushMessage("!config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}")
        popMessage()
        while not webserver_ready('localhost', 3141):
            logging.debug("Webserver not ready yet, sleeping 0.1 second")
            sleep(0.1)
コード例 #6
0
    def setUpClass(cls, extra_test_file=None):
        plugin_dir = os.path.dirname(
            os.path.realpath(__file__)) + os.sep + 'webhooks_tests'
        super(TestWebhooks, cls).setUpClass(extra_test_file=plugin_dir)

        pushMessage(
            "!config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}"
        )
        popMessage()
        while not webserver_ready('localhost', 3141):
            logging.debug("Webserver not ready yet, sleeping 0.1 second")
            sleep(0.1)
コード例 #7
0
ファイル: tests.py プロジェクト: foxxyz/bookiebot
	def test_end_match(self):
		pushMessage('!start match Honduras vs. Poland')
		popMessage()
		pushMessage('!score 1-1 Honduras')
		popMessage()
		pushMessage('!end match 0-0 Honduras')
		self.assertIn('Closed match', popMessage())
		pushMessage('!scoreboard')
		self.assertIn('gbin:1', popMessage())
コード例 #8
0
ファイル: webhooks_tests.py プロジェクト: DazWorrall/err
    def test_generate_certificate_creates_usable_cert(self):
        key_path = os.sep.join((BOT_DATA_DIR, "webserver_key.pem"))
        cert_path = os.sep.join((BOT_DATA_DIR, "webserver_certificate.pem"))

        pushMessage("!generate_certificate")
        self.assertTrue("Generating" in popMessage(timeout=1))

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

        pushMessage("!config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL': {'certificate': '%s', 'key': '%s', 'host': 'localhost', 'port': 3142, 'enabled': True}}" % (cert_path, key_path))
        popMessage()

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

        self.assertEquals(
            requests.post('https://localhost:3142/webhook1/', JSONOBJECT, verify=False).text,
            repr(json.loads(JSONOBJECT))
        )
コード例 #9
0
ファイル: commands_tests.py プロジェクト: avallark/err
    def test_plugin_cycle(self):
        pushMessage('!repos install git://github.com/gbin/err-helloworld.git')
        self.assertIn('err-helloworld', popMessage())
        self.assertIn('reload', popMessage())

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

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

        pushMessage('!hello')  # should respond
        self.assertEqual('Hello World !', popMessage())

        pushMessage('!reload HelloWorld')
        self.assertEqual('Plugin HelloWorld deactivated / Plugin HelloWorld activated', popMessage())

        pushMessage('!hello')  # should still respond
        self.assertEqual('Hello World !', popMessage())

        pushMessage('!unload HelloWorld')
        self.assertEqual('Plugin HelloWorld deactivated', popMessage())

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

        pushMessage('!load HelloWorld')
        self.assertEqual('Plugin HelloWorld activated', popMessage())

        pushMessage('!hello')  # should respond back
        self.assertEqual('Hello World !', popMessage())

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

        pushMessage('!hello')  # should not respond
        self.assertIn('Command "hello" not found', popMessage())
コード例 #10
0
ファイル: commands_tests.py プロジェクト: avallark/err
 def test_apropos(self):
     pushMessage('!apropos about')
     self.assertIn('!about: Returns some', popMessage())
コード例 #11
0
ファイル: commands_tests.py プロジェクト: avallark/err
    def test_history(self):
        from errbot.holder import bot

        pushMessage('!uptime')
        popMessage()
        pushMessage('!history')
        self.assertIn('uptime', popMessage())

        orig_sender = bot.sender
        try:
            # Pretend to be someone else. History should be empty
            bot.sender = 'non_default_person@localhost'
            pushMessage('!history')
            self.assertRaises(Empty, popMessage, block=False)
            pushMessage('!echo should be seperate history')
            popMessage()
            pushMessage('!history')
            self.assertIn('should be seperate history', popMessage())
        finally:
            bot.sender = orig_sender
        # Pretend to be the original person again. History should still contain uptime
        pushMessage('!history')
        self.assertIn('uptime', popMessage())
コード例 #12
0
ファイル: commands_tests.py プロジェクト: avallark/err
 def test_about(self):
     pushMessage('!about')
     self.assertIn('Err version', popMessage())
コード例 #13
0
ファイル: commands_tests.py プロジェクト: avallark/err
 def test_status(self):
     pushMessage('!status')
     self.assertIn('Yes I am alive', popMessage())
コード例 #14
0
 def test_borat(self):
     pushMessage('!borat')
     self.assertIn('DEVOPS_BORAT', popMessage())
コード例 #15
0
 def test_calculate_with_exception(self):
     """Test calculate command with exception
     """
     pushMessage('!calculate 1+2)')
     self.assertEqual(popMessage(), 'Input is error!')
コード例 #16
0
ファイル: commands_tests.py プロジェクト: sanketsudake/err
 def test_status(self):
     pushMessage('!status')
     self.assertIn('Yes I am alive', popMessage())
コード例 #17
0
ファイル: commands_tests.py プロジェクト: sanketsudake/err
    def test_config_cycle(self):
        # test the full configuration cycle help, get set and export, import
        pushMessage('!zap configs')
        self.assertIn('Done', popMessage())

        pushMessage('!config Webserver')
        self.assertIn('Copy paste and adapt', popMessage())

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

        pushMessage('!config Webserver')
        self.assertIn('localhost', popMessage())

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

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

        pushMessage('!config Webserver')
        self.assertIn('localhost', popMessage())
コード例 #18
0
ファイル: commands_tests.py プロジェクト: sanketsudake/err
 def test_about(self):
     pushMessage('!about')
     self.assertIn('Err version', popMessage())
コード例 #19
0
ファイル: commands_tests.py プロジェクト: sanketsudake/err
 def test_uptime(self):
     pushMessage('!uptime')
     self.assertIn('I\'ve been up for', popMessage())
コード例 #20
0
ファイル: commands_tests.py プロジェクト: sanketsudake/err
 def test_encoding_preservation(self):
     pushMessage('!echo へようこそ')
     self.assertEquals('へようこそ', popMessage())
コード例 #21
0
ファイル: commands_tests.py プロジェクト: P-Product/err
 def test_history(self):
     pushMessage('!uptime')
     popMessage()
     pushMessage('!history')
     self.assertIn('uptime', popMessage())
コード例 #22
0
ファイル: commands_tests.py プロジェクト: DazWorrall/err
    def test_unblacklist_and_blacklist(self):
        pushMessage('!unblacklist nosuchplugin')
        m = popMessage()
        self.assertIn("nosuchplugin isn't a valid plugin name. The current plugins are", m)
        self.assertIn('ChatRoom', m)

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

        pushMessage('!blacklist ChatRoom')
        self.assertEqual("Plugin ChatRoom is now blacklisted", popMessage())

        pushMessage('!blacklist ChatRoom')
        self.assertEqual("Plugin ChatRoom is already blacklisted", popMessage())

        pushMessage("!status")
        self.assertIn("[B,L] ChatRoom", popMessage())

        pushMessage('!unblacklist ChatRoom')
        self.assertEqual('Plugin ChatRoom removed from blacklist', popMessage())

        pushMessage('!unblacklist ChatRoom')
        self.assertEqual('Plugin ChatRoom is not blacklisted', popMessage())

        pushMessage("!status")
        self.assertIn("[L] ChatRoom", popMessage())
コード例 #23
0
ファイル: webhooks_tests.py プロジェクト: DazWorrall/err
 def test_webserver_plugin_ok(self):
     pushMessage("!webstatus")
     self.assertIn("echo", popMessage())
コード例 #24
0
ファイル: commands_tests.py プロジェクト: sanketsudake/err
 def test_apropos(self):
     pushMessage('!apropos about')
     self.assertIn('!about: Returns some', popMessage())
コード例 #25
0
ファイル: commands_tests.py プロジェクト: DazWorrall/err
    def test_load_reload_and_unload(self):
        for command in ('load', 'reload', 'unload'):
            pushMessage("!{}".format(command))
            m = popMessage()
            self.assertIn('Please tell me which of the following plugins to reload', m)
            self.assertIn('ChatRoom', m)

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

        pushMessage('!reload ChatRoom')
        self.assertEqual('Plugin ChatRoom deactivated', popMessage())
        self.assertEqual('Plugin ChatRoom activated', popMessage())

        pushMessage("!status")
        self.assertIn("[L] ChatRoom", popMessage())

        pushMessage('!unload ChatRoom')
        self.assertEqual('Plugin ChatRoom deactivated', popMessage())

        pushMessage("!status")
        self.assertIn("[U] ChatRoom", popMessage())

        pushMessage('!unload ChatRoom')
        self.assertEqual('ChatRoom is not currently loaded', popMessage())

        pushMessage('!load ChatRoom')
        self.assertEqual('Plugin ChatRoom activated', popMessage())

        pushMessage("!status")
        self.assertIn("[L] ChatRoom", popMessage())

        pushMessage('!load ChatRoom')
        self.assertEqual('ChatRoom is already loaded', popMessage())

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

        pushMessage('!blacklist ChatRoom')
        self.assertEqual("Plugin ChatRoom is now blacklisted", popMessage())

        pushMessage("!status")
        self.assertIn("[B,L] ChatRoom", popMessage())

        # Needed else configuration for this plugin gets saved which screws up
        # other tests
        pushMessage('!unblacklist ChatRoom')
        popMessage()
コード例 #26
0
ファイル: commands_tests.py プロジェクト: sanketsudake/err
 def test_logtail(self):
     pushMessage('!log tail')
     self.assertIn('DEBUG', popMessage())
コード例 #27
0
 def test_coderwall(self):
     pushMessage('!coderwall gbin')
     self.assertIn('24PullRequests', popMessage())
     self.assertIn('Forked 20', popMessage())
コード例 #28
0
ファイル: commands_tests.py プロジェクト: sanketsudake/err
    def test_history(self):
        from errbot.holder import bot

        pushMessage('!uptime')
        popMessage()
        pushMessage('!history')
        self.assertIn('uptime', popMessage())

        orig_sender = bot.sender
        try:
            # Pretend to be someone else. History should be empty
            bot.sender = 'non_default_person@localhost'
            pushMessage('!history')
            self.assertRaises(Empty, popMessage, block=False)
            pushMessage('!echo should be seperate history')
            popMessage()
            pushMessage('!history')
            self.assertIn('should be seperate history', popMessage())
        finally:
            bot.sender = orig_sender
        # Pretend to be the original person again. History should still contain uptime
        pushMessage('!history')
        self.assertIn('uptime', popMessage())
コード例 #29
0
ファイル: commands_tests.py プロジェクト: avallark/err
 def test_encoding_preservation(self):
     pushMessage('!echo へようこそ')
     self.assertEquals('へようこそ', popMessage())
コード例 #30
0
ファイル: commands_tests.py プロジェクト: sanketsudake/err
 def test_root_help(self):
     pushMessage('!help')
     self.assertIn('Available help', popMessage())
コード例 #31
0
ファイル: commands_tests.py プロジェクト: avallark/err
 def test_uptime(self):
     pushMessage('!uptime')
     self.assertIn('I\'ve been up for', popMessage())
コード例 #32
0
ファイル: test_eliza.py プロジェクト: errbotio/err-elizabot
 def test_eliza(self):
     pushMessage('!eliza Hello')
     ref = self.assertRegex if PY3 else self.assertRegexpMatches
     ref(popMessage(), r"Hi|Hello")
コード例 #33
0
ファイル: commands_tests.py プロジェクト: avallark/err
    def test_config_cycle(self):
        # test the full configuration cycle help, get set and export, import
        pushMessage('!zap configs')
        self.assertIn('Done', popMessage())

        pushMessage('!config Webserver')
        self.assertIn('Copy paste and adapt', popMessage())

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

        pushMessage('!config Webserver')
        self.assertIn('localhost', popMessage())

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

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

        pushMessage('!config Webserver')
        self.assertIn('localhost', popMessage())
コード例 #34
0
 def test_eliza(self):
     pushMessage('!eliza Hello')
     ref = self.assertRegex if PY3 else self.assertRegexpMatches
     ref(popMessage(), r"Hi|Hello")
コード例 #35
0
ファイル: commands_tests.py プロジェクト: avallark/err
 def test_logtail(self):
     pushMessage('!log tail')
     self.assertIn('DEBUG', popMessage())
コード例 #36
0
ファイル: tests.py プロジェクト: foxxyz/bookiebot
	def test_scoreboard_empty(self):
		pushMessage('!init')
		popMessage()
		pushMessage('!scoreboard')
		self.assertIn('Scoreboard is empty', popMessage())
コード例 #37
0
ファイル: commands_tests.py プロジェクト: avallark/err
 def test_root_help(self):
     pushMessage('!help')
     self.assertIn('Available help', popMessage())
コード例 #38
0
ファイル: tests.py プロジェクト: foxxyz/bookiebot
	def test_start_match(self):
		pushMessage('!start match Honduras vs. Poland')
		self.assertIn('Started match', popMessage())
コード例 #39
0
    def test_config_cycle(self):
        # test the full configuration cycle help, get set and export, import
        pushMessage('!zap configs')
        self.assertIn('Done', popMessage())

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

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

        pushMessage('!config Webserver')
        m = popMessage()
        self.assertIn('Current configuration', m)
        self.assertIn('localhost', m)

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

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

        pushMessage('!config Webserver')
        self.assertIn('localhost', popMessage())
コード例 #40
0
 def test_webserver_plugin_ok(self):
     pushMessage("!webstatus")
     self.assertIn("echo", popMessage())
コード例 #41
0
ファイル: commands_tests.py プロジェクト: sanketsudake/err
    def test_plugin_cycle(self):
        pushMessage('!repos install git://github.com/gbin/err-helloworld.git')
        self.assertIn('err-helloworld', popMessage())
        self.assertIn('reload', popMessage())

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

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

        pushMessage('!hello')  # should respond
        self.assertEqual('Hello World !', popMessage())

        pushMessage('!reload HelloWorld')
        self.assertEqual(
            'Plugin HelloWorld deactivated / Plugin HelloWorld activated',
            popMessage())

        pushMessage('!hello')  # should still respond
        self.assertEqual('Hello World !', popMessage())

        pushMessage('!unload HelloWorld')
        self.assertEqual('Plugin HelloWorld deactivated', popMessage())

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

        pushMessage('!load HelloWorld')
        self.assertEqual('Plugin HelloWorld activated', popMessage())

        pushMessage('!hello')  # should respond back
        self.assertEqual('Hello World !', popMessage())

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

        pushMessage('!hello')  # should not respond
        self.assertIn('Command "hello" not found', popMessage())
コード例 #42
0
ファイル: webhooks_tests.py プロジェクト: P-Product/err
 def setUpClass(cls, extra_test_file=None):
     super(TestWebhooks, cls).setUpClass()
     pushMessage("!config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}")
     popMessage()