Fix ~add ~del ~clean commands

The first parameter would be ignored when running ~add, ~del or
~clean commands. Fix the issue and add a test to make sure we
do not regress again.

Change-Id: If2c239e8d04ca2ea86283861617c89d77d3917ee
This commit is contained in:
Thierry Carrez 2021-04-16 11:09:24 +02:00
parent 011c7c7ed7
commit b728b153e4
2 changed files with 14 additions and 1 deletions

View File

@ -80,7 +80,7 @@ def process_admin_command(db, command, params):
elif command in ('clean', 'add', 'del'):
if len(params) < 1:
return "This command takes one or more arguments"
getattr(db, command + '_tracks')(params[1:])
getattr(db, command + '_tracks')(params)
else:
return "Unknown command '%s'" % command

View File

@ -515,6 +515,19 @@ class TestProcessMessage(testtools.TestCase):
self.assertEqual(self.db.data, original_db_data)
mock_send.reset_mock()
def test_add_track(self):
self.bot.is_chanop = mock.MagicMock(return_value=True)
with mock.patch.object(
self.bot, 'send',
) as mock_send:
msg = Event('',
'johndoe!~johndoe@openstack/member/johndoe',
'#channel',
['+~add testtrack'])
self.bot.on_pubmsg('', msg)
self.assertTrue('testtrack' in self.db.data['tracks'])
mock_send.reset_mock()
def test_motd(self):
motdstates = [
('~motd add info foo bar', [