Compare commits

...

10 Commits

Author SHA1 Message Date
Aminda Suomalainen ⚧ cbc2274179
Merge c389be4f37 into f65089af86 2024-05-05 18:24:11 +02:00
Valentin Lorentz f65089af86 CONTRIBUTING.md: Remove the bit about the testing branch
We're going to commit directly to master from now one.

The 'testing' policy predates PyPI releases and Git master was the primary mean
of distributing Limnoria back then, but it does not make sense anymore.
2024-05-05 17:56:48 +02:00
Valentin Lorentz 07834620f3 CONTRIBUTING.md: Update documentation URLs 2024-05-05 17:56:00 +02:00
Valentin Lorentz d435442b39 Admin: Actually clean up test channel from configuration
943f39745d did not actually because:

1. the 'part' command is not available (it's in the Channel plugin)
   so it just didn't do anything
2. one of the tests was missing the cleanup
2024-04-26 09:04:45 +02:00
Valentin Lorentz 6758c00363 limnoria-test: Fix log config
Since 03a3777129 we use .format() instead of % for substitution,
so these should not be escaped anymore.
2024-04-26 08:57:49 +02:00
Valentin Lorentz 943f39745d Admin: Fix leftover state change in testPart
it affects Channel's testPart
2024-04-18 19:47:22 +02:00
Valentin Lorentz c8030be71a Web: Need to download even more Javascript from Youtube 2024-04-18 19:33:55 +02:00
Valentin Lorentz 03c638705f Channel: Fix error in @part when channel is configured but not joined
This typically happens when banned from the channel, and returning an error
gives bot admins the impression @part did not remove the channel from
the auto-join list
2024-04-12 19:17:13 +02:00
GMDSantana 03a3777129
Create temporary files in a temporary directory
But keep it if tests fail.

Closes #1061
2024-04-12 11:06:30 +02:00
Mikaela Suomalainen c389be4f37
Config: note "config flush false" when option is not writeable via IRC 2021-05-27 10:47:11 +03:00
6 changed files with 55 additions and 35 deletions

View File

@ -15,14 +15,10 @@ Last rule: you shouldn't add a mandatory dependency. Limnoria does not
come with any (besides Python), so please try to keep all dependencies
optional.
[Style Guidelines]:https://limnoria.readthedocs.io/en/latest/develop/style.html
[Style Guidelines]:https://docs.limnoria.net/develop/style.html
## Sending patches
When you send a pull request, **send it to the testing branch**.
It will be merged to master when it's considered to be stable enough to be
supported.
Don't fear that you spam Limnoria by sending many pull requests. According
to @ProgVal, it's easier for them to accept pull requests than to
cherry-pick everything manually.
@ -32,6 +28,6 @@ is very appreciated.
See also [Contributing to Limnoria] at [Limnoria documentation].
[Contributing to Limnoria]:https://limnoria.readthedocs.io/en/latest/contribute/index.html
[Contributing to Limnoria]:https://docs.limnoria.net/contribute/index.html
[Limnoria documentation]:https://limnoria.readthedocs.io/
[Limnoria documentation]:https://docs.limnoria.net/

View File

@ -50,6 +50,7 @@ class AdminTestCase(PluginTestCase):
self.irc.feedMsg(ircmsgs.join('#Baz', prefix=self.prefix))
getAfterJoinMessages()
self.assertRegexp('channels', '#bar, #Baz, and #foo')
self.assertNotRegexp('config networks.test.channels', '.*#foo.*')
def testIgnoreAddRemove(self):
self.assertNotError('admin ignore add foo!bar@baz')
@ -87,13 +88,16 @@ class AdminTestCase(PluginTestCase):
ircdb.users.delUser(u.id)
def testJoin(self):
m = self.getMsg('join #foo')
self.assertEqual(m.command, 'JOIN')
self.assertEqual(m.args[0], '#foo')
m = self.getMsg('join #foo key')
self.assertEqual(m.command, 'JOIN')
self.assertEqual(m.args[0], '#foo')
self.assertEqual(m.args[1], 'key')
try:
m = self.getMsg('join #foo')
self.assertEqual(m.command, 'JOIN')
self.assertEqual(m.args[0], '#foo')
m = self.getMsg('join #foo key')
self.assertEqual(m.command, 'JOIN')
self.assertEqual(m.args[0], '#foo')
self.assertEqual(m.args[1], 'key')
finally:
conf.supybot.networks.test.channels.setValue('')
def testNick(self):
try:
@ -107,10 +111,13 @@ class AdminTestCase(PluginTestCase):
self.assertError('admin capability add %s owner' % self.nick)
def testJoinOnOwnerInvite(self):
self.irc.feedMsg(ircmsgs.invite(conf.supybot.nick(), '#foo', prefix=self.prefix))
m = self.getMsg(' ')
self.assertEqual(m.command, 'JOIN')
self.assertEqual(m.args[0], '#foo')
try:
self.irc.feedMsg(ircmsgs.invite(conf.supybot.nick(), '#foo', prefix=self.prefix))
m = self.getMsg(' ')
self.assertEqual(m.command, 'JOIN')
self.assertEqual(m.args[0], '#foo')
finally:
conf.supybot.networks.test.channels.setValue('')
def testNoJoinOnUnprivilegedInvite(self):
try:
@ -121,6 +128,7 @@ class AdminTestCase(PluginTestCase):
'Error: "somecommand" is not a valid command.')
finally:
world.testing = True
self.assertNotRegexp('config networks.test.channels', '.*#foo.*')
def testAcmd(self):
self.irc.feedMsg(ircmsgs.join('#foo', prefix=self.prefix))

