Пример #1
0
 def setUp(self):
     patcher = patch('transmissionrpc.client.Client.get_torrents')
     self.get_torrents = patcher.start()
     self.addCleanup(patcher.stop)
     patcher = patch('transmissionrpc.client.Client.add_torrent')
     self.add_torrent = patcher.start()
     self.addCleanup(patcher.stop)
     patcher = patch('transmissionrpc.client.Client.get_session')
     patcher.start()
     self.addCleanup(patcher.stop)
Пример #2
0
 def setUp(self):
     patcher = patch('transmissionrpc.client.Client.get_torrents')
     self.get_torrents = patcher.start()
     self.addCleanup(patcher.stop)
     patcher = patch('transmissionrpc.client.Client.add_torrent')
     self.add_torrent = patcher.start()
     self.addCleanup(patcher.stop)
     patcher = patch('transmissionrpc.client.Client.get_session')
     patcher.start()
     self.addCleanup(patcher.stop)
Пример #3
0
    def setUp(self):
        self.patch_asyncio()
        patcher = patch('panoramisk.Manager.send_action_via_http')
        self.send_action = patcher.start()
        self.response = Message(
            'response', '', headers={'Response': 'Success'})
        self.send_action.return_value = self.response
        self.addCleanup(patcher.stop)

        self.mocks = {}
        for name in ('connect', 'close'):
            patcher = patch('panoramisk.Manager.' + name)
            self.mocks[name] = patcher.start()
            self.addCleanup(patcher.stop)
Пример #4
0
    def setUp(self):
        self.patch_asyncio()
        patcher = patch('panoramisk.Manager.send_action_via_http')
        self.send_action = patcher.start()
        self.response = Message('response',
                                '',
                                headers={'Response': 'Success'})
        self.send_action.return_value = self.response
        self.addCleanup(patcher.stop)

        self.mocks = {}
        for name in ('connect', 'close'):
            patcher = patch('panoramisk.Manager.' + name)
            self.mocks[name] = patcher.start()
            self.addCleanup(patcher.stop)
Пример #5
0
 def setUp(self):
     self.patch_asyncio()
     self.mocks = {}
     for name in ('connect', 'close'):
         patcher = patch('panoramisk.Manager.' + name)
         self.mocks[name] = patcher.start()
         self.addCleanup(patcher.stop)
Пример #6
0
    def test_autocommand(self):
        loop = asyncio.get_event_loop()

        # sleep typed in mixed case to test that work with different cases
        bot = self.callFTU(
            autocommands=['AUTH user pass', '/slEep  3', 'MODE {nick} +x'])
        with patch('irc3.plugins.autocommand.SleepCommand.execute', mock):
            plugin = bot.get_plugin(AutoCommand)
            loop.run_until_complete(plugin.execute_commands())
            self.assertSent(['AUTH user pass', 'MODE irc3 +x'])

            with self.assertRaises(ValueError):
                # test bad arguments too
                self.callFTU(autocommands=[
                    None, '/sleep 3.4.5', '/sleep bad', 'TEST SENT'
                ])
Пример #7
0
    def test_autocommand(self, sleep):
        def new_async(coro, *args, **kw):
            for res in coro:
                pass  # do nothing

        with patch('irc3.asyncio.async', new_async):
            # sleep typed in mixed case to test that work with different cases
            bot = self.callFTU(commands=['AUTH user pass', '/slEep  3',
                                         'MODE {nick} +x'])
            bot.notify('connection_made')
            bot.dispatch(':node.net 376 irc3 :End of /MOTD command.')
            self.assertSent(['AUTH user pass', 'MODE irc3 +x'])
            sleep.assert_called_once_with(3, loop=bot.loop)

            with self.assertRaises(ValueError):
                # test bad arguments too
                bot2 = self.callFTU(commands=[
                        None, '/sleep 3.4.5', '/sleep bad', 'TEST SENT'])
                bot2.notify('connection_made')
                bot2.dispatch(':node.net 376 irc3 '':End of /MOTD command.')
                self.assertSent(['TEST SENT'])
Пример #8
0
    def test_autocommand(self, sleep):
        def new_async(coro, *args, **kw):
            for res in coro:
                pass  # do nothing

        with patch('irc3.asyncio.async', new_async):
            # sleep typed in mixed case to test that work with different cases
            bot = self.callFTU(
                commands=['AUTH user pass', '/slEep  3', 'MODE {nick} +x'])
            bot.notify('connection_made')
            bot.dispatch(':node.net 376 irc3 :End of /MOTD command.')
            self.assertSent(['AUTH user pass', 'MODE irc3 +x'])
            sleep.assert_called_once_with(3, loop=bot.loop)

            with self.assertRaises(ValueError):
                # test bad arguments too
                bot2 = self.callFTU(
                    commands=[None, '/sleep 3.4.5', '/sleep bad', 'TEST SENT'])
                bot2.notify('connection_made')
                bot2.dispatch(':node.net 376 irc3 ' ':End of /MOTD command.')
                self.assertSent(['TEST SENT'])