2011-04-27 14:59:02 +02:00
|
|
|
###
|
2021-10-17 09:54:06 +02:00
|
|
|
# Copyright (c) 2011-2021, Valentin Lorentz
|
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
|
|
|
|
import shutil
|
|
|
|
|
2011-04-27 14:59:02 +02:00
|
|
|
from supybot.test import *
|
|
|
|
|
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(, .*)?')
|
2022-06-23 22:09:23 +02:00
|
|
|
self.assertRegexp('repolist', '(.*, )?jlu5(, .*)?')
|
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')
|
|
|
|
|
2016-08-01 16:08:31 +02:00
|
|
|
def testInstallNonAsciiInit(self):
|
|
|
|
self.assertNotError('plugindownloader install Hoaas DuckDuckGo')
|
|
|
|
self._testPluginInstalled('DuckDuckGo')
|
|
|
|
|
2022-06-23 22:12:13 +02:00
|
|
|
def testInstallLegacyWarning(self):
|
|
|
|
self.assertRegexp('plugindownloader install frumious Codepoints',
|
|
|
|
'may be incompatible')
|
|
|
|
|
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.')
|
|
|
|
|
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:
|