View File

@ -991,9 +991,14 @@ class Channel(callbacks.Plugin):
network = conf.supybot.networks.get(irc.network)
network.channels().remove(channel)
except KeyError:
pass
if channel not in irc.state.channels:
irc.error(_('I\'m not in %s.') % channel, Raise=True)
if channel not in irc.state.channels:
# Not configured AND not in the channel
irc.error(_('I\'m not in %s.') % channel, Raise=True)
else:
if channel not in irc.state.channels:
# Configured, but not in the channel
irc.reply(_('%s removed from configured join list.') % channel)
return
reason = (reason or self.registryValue("partMsg", channel, irc.network))
reason = ircutils.standardSubstitute(irc, msg, reason)
irc.queueMsg(ircmsgs.part(channel, reason))

View File

@ -108,8 +108,9 @@ def isReadOnly(name):
def checkCanSetValue(irc, msg, group):
if isReadOnly(group._name):
irc.error(_("This configuration variable is not writeable "
"via IRC. To change it you have to: 1) use the 'flush' command 2) edit "
"the config file 3) use the 'config reload' command."), Raise=True)
"via IRC. To change it you have to: 1) use the 'flush' command "
"2) use the 'config flush false' command 3) edit the config "
"file 4) use the 'config reload' command."), Raise=True)
capability = getCapability(irc, group._name)
if not ircdb.checkCapability(msg.prefix, capability):
irc.errorNoCapability(capability, Raise=True)

View File

@ -154,7 +154,7 @@ class Web(callbacks.PluginRegexp):
if parsed_url.netloc == 'youtube.com' \
or parsed_url.netloc.endswith(('.youtube.com')):
# there is a lot of Javascript before the <title>
size = max(409600, size)
size = max(819200, size)
if parsed_url.netloc in ('reddit.com', 'www.reddit.com', 'new.reddit.com'):
# Since 2022-03, New Reddit has 'Reddit - Dive into anything' as
# <title> on every page.

View File

@ -36,6 +36,7 @@ import sys
import time
import shutil
import fnmatch
from tempfile import TemporaryDirectory
started = time.time()
import supybot
@ -43,21 +44,24 @@ import logging
import traceback
# We need to do this before we import conf.
if not os.path.exists('test-conf'):
os.mkdir('test-conf')
main_temp_dir = TemporaryDirectory()
registryFilename = os.path.join('test-conf', 'test.conf')
fd = open(registryFilename, 'w')
fd.write("""
os.makedirs(os.path.join(main_temp_dir.name, 'conf'))
os.makedirs(os.path.join(main_temp_dir.name, 'data'))
os.makedirs(os.path.join(main_temp_dir.name, 'logs'))
registryFilename = os.path.join(main_temp_dir.name, 'conf', 'test.conf')
with open(registryFilename, 'w') as fd:
fd.write("""
supybot.directories.backup: /dev/null
supybot.directories.conf: %(base_dir)s/test-conf
supybot.directories.data: %(base_dir)s/test-data
supybot.directories.log: %(base_dir)s/test-logs
supybot.directories.conf: {temp_conf}
supybot.directories.data: {temp_data}
supybot.directories.log: {temp_logs}
supybot.reply.whenNotCommand: True
supybot.log.stdout: False
supybot.log.stdout.level: ERROR
supybot.log.level: DEBUG
supybot.log.format: %%(levelname)s %%(message)s
supybot.log.format: %(levelname)s %(message)s
supybot.log.plugins.individualLogfiles: False
supybot.protocols.irc.throttleTime: 0
supybot.reply.whenAddressedBy.chars: @
@ -67,8 +71,11 @@ supybot.networks.testnet2.server: should.not.need.this
supybot.networks.testnet3.server: should.not.need.this
supybot.nick: test
supybot.databases.users.allowUnregistration: True
""" % {'base_dir': os.getcwd()})
fd.close()
""".format(
temp_conf=os.path.join(main_temp_dir.name, 'conf'),
temp_data=os.path.join(main_temp_dir.name, 'data'),
temp_logs=os.path.join(main_temp_dir.name, 'logs')
))
import supybot.registry as registry
registry.open_registry(registryFilename)
@ -251,6 +258,9 @@ def main():
if result.wasSuccessful():
sys.exit(0)
else:
# Deactivate autocleaning for the temporary directiories to allow inspection.
main_temp_dir._finalizer.detach()
print(f"Temporary directory path: {main_temp_dir.name}")
sys.exit(1)