[Zope-Checkins] CVS: Zope3/lib/python/Zope/Security/tests - test_Proxy.py:1.1.2.1 testSecProxy.py:NONE

Guido van Rossum guido@python.org
Thu, 18 Apr 2002 11:20:52 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv21683/tests

Added Files:
      Tag: SecurityProxy-branch
	test_Proxy.py 
Removed Files:
      Tag: SecurityProxy-branch
	testSecProxy.py 
Log Message:
Got rid of secproxy subpackage, the C code is now a module _Proxy.c.

=== Added File Zope3/lib/python/Zope/Security/tests/test_Proxy.py ===
import unittest

from Zope.Security._Proxy import _Proxy

class Checker:
    def check_getattr(self, object, name):
        ##print "check_getattr", (object, name)
        if name != "foo":
            raise RuntimeError
        return "hello"
    def proxy(self, value, checked):
        ##print "proxy", (value, checked)
        return [value, checked]

class Something:
    foo = "whatever"

class ProxyTests(unittest.TestCase):

    def setUp(self):
        self.x = Something()
        self.c = Checker()
        self.p = _Proxy(self.x, self.c)

    def testStr(self):
        self.assertEqual(str(self.p), str(self.x))

    def testRepr(self):
        self.assertEqual(repr(self.p), repr(self.x))

    def testGetAttrOK(self):
        self.assertEqual(self.p.foo, ["whatever", "hello"])

    def testGetAttrFail(self):
        try:
            self.p.bar
        except RuntimeError:
            pass
        else:
            self.fail("p.bar didn't raise RuntimeError")

def test_suite():
    return unittest.makeSuite(ProxyTests)

=== Removed File Zope3/lib/python/Zope/Security/tests/testSecProxy.py ===