From 105a2ed7df89cd55ca76fa84196ace8249747223 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Mon, 11 May 2009 16:20:22 +0000
Subject: [PATCH] Test that all listboxes have a callable ListMethod

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26912 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testXHTML.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/product/ERP5/tests/testXHTML.py b/product/ERP5/tests/testXHTML.py
index 806783a45f..9937e7db93 100644
--- a/product/ERP5/tests/testXHTML.py
+++ b/product/ERP5/tests/testXHTML.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 # Copyright (c) 2007 Nexedi SARL and Contributors. All Rights Reserved.
@@ -159,6 +160,28 @@ class TestXHTML(ERP5TypeTestCase):
             error_list.append(form_path)
     self.assertEquals(error_list, [])
 
+  def test_executableListMethodInListbox(self):
+    # check all list_method in listboxes
+    skins_tool = self.portal.portal_skins
+    error_list = []
+    for form_path, form in skins_tool.ZopeFind(
+              skins_tool, obj_metatypes=['ERP5 Form'], search_sub=1):
+      try:
+       fields = form.get_fields()
+      except AttributeError, e:
+        print "%s is broken: %s" % (form_path, e)
+      for field in fields:
+        if field.meta_type == 'ListBox':
+          list_method = field.get_value("list_method")
+          if list_method:
+            if isinstance(list_method, str):
+              method = getattr(self.portal, list_method)
+            else:
+              method = list_method
+            if not callable(method):
+              error_list.append(form_path)
+    self.assertEquals(error_list, [])
+
 class W3Validator(object):
 
   def __init__(self, validator_path, show_warnings):
-- 
2.30.9