From e75b92853b5bbdcd378ec7572ebe8ae510061000 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 22 Sep 2003 09:18:13 +0000 Subject: [PATCH] Fixed bug with channel capabilities for channels with . in their name. --- src/ircdb.py | 3 ++- test/test_ircdb.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ircdb.py b/src/ircdb.py index f6f15f288..a8cb2df29 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -46,7 +46,8 @@ def fromChannelCapability(capability): """Returns a (channel, capability) tuple from a channel capability.""" if not isChannelCapability(capability): raise ValueError, '%s is not a channel capability' % capability - return capability.split('.', 1) + #return capability.rsplit('.', 1) + return rsplit(capability, '.', 1) def isChannelCapability(capability): """Returns True if capability is a channel capability; False otherwise.""" diff --git a/test/test_ircdb.py b/test/test_ircdb.py index 369152d80..277ca29f1 100644 --- a/test/test_ircdb.py +++ b/test/test_ircdb.py @@ -45,10 +45,12 @@ class FunctionsTestCase(unittest.TestCase): self.failIf(ircdb.isAntiCapability('#foo.bar')) self.failUnless(ircdb.isAntiCapability('!foo')) self.failUnless(ircdb.isAntiCapability('#foo.!bar')) + self.failUnless(ircdb.isAntiCapability('#foo.bar.!baz')) def testIsChannelCapability(self): self.failIf(ircdb.isChannelCapability('foo')) self.failUnless(ircdb.isChannelCapability('#foo.bar')) + self.failUnless(ircdb.isChannelCapability('#foo.bar.baz')) def testMakeAntiCapability(self): self.assertEqual(ircdb.makeAntiCapability('foo'), '!foo') @@ -58,9 +60,17 @@ class FunctionsTestCase(unittest.TestCase): self.assertEqual(ircdb.makeChannelCapability('#f', 'b'), '#f.b') self.assertEqual(ircdb.makeChannelCapability('#f', '!b'), '#f.!b') + def testFromChannelCapability(self): + self.assertEqual(ircdb.fromChannelCapability('#foo.bar'), + ['#foo', 'bar']) + self.assertEqual(ircdb.fromChannelCapability('#foo.bar.baz'), + ['#foo.bar', 'baz']) + def testUnAntiCapability(self): self.assertEqual(ircdb.unAntiCapability('!bar'), 'bar') self.assertEqual(ircdb.unAntiCapability('#foo.!bar'), '#foo.bar') + self.assertEqual(ircdb.unAntiCapability('#foo.bar.!baz'), + '#foo.bar.baz') def testInvertCapability(self): self.assertEqual(ircdb.invertCapability('bar'), '!bar')