2011-04-27 14:59:02 +02:00
|
|
|
###
|
2021-08-01 21:47:37 +02:00
|
|
|
# Copyright (c) 2011-2021, The Limnoria Contributors
|
2011-04-27 14:59:02 +02:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright notice,
|
|
|
|
# this list of conditions, and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
# this list of conditions, and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
# * Neither the name of the author of this software nor the name of
|
|
|
|
# contributors to this software may be used to endorse or promote products
|
|
|
|
# derived from this software without specific prior written consent.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
###
|
|
|
|
|
2011-04-28 11:38:48 +02:00
|
|
|
import os
|
2013-11-26 18:13:56 +01:00
|
|
|
import sys
|
2011-04-28 11:38:48 +02:00
|
|
|
import shutil
|
|
|
|
|
2011-04-27 14:59:02 +02:00
|
|
|
from supybot.test import *
|
2015-08-11 16:50:23 +02:00
|
|
|
import supybot.utils.minisix as minisix
|
2011-04-27 14:59:02 +02:00
|
|
|
|
2011-04-28 11:38:48 +02:00
|
|
|
pluginsPath = '%s/test-plugins' % os.getcwd()
|
|
|
|
|
2011-04-27 14:59:02 +02:00
|
|
|
class PluginDownloaderTestCase(PluginTestCase):
|
|
|
|
plugins = ('PluginDownloader',)
|
2011-04-28 11:38:48 +02:00
|
|
|
config = {'supybot.directories.plugins': [pluginsPath]}
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
PluginTestCase.setUp(self)
|
|
|
|
try:
|
|
|
|
shutil.rmtree(pluginsPath)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
os.mkdir(pluginsPath)
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
try:
|
|
|
|
shutil.rmtree(pluginsPath)
|
|
|
|
finally:
|
|
|
|
PluginTestCase.tearDown(self)
|
2011-04-27 14:59:02 +02:00
|
|
|
|
2011-04-28 13:57:06 +02:00
|
|
|
def _testPluginInstalled(self, name):
|
|
|
|
assert os.path.isdir(pluginsPath + '/%s/' % name)
|
|
|
|
assert os.path.isfile(pluginsPath + '/%s/plugin.py' % name)
|
|
|
|
assert os.path.isfile(pluginsPath + '/%s/config.py' % name)
|
|
|
|
|
2011-04-27 14:59:02 +02:00
|
|
|
def testRepolist(self):
|
2021-09-14 20:30:47 +02:00
|
|
|
self.assertRegexp('repolist', '(.*, )?progval(, .*)?')
|
2011-04-28 13:57:06 +02:00
|
|
|
self.assertRegexp('repolist', '(.*, )?quantumlemur(, .*)?')
|
2021-09-14 20:30:47 +02:00
|
|
|
self.assertRegexp('repolist progval', '(.*, )?AttackProtector(, .*)?')
|
2011-04-27 14:59:02 +02:00
|
|
|
|
2021-09-14 20:30:47 +02:00
|
|
|
def testInstallprogval(self):
|
|
|
|
self.assertError('plugindownloader install progval Darcs')
|
|
|
|
self.assertNotError('plugindownloader install progval AttackProtector')
|
|
|
|
self.assertError('plugindownloader install progval Darcs')
|
2011-04-28 13:57:06 +02:00
|
|
|
self._testPluginInstalled('AttackProtector')
|
2011-04-28 11:38:48 +02:00
|
|
|
|
2017-09-24 21:11:21 +02:00
|
|
|
def testShellForbidden(self):
|
|
|
|
with conf.supybot.commands.allowShell.context(False):
|
2021-09-14 20:30:47 +02:00
|
|
|
self.assertRegexp('plugindownloader install progval Darcs',
|
2017-09-24 21:11:21 +02:00
|
|
|
'Error:.*not available.*supybot.commands.allowShell')
|
|
|
|
|
2011-04-28 11:38:48 +02:00
|
|
|
def testInstallQuantumlemur(self):
|
|
|
|
self.assertError('plugindownloader install quantumlemur AttackProtector')
|
|
|
|
self.assertNotError('plugindownloader install quantumlemur Listener')
|
|
|
|
self.assertError('plugindownloader install quantumlemur AttackProtector')
|
2011-04-28 13:57:06 +02:00
|
|
|
self._testPluginInstalled('Listener')
|
|
|
|
|
|
|
|
def testInstallStepnem(self):
|
|
|
|
self.assertNotError('plugindownloader install stepnem Freenode')
|
|
|
|
self._testPluginInstalled('Freenode')
|
|
|
|
|
2011-04-28 14:20:36 +02:00
|
|
|
def testInstallNanotubeBitcoin(self):
|
|
|
|
self.assertNotError('plugindownloader install nanotube-bitcoin GPG')
|
|
|
|
self._testPluginInstalled('GPG')
|
|
|
|
|
2011-04-28 14:47:25 +02:00
|
|
|
def testInstallMtughanWeather(self):
|
|
|
|
self.assertNotError('plugindownloader install mtughan-weather '
|
|
|
|
'WunderWeather')
|
|
|
|
self._testPluginInstalled('WunderWeather')
|
|
|
|
|
|
|
|
def testInstallSpiderDave(self):
|
|
|
|
self.assertNotError('plugindownloader install SpiderDave Pastebin')
|
|
|
|
self._testPluginInstalled('Pastebin')
|
|
|
|
|
2016-08-01 16:08:31 +02:00
|
|
|
def testInstallNonAsciiInit(self):
|
|
|
|
self.assertNotError('plugindownloader install Hoaas DuckDuckGo')
|
|
|
|
self._testPluginInstalled('DuckDuckGo')
|
|
|
|
|
2013-07-30 10:53:58 +02:00
|
|
|
def testInfo(self):
|
2021-09-14 20:30:47 +02:00
|
|
|
self.assertResponse('plugindownloader info progval Twitter',
|
2013-07-30 10:53:58 +02:00
|
|
|
'Advanced Twitter plugin for Supybot, with capabilities '
|
|
|
|
'handling, and per-channel user account.')
|
|
|
|
|
2015-08-09 00:23:03 +02:00
|
|
|
if minisix.PY3:
|
2013-11-26 18:13:56 +01:00
|
|
|
def test_2to3(self):
|
|
|
|
self.assertRegexp('plugindownloader install SpiderDave Pastebin',
|
|
|
|
'convert')
|
|
|
|
self.assertNotError('load Pastebin')
|
|
|
|
|
2013-04-27 10:19:43 +02:00
|
|
|
if not network:
|
|
|
|
class PluginDownloaderTestCase(PluginTestCase):
|
|
|
|
pass
|
2011-04-28 14:20:36 +02:00
|
|
|
|
2011-04-27 14:59:02 +02:00
|
|
|
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|