[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/POP3/tests - testPOP3MessageList.py:1.1.2.2 testPOP3Server.py:1.1.2.2
Stephan Richter
srichter@cbu.edu
Thu, 11 Apr 2002 00:32:42 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Server/POP3/tests
In directory cvs.zope.org:/tmp/cvs-serv25892/lib/python/Zope/Server/POP3/tests
Modified Files:
Tag: Zope3-Server-Branch
testPOP3MessageList.py testPOP3Server.py
Log Message:
Wee, quiet a bit of changes, but they fix and finnish the stuff Shane did
earlier today.
- Removed a lot of old files and moved some to more appropriate places. The
removal of the Suthentication directory is probably the biggest one. I
also deleted all the other FileSystem types, like MSDOS and Unix, since
the FielSystem is not returning formatted lists anymore. Yipee!
- Fixed PublisherFTPServer, so it works with Shane's new Credentials
interfaces. Everything should be working fine again.
- Fixed the POP3 and SMTP code to work with the new model. It all works
really well. I hope that Gerson Kurz will take over this development
soon. I also contacted authors of other server protocols, and they might
join. Rich Salz is already writing a method for ZSI, so that we can
insert SOAP in the next days.
- Made most tests run again and updated them. I still have one error. I know
why it is caused, but I do not know how to correct. I know it is a test
environment problem though, not a code one.
=== Zope3/lib/python/Zope/Server/POP3/tests/testPOP3MessageList.py 1.1.2.1 => 1.1.2.2 ===
from Zope.Server.POP3.POP3MessageList import POP3MessageList
-from Zope.Server.VFS.UnixFileSystem import UnixFileSystem
+from Zope.Server.VFS.OSFileSystem import OSFileSystem
import foo_mb
@@ -35,7 +35,7 @@
def setUp(self):
dir = tempfile.gettempdir()
open(os.path.join(dir, 'foo'), 'w').write(foo_mb.mailbox)
- self.msg_list = POP3MessageList(UnixFileSystem(dir), 'foo')
+ self.msg_list = POP3MessageList(OSFileSystem(dir), 'foo')
self.msg_list.open()
def testOpen(self):
=== Zope3/lib/python/Zope/Server/POP3/tests/testPOP3Server.py 1.1.2.1 => 1.1.2.2 ===
import tempfile
import os
+from cStringIO import StringIO
from asyncore import socket_map, poll
from threading import Thread
@@ -26,12 +27,12 @@
from Zope.Server.POP3.POP3Server import POP3Server
from Zope.Server.POP3.POP3ServerChannel import POP3ServerChannel
from Zope.Server.POP3.POP3StatusMessages import status_msgs
+from Zope.Server.VFS.TestFilesystemAccess import TestFilesystemAccess
+from Zope.Server.VFS.UsernamePassword import UsernamePassword
from Zope.Server.Adjustments import Adjustments
from Zope.Server.ITask import ITask
-from Zope.Server.VFS.UnixFileSystem import UnixFileSystem
-from Zope.Server.Authentication.DictionaryAuthentication import \
- DictionaryAuthentication
+from Zope.Server.VFS.OSFileSystem import OSFileSystem
import poplib
import foo_mb
@@ -60,14 +61,16 @@
root_dir = tempfile.mktemp()
os.mkdir(root_dir)
- self.root_dir = UnixFileSystem(root_dir)
-
file = open(os.path.join(root_dir, 'foo'), 'w')
file.write(foo_mb.mailbox)
file.close()
+ fs = OSFileSystem('/opt/ZopeMail')
+ root_dir = TestFilesystemAccess(fs)
+ credentials = UsernamePassword('foo', 'bar')
+ self.root_dir = root_dir.open(credentials)
+
self.server = POP3Server(LOCALHOST, SERVER_PORT, root_dir,
- DictionaryAuthentication({'foo': 'bar'}),
task_dispatcher=td, adj=my_adj)
if CONNECT_TO_PORT == 0:
self.port = self.server.socket.getsockname()[1]
@@ -87,15 +90,15 @@
self.server.close()
# Make sure all sockets get closed by asyncore normally.
# timeout = time() + 5
- # while 1:
- # if len(socket_map) == self.orig_map_size:
- # # Clean!
- # break
- # if time() >= timeout:
- # print 'Leaked a socket: %s' % `socket_map`
- # break
- # #self.fail('Leaked a socket: %s' % `socket_map`)
- # poll(0.1, socket_map)
+ while 1:
+ if len(socket_map) == self.orig_map_size:
+ # Clean!
+ break
+ if time() >= timeout:
+ print 'Leaked a socket: %s' % `socket_map`
+ break
+ #self.fail('Leaked a socket: %s' % `socket_map`)
+ poll(0.1, socket_map)
def loop(self):
@@ -108,9 +111,7 @@
def getPOP3Connection(self, login=1):
# Refresh the file every single time, since some operations might
# modify it.
- file = self.root_dir.open('foo', 'w')
- file.write(foo_mb.mailbox)
- file.close()
+ self.root_dir.writefile('foo', 'w', StringIO(foo_mb.mailbox))
pop = poplib.POP3(LOCALHOST, self.port)
if login: