From 1961724477df6a8f46da773fb2239e88207a154b Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Thu, 8 Apr 2010 11:34:52 +0000
Subject: [PATCH] Add general purpose scripts to determine file system tests
 documents location. These scripts are useful to make a real user file upload
 in automated selenium tests (if respective browser security settings does
 allow it).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34379 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../SeleniumTestUtils.py                      |  42 ++++++
 .../Zuite_getFilenameLocation.xml             | 133 ++++++++++++++++++
 .../Zuite_getTestDocumentsHome.xml            |  31 ++++
 bt5/erp5_ui_test_core/bt/revision             |   2 +-
 .../bt/template_extension_id_list             |   3 +-
 5 files changed, 209 insertions(+), 2 deletions(-)
 create mode 100644 bt5/erp5_ui_test_core/ExtensionTemplateItem/SeleniumTestUtils.py
 create mode 100644 bt5/erp5_ui_test_core/SkinTemplateItem/portal_skins/erp5_ui_test_core/Zuite_getFilenameLocation.xml
 create mode 100644 bt5/erp5_ui_test_core/SkinTemplateItem/portal_skins/erp5_ui_test_core/Zuite_getTestDocumentsHome.xml

diff --git a/bt5/erp5_ui_test_core/ExtensionTemplateItem/SeleniumTestUtils.py b/bt5/erp5_ui_test_core/ExtensionTemplateItem/SeleniumTestUtils.py
new file mode 100644
index 0000000000..df24dafb1d
--- /dev/null
+++ b/bt5/erp5_ui_test_core/ExtensionTemplateItem/SeleniumTestUtils.py
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2002-2009 Nexedi SA and Contributors. All Rights Reserved.
+#                  Ivan Tyagov <ivan@nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+from App.config import getConfiguration
+from os import sep
+
+def Zuite_getTestDocumentsHome(self):
+  """
+    Get test documents folder as string.
+  """
+  instance_home_path = getConfiguration().instancehome
+  instance_home_elements = instance_home_path.split(sep)[:-1]
+  instance_home_elements.append('test_documents')
+  documents_home = sep.join(instance_home_elements)
+  return documents_home
+  
+  
diff --git a/bt5/erp5_ui_test_core/SkinTemplateItem/portal_skins/erp5_ui_test_core/Zuite_getFilenameLocation.xml b/bt5/erp5_ui_test_core/SkinTemplateItem/portal_skins/erp5_ui_test_core/Zuite_getFilenameLocation.xml
new file mode 100644
index 0000000000..a9d0203c17
--- /dev/null
+++ b/bt5/erp5_ui_test_core/SkinTemplateItem/portal_skins/erp5_ui_test_core/Zuite_getFilenameLocation.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_body</string> </key>
+            <value> <string>test_documents_home = context.Zuite_getTestDocumentsHome()\n
+return \'%s/%s\' %(test_documents_home, filename)\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>filename</string> </value>
+        </item>
+        <item>
+            <key> <string>_proxy_roles</string> </key>
+            <value>
+              <tuple>
+                <string>Manager</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>errors</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_code</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>co_argcount</string> </key>
+                        <value> <int>1</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>filename</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>test_documents_home</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Zuite_getFilenameLocation</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_ui_test_core/SkinTemplateItem/portal_skins/erp5_ui_test_core/Zuite_getTestDocumentsHome.xml b/bt5/erp5_ui_test_core/SkinTemplateItem/portal_skins/erp5_ui_test_core/Zuite_getTestDocumentsHome.xml
new file mode 100644
index 0000000000..bdc084f860
--- /dev/null
+++ b/bt5/erp5_ui_test_core/SkinTemplateItem/portal_skins/erp5_ui_test_core/Zuite_getTestDocumentsHome.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_function</string> </key>
+            <value> <string>Zuite_getTestDocumentsHome</string> </value>
+        </item>
+        <item>
+            <key> <string>_module</string> </key>
+            <value> <string>SeleniumTestUtils</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Zuite_getTestDocumentsHome</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string></string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_ui_test_core/bt/revision b/bt5/erp5_ui_test_core/bt/revision
index dec2bf5d61..2edeafb09d 100644
--- a/bt5/erp5_ui_test_core/bt/revision
+++ b/bt5/erp5_ui_test_core/bt/revision
@@ -1 +1 @@
-19
\ No newline at end of file
+20
\ No newline at end of file
diff --git a/bt5/erp5_ui_test_core/bt/template_extension_id_list b/bt5/erp5_ui_test_core/bt/template_extension_id_list
index ad5c4c763a..1053dd69d2 100644
--- a/bt5/erp5_ui_test_core/bt/template_extension_id_list
+++ b/bt5/erp5_ui_test_core/bt/template_extension_id_list
@@ -1 +1,2 @@
-MailHostUtils
\ No newline at end of file
+MailHostUtils
+SeleniumTestUtils
\ No newline at end of file
-- 
2.30.9