Issue #4473: Add a POP3.capa() method to query the capabilities advertised by the POP3 server.

Patch by Lorenzo Catucci.
This commit is contained in:
Antoine Pitrou 2012-11-23 20:07:39 +01:00
parent d89824b0e2
commit 25cee19beb
4 changed files with 57 additions and 0 deletions

View file

@ -33,6 +33,8 @@ line3\r\n\
class DummyPOP3Handler(asynchat.async_chat):
CAPAS = {'UIDL': [], 'IMPLEMENTATION': ['python-testlib-pop-server']}
def __init__(self, conn):
asynchat.async_chat.__init__(self, conn)
self.set_terminator(b"\r\n")
@ -112,6 +114,16 @@ class DummyPOP3Handler(asynchat.async_chat):
self.push('+OK closing.')
self.close_when_done()
def cmd_capa(self, arg):
self.push('+OK Capability list follows')
if self.CAPAS:
for cap, params in self.CAPAS.items():
_ln = [cap]
if params:
_ln.extend(params)
self.push(' '.join(_ln))
self.push('.')
class DummyPOP3Server(asyncore.dispatcher, threading.Thread):
@ -232,6 +244,10 @@ class TestPOP3Class(TestCase):
self.client.uidl()
self.client.uidl('foo')
def test_capa(self):
capa = self.client.capa()
self.assertTrue('IMPLEMENTATION' in capa.keys())
def test_quit(self):
resp = self.client.quit()
self.assertTrue(resp)