Skip to content

Commit

Permalink
Backported
Browse files Browse the repository at this point in the history
r26454 | srichter | 2004-07-13 12:28:46 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26455 | srichter | 2004-07-13 12:32:34 -0400 (Tue, 13 Jul 2004) | 3 
lines
r26456 | srichter | 2004-07-13 12:33:41 -0400 (Tue, 13 Jul 2004) | 3 
lines
r26457 | srichter | 2004-07-13 12:34:28 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26458 | srichter | 2004-07-13 12:37:35 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26459 | srichter | 2004-07-13 12:39:48 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26460 | srichter | 2004-07-13 12:40:26 -0400 (Tue, 13 Jul 2004) | 4 
lines
r26461 | srichter | 2004-07-13 12:41:08 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26462 | srichter | 2004-07-13 12:44:02 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26463 | srichter | 2004-07-13 12:46:02 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26464 | srichter | 2004-07-13 12:48:13 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26465 | srichter | 2004-07-13 12:48:44 -0400 (Tue, 13 Jul 2004) | 4 
lines
r26466 | srichter | 2004-07-13 12:49:20 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26467 | srichter | 2004-07-13 12:49:41 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26468 | srichter | 2004-07-13 12:51:32 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26469 | srichter | 2004-07-13 12:52:22 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26470 | srichter | 2004-07-13 12:53:32 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26471 | srichter | 2004-07-13 12:55:23 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26472 | srichter | 2004-07-13 12:56:24 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26473 | srichter | 2004-07-13 12:56:45 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26474 | srichter | 2004-07-13 12:57:36 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26475 | srichter | 2004-07-13 12:57:58 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26476 | srichter | 2004-07-13 12:59:11 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26477 | srichter | 2004-07-13 13:00:04 -0400 (Tue, 13 Jul 2004) | 4 
lines
r26478 | srichter | 2004-07-13 13:00:36 -0400 (Tue, 13 Jul 2004) | 2 
lines
r26479 | srichter | 2004-07-13 13:01:19 -0400 (Tue, 13 Jul 2004) | 2 
lines
  • Loading branch information
strichter committed Aug 12, 2004
1 parent d5fccf1 commit c4c25ae
Show file tree
Hide file tree
Showing 9 changed files with 1,021 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ftp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def cmd_port(self, args):
port = int(info[4])*256 + int(info[5])
# how many data connections at a time?
# I'm assuming one for now...
# XXX: we should (optionally) verify that the
# TODO: we should (optionally) verify that the
# ip number belongs to the client. [wu-ftpd does this?]
self.client_addr = (ip, port)
self.reply('SUCCESS_200', 'PORT')
Expand Down
40 changes: 40 additions & 0 deletions ftp/tests/test_demofs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test the Demo Filesystem implementation.
$Id$
"""
import demofs
from unittest import TestCase, TestSuite, main, makeSuite
from fstests import FileSystemTests
from StringIO import StringIO

class Test(FileSystemTests, TestCase):

def setUp(self):
root = demofs.Directory()
root.grant('bob', demofs.write)
fs = self.filesystem = demofs.DemoFileSystem(root, 'bob')
fs.mkdir(self.dir_name)
fs.writefile(self.file_name, StringIO(self.file_contents))
fs.writefile(self.unwritable_filename, StringIO("save this"))
fs.get(self.unwritable_filename).revoke('bob', demofs.write)

def test_suite():
return TestSuite((
makeSuite(Test),
))

if __name__=='__main__':
main(defaultTest='test_suite')
123 changes: 123 additions & 0 deletions ftp/tests/test_publisher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test the FTP publisher.
$Id$
"""
import demofs
from unittest import TestCase, TestSuite, main, makeSuite
from fstests import FileSystemTests
from StringIO import StringIO
from zope.publisher.publish import mapply
from zope.server.ftp.publisher import PublisherFileSystem

class DemoFileSystem(demofs.DemoFileSystem):

def rename(self, path, old, new):
return demofs.DemoFileSystem.rename(
self, "%s/%s" % (path, old), "%s/%s" % (path, new))

class Publication:

def __init__(self, root):
self.root = root

def beforeTraversal(self, request):
pass

def getApplication(self, request):
return self.root

def afterTraversal(self, request, ob):
pass

def callObject(self, request, ob):
command = getattr(ob, request.env['command'])
if 'name' in request.env:
request.env['path'] += "/" + request.env['name']
return mapply(command, request = request.env)

def afterCall(self, request, ob):
pass

def endRequest(self, request, ob):
pass

def handleException(self, object, request, info, retry_allowed=True):
request.response._exc = info[:2]


class Request:

def __init__(self, input, output, env):
self.env = env
self.response = Response()
self.user = env['credentials']
del env['credentials']

def processInputs(self):
pass

def traverse(self, root):
root.user = self.user
return root

def close(self):
pass

class Response:

_exc = _body = None

def setBody(self, result):
self._body = result

def outputBody(self):
pass

def getResult(self):
if self._exc:
raise self._exc[0], self._exc[1]
return self._body

class RequestFactory:

def __init__(self, root):
self.pub = Publication(root)

def __call__(self, input, output, env):
r = Request(input, output, env)
r.publication = self.pub
return r

class TestPublisherFileSystem(FileSystemTests, TestCase):

def setUp(self):
root = demofs.Directory()
root.grant('bob', demofs.write)
fs = DemoFileSystem(root, 'bob')
fs.mkdir(self.dir_name)
fs.writefile(self.file_name, StringIO(self.file_contents))
fs.writefile(self.unwritable_filename, StringIO("save this"))
fs.get(self.unwritable_filename).revoke('bob', demofs.write)

self.filesystem = PublisherFileSystem('bob', RequestFactory(fs))

def test_suite():
return TestSuite((
makeSuite(TestPublisherFileSystem),
))

if __name__=='__main__':
main(defaultTest='test_suite')
8 changes: 4 additions & 4 deletions http/tests/test_commonaccesslogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def test_default_constructor(self):
self.assert_(logger.output.logger.name, 'accesslog')
self.assert_(logger.output.logger.level, logging.INFO)

# XXX please add unit tests for other methods as well:
# compute_timezone_for_log
# log_date_string
# log
# TODO: please add unit tests for other methods as well:
# compute_timezone_for_log
# log_date_string
# log


def test_suite():
Expand Down
Loading

0 comments on commit c4c25ae

Please sign in to comment.