[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests - test_editwizardview.py:1.1 test_editview.py:1.18

Dominik Huber dominik.huber at projekt01.ch
Thu Feb 26 05:28:42 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv13588

Modified Files:
	test_editview.py 
Added Files:
	test_editwizardview.py 
Log Message:
- bug fix: schemadisplay.DisplayView and 
  editwizard.EditWizardView missing imports (own mistake, excuse me)
- add _setupWidget test for editwizard
- needless imports removed
- todo: test for displayview


=== Added File Zope3/src/zope/app/browser/form/tests/test_editwizardview.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""$Id: test_editwizardview.py,v 1.1 2004/02/26 10:28:41 dominikhuber Exp $
"""
import unittest

from zope.interface import Interface, implements
from zope.publisher.browser import TestRequest
from zope.schema import TextLine, accessors
from zope.schema.interfaces import ITextLine
from zope.security.checker import InterfaceChecker, ProxyFactory

from zope.app.tests import ztapi
from zope.app.tests.placelesssetup import PlacelessSetup

from zope.app.browser.form.editwizard import EditWizardView
from zope.app.browser.form.widget import TextWidget


class I(Interface):
    foo = TextLine(title=u"Foo")
    bar = TextLine(title=u"Bar")
    a   = TextLine(title=u"A")
    b   = TextLine(title=u"B", min_length=0, required=False)
    getbaz, setbaz = accessors(TextLine(title=u"Baz"))

class EV(EditWizardView):
    schema = I
    object_factories = []
    use_session = None

class C:
    implements(I)
    foo = u"c foo"
    bar = u"c bar"
    a   = u"c a"
    b   = u"c b"

    _baz = u"c baz"
    def getbaz(self): return self._baz
    def setbaz(self, v): self._baz = v


class IFoo(Interface):
    foo = TextLine(title=u"Foo")

class IBar(Interface):
    bar = TextLine(title=u"Bar")

class Foo:
    implements(IFoo)

    foo = u'Foo foo'
    
class ConformFoo(object):
    implements(IFoo)

    foo = u'Foo foo'

    def __conform__(self, interface):
        # fake proxied adapter (attention only read proxy)        
        if interface is IBar:
            checker = InterfaceChecker(IBar)
            return ProxyFactory(OtherFooBarAdapter(self), checker)

            
class FooBarAdapter(object):
    implements(IBar)
    __used_for__ = IFoo

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

    def getbar(self): return self.context.foo
    def setbar(self, v): self.context.foo = v

    bar = property(getbar, setbar)
    
class OtherFooBarAdapter(FooBarAdapter):
    pass

class BarV(EditWizardView):
    schema = IBar
    object_factories = []
    use_session = None

class Test(PlacelessSetup, unittest.TestCase):

    def setUp(self):
        super(Test, self).setUp()
        ztapi.browserView(ITextLine, 'edit', TextWidget)
        ztapi.setDefaultViewName(ITextLine, "edit")
        ztapi.provideAdapter(IFoo, IBar, FooBarAdapter)

    def test_setUpWidget(self):
        c = C()
        request = TestRequest()
        v = EV(c, request)

    def test_setUpWidget_via_adapter(self):
        f = Foo()
        request = TestRequest()
        v = BarV(f, request)

    def test_setUpWidget_via_conform_adapter(self):        
        f = ConformFoo()
        request = TestRequest()
        v = BarV(f, request)
        
def test_suite():
    return unittest.makeSuite(Test)

if __name__=='__main__':
    unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_editview.py 1.17 => 1.18 ===
--- Zope3/src/zope/app/browser/form/tests/test_editview.py:1.17	Wed Feb 25 08:22:09 2004
+++ Zope3/src/zope/app/browser/form/tests/test_editview.py	Thu Feb 26 05:28:41 2004
@@ -15,18 +15,20 @@
 """
 import unittest
 
-from zope.app.tests import ztapi
-from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.app.event.tests.placelesssetup import getEvents
 from zope.interface import Interface, implements
+from zope.publisher.browser import TestRequest
 from zope.schema import TextLine, accessors
 from zope.schema.interfaces import ITextLine
-from zope.publisher.browser import TestRequest
-from zope.app.browser.form.editview import EditView
+from zope.component.exceptions import ComponentLookupError
+
 from zope.app.tests import ztapi
+from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.app.event.tests.placelesssetup import getEvents
+
+from zope.app.browser.form.editview import EditView
 from zope.app.browser.form.widget import TextWidget
 from zope.app.browser.form.submit import Update
-from zope.component.exceptions import ComponentLookupError
+
 
 class I(Interface):
     foo = TextLine(title=u"Foo")




More information about the Zope3-Checkins mailing list