From c2a324dbba3252599073edec7cabfb04f44bbbf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 2 Aug 2007 13:20:45 +0000
Subject: [PATCH] test that 'form' is correct in the TALES context of a
 proxyfield.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15418 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/tests/testFields.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/product/ERP5Form/tests/testFields.py b/product/ERP5Form/tests/testFields.py
index e240a0aa8e..01e12ed435 100644
--- a/product/ERP5Form/tests/testFields.py
+++ b/product/ERP5Form/tests/testFields.py
@@ -161,7 +161,7 @@ class TestProxyField(unittest.TestCase):
     self.assertEquals('container', self.container.getId())
     self.assertEquals('container', proxy_field.get_value('default'))
 
-  def test_tales_context(self):
+  def test_field_tales_context(self):
     # in the TALES context, "field" will be the proxyfield, not the original
     # field.
     self.container.Base_viewProxyFieldLibrary.manage_addField(
@@ -178,6 +178,22 @@ class TestProxyField(unittest.TestCase):
     # 'my_reference' is the ID of the proxy field
     self.assertEquals('my_reference', proxy_field.get_value('title'))
 
+  def test_form_tales_context(self):
+    # in the TALES context, "form" will be the form containing the proxyfield,
+    # not the original form (ie. the field library).
+    self.container.Base_viewProxyFieldLibrary.manage_addField(
+                        'my_title', 'Title', 'StringField')
+    original_field = self.container.Base_viewProxyFieldLibrary.my_title
+    original_field.manage_tales_xmlrpc(dict(title='form/getId'))
+    self.assertEquals('Base_viewProxyFieldLibrary',
+                       original_field.get_value('title'))
+
+    self.container.Base_view.manage_addField(
+                      'my_title', 'Title', 'ProxyField')
+    proxy_field = self.container.Base_view.my_title
+    proxy_field.manage_edit_xmlrpc(dict(form_id='Base_viewProxyFieldLibrary',
+                                        field_id='my_title',))
+    self.assertEquals('Base_view', proxy_field.get_value('title'))
 
 
 def test_suite():
-- 
2.30.9