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

Anthony Baxter anthony@interlink.com.au
Sat, 2 Aug 2003 05:11:47 -0400


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

Modified Files:
	test_add.py 
Log Message:
Backing out philiKON's changes - they broke the functional tests, and
from his signoff on IRC, I don't think he's going to be around until 
Monday. As I'm working on the Catalog functional tests, this is pretty
annoying. I tried to figure out how to just back out bits til I found the
broken stuff, but it's a pretty serious refactoring. I'll send a message
to zope3-checkins with the CVS commands used for this, so that someone
can undo the backout if they wish.


=== Zope3/src/zope/app/browser/form/tests/test_add.py 1.17 => 1.18 ===
--- Zope3/src/zope/app/browser/form/tests/test_add.py:1.17	Sat Aug  2 03:03:59 2003
+++ Zope3/src/zope/app/browser/form/tests/test_add.py	Sat Aug  2 05:11:12 2003
@@ -37,8 +37,14 @@
 
 class Context:
 
-    def action(self, discriminator, callable, args=(), kw={}):
-        self.last_action = (discriminator, callable, args, kw)
+    def resolve(self, name):
+        l = name.rfind('.')
+        if l >= 0:
+            # eek, we got a real dotted name
+            m = sys.modules[name[:l]]
+            return getattr(m, name[l+1:])
+        else:
+            return globals()[name]
 
 class I(Interface):
 
@@ -90,17 +96,16 @@
 class Test(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
-        self._context = Context()
         PlacelessSetup.setUp(self)
         provideAdapter(IFoo, IBar, FooBarAdapter)
 
-    def _invoke_add(self, schema=I, name="addthis", permission="zope.Public",
-                    label="Add this", content_factory=C, class_=V,
-                    arguments=['first', 'last'], keyword_arguments=['email'],
-                    set_before_add=['getfoo'], set_after_add=['extra1'],
+    def _invoke_add(self, schema="I", name="addthis", permission="zope.Public",
+                    label="Add this", content_factory="C", class_="V",
+                    arguments="first last", keyword_arguments="email",
+                    set_before_add="getfoo", set_after_add="extra1",
                     fields=None):
         """ Call the 'add' factory to process arguments into 'args'."""
-        return add(self._context,
+        return add(Context(),
                    schema=schema,
                    name=name,
                    permission=permission,
@@ -115,31 +120,31 @@
                    )
 
     def test_add_no_fields(self):
-        _context = self._context
-        self._invoke_add()
-        result1 = _context.last_action
-        self._invoke_add(
-            fields="name first last email address getfoo extra1 extra2".split(),
+
+        result1 = self._invoke_add()
+        result2 = self._invoke_add(
+            fields="name first last email address getfoo extra1 extra2",
             )
-        result2 = _context.last_action
 
         self.assertEqual(result1, result2)
 
     def test_add_error_handling(self):
+
+        result1 = self._invoke_add(fields="first last email getfoo extra1")
         # cannot use a field in arguments if it is not mentioned in fields
-        self.assertRaises(ValueError, self._invoke_add, fields="first email getfoo extra1".split())
+        self.assertRaises(ValueError, self._invoke_add, fields="first email getfoo extra1")
         # cannot use a field in keyword_arguments if it is not mentioned in fields
-        self.assertRaises(ValueError, self._invoke_add, fields="first last getfoo extra1".split())
+        self.assertRaises(ValueError, self._invoke_add, fields="first last getfoo extra1")
         # cannot use a field in set_before_add if it is not mentioned in fields
-        self.assertRaises(ValueError, self._invoke_add, fields="first last email extra1".split())
+        self.assertRaises(ValueError, self._invoke_add, fields="first last email extra1")
         # cannot use a field in set_after_add if it is not mentioned in fields
-        self.assertRaises(ValueError, self._invoke_add, fields="first last email getfoo".split())
+        self.assertRaises(ValueError, self._invoke_add, fields="first last email getfoo")
         # cannot use an optional field in arguments
-        self.assertRaises(ValueError, self._invoke_add, arguments=["extra2"])
+        self.assertRaises(ValueError, self._invoke_add, arguments="extra2")
 
     def test_add(self, args=None):
-        self._invoke_add()
-        (descriminator, callable, args, kw) = self._context.last_action
+
+        [(descriminator, callable, args, kw)] = self._invoke_add()
 
         self.assertEqual(descriminator,
                          ('view', IAdding, "addthis", IBrowserPresentation,
@@ -197,8 +202,7 @@
                 return "."
 
         adding = Adding(self)
-        self._invoke_add()
-        (descriminator, callable, args, kw) = self._context.last_action
+        [(descriminator, callable, args, kw)] = self._invoke_add()
         factory = AddViewFactory(*args)
         request = TestRequest()
         view = getView(adding, 'addthis', request)
@@ -230,8 +234,7 @@
                 return "."
 
         adding = Adding(self)
-        self._invoke_add()
-        (descriminator, callable, args, kw) = self._context.last_action
+        [(descriminator, callable, args, kw)] = self._invoke_add()
         factory = AddViewFactory(*args)
         request = TestRequest()
         view = getView(adding, 'addthis', request)
@@ -260,14 +263,12 @@
                 return "."
 
         adding = Adding(self)
-        self._invoke_add(
-            schema=IBar, name="addthis", permission="zope.Public",
-            label="Add this", content_factory=Foo, class_=FooV,
-            arguments=None, keyword_arguments=None,
-            set_before_add=["bar"], set_after_add=None,
-            fields=None
-            )
-        (descriminator, callable, args, kw) = self._context.last_action
+        [(descriminator, callable, args, kw)] = self._invoke_add(
+            schema="IBar", name="addthis", permission="zope.Public",
+            label="Add this", content_factory="Foo", class_="FooV",
+            arguments="", keyword_arguments="",
+            set_before_add="bar", set_after_add="",
+            fields=None)
         factory = AddViewFactory(*args)
         request = TestRequest()
         view = getView(adding, 'addthis', request)
@@ -280,8 +281,7 @@
             implements(IAdding)
 
         adding = Adding()
-        self._invoke_add()
-        (descriminator, callable, args, kw) = self._context.last_action
+        [(descriminator, callable, args, kw)] = self._invoke_add()
         factory = AddViewFactory(*args)
         request = TestRequest()