Commit 83747669 authored by Aurel's avatar Aurel Committed by Jérome Perrin

zope4: manage_delObjects now raises BadRequest.

* Emtpy parameter.
* No argument.
parent c22842ce
...@@ -32,6 +32,7 @@ from unittest import expectedFailure ...@@ -32,6 +32,7 @@ from unittest import expectedFailure
from lxml import etree from lxml import etree
from Products.Formulator.FormToXML import formToXML from Products.Formulator.FormToXML import formToXML
from Products.Formulator.TALESField import TALESMethod from Products.Formulator.TALESField import TALESMethod
from zExceptions import BadRequest
from Products.Formulator.XMLToForm import XMLToForm from Products.Formulator.XMLToForm import XMLToForm
from Products.ERP5Form.ProxyField import BrokenProxyField from Products.ERP5Form.ProxyField import BrokenProxyField
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
...@@ -57,7 +58,10 @@ class TestProxyField(ERP5TypeTestCase): ...@@ -57,7 +58,10 @@ class TestProxyField(ERP5TypeTestCase):
"""Remove objects created in tests.""" """Remove objects created in tests."""
# Remove forms # Remove forms
custom_folder = self.getSkinsTool().custom custom_folder = self.getSkinsTool().custom
try:
custom_folder.manage_delObjects(custom_folder.objectIds()) custom_folder.manage_delObjects(custom_folder.objectIds())
except BadRequest:
pass
# Remove skin folders # Remove skin folders
if 'erp5_geek' in self.getSkinsTool().objectIds(): if 'erp5_geek' in self.getSkinsTool().objectIds():
......
...@@ -29,6 +29,7 @@ import unittest ...@@ -29,6 +29,7 @@ import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from erp5.component.test.testOrder import TestOrderMixin from erp5.component.test.testOrder import TestOrderMixin
from zExceptions import BadRequest
class TestRuleMixin(TestOrderMixin): class TestRuleMixin(TestOrderMixin):
""" """
...@@ -52,13 +53,19 @@ class TestRuleMixin(TestOrderMixin): ...@@ -52,13 +53,19 @@ class TestRuleMixin(TestOrderMixin):
return rule return rule
def _wipe(self, folder): def _wipe(self, folder):
try:
folder.manage_delObjects(list(folder.objectIds())) folder.manage_delObjects(list(folder.objectIds()))
except BadRequest:
pass
def afterSetUp(self): def afterSetUp(self):
# delete rules # delete rules
rule_tool = self.portal.portal_rules rule_tool = self.portal.portal_rules
try:
rule_tool.manage_delObjects(ids=[x.getId() for x in rule_tool.objectValues() rule_tool.manage_delObjects(ids=[x.getId() for x in rule_tool.objectValues()
if x.getVersion().startswith('testRule.')]) if x.getVersion().startswith('testRule.')])
except BadRequest:
pass
# recreate rules # recreate rules
self.createRule('default_order_rule', '1') self.createRule('default_order_rule', '1')
self.createRule('default_delivery_rule', '1') self.createRule('default_delivery_rule', '1')
......
...@@ -54,6 +54,7 @@ from erp5.component.test.testOrder import TestOrderMixin ...@@ -54,6 +54,7 @@ from erp5.component.test.testOrder import TestOrderMixin
from Products.ERP5Form.Selection import DomainSelection from Products.ERP5Form.Selection import DomainSelection
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from textwrap import dedent from textwrap import dedent
from zExceptions import BadRequest
class TestInventory(TestOrderMixin, ERP5TypeTestCase): class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
...@@ -115,10 +116,15 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -115,10 +116,15 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
for module in [ 'portal_simulation', for module in [ 'portal_simulation',
'inventory_module']: 'inventory_module']:
folder = self.portal[module] folder = self.portal[module]
try:
folder.manage_delObjects(list(folder.objectIds())) folder.manage_delObjects(list(folder.objectIds()))
except BadRequest:
pass
try:
self.portal.portal_skins.custom.manage_delObjects( self.portal.portal_skins.custom.manage_delObjects(
list(self.portal.portal_skins.custom.objectIds())) list(self.portal.portal_skins.custom.objectIds()))
except BadRequest:
pass
self.tic() self.tic()
def createCategory(self, parent, id_list): def createCategory(self, parent, id_list):
......
from zExceptions import BadRequest
portal_tests = container.portal_tests portal_tests = container.portal_tests
if test_zuite_relative_url is not None: if test_zuite_relative_url is not None:
# we care for a specific test zuite # we care for a specific test zuite
portal_tests = portal_tests.restrictedTraverse(test_zuite_relative_url,\ portal_tests = portal_tests.restrictedTraverse(test_zuite_relative_url,\
portal_tests) portal_tests)
# remove test results from previous test runs # remove test results from previous test runs
portal_tests.manage_delObjects([x.getId() \ try:
portal_tests.manage_delObjects([x.getId() \
for x in portal_tests.objectValues('Zuite Results')]) for x in portal_tests.objectValues('Zuite Results')])
except BadRequest:
pass
print "OK" print "OK"
return printed return printed
""" """
Create a zuite or return an existing one after remove his contents. Create a zuite or return an existing one after remove his contents.
""" """
from zExceptions import BadRequest
assert context.getPortalType() == "Test Tool", "bad context" assert context.getPortalType() == "Test Tool", "bad context"
if REQUEST: if REQUEST:
raise RuntimeError("You can not call this script from the URL") raise RuntimeError("You can not call this script from the URL")
...@@ -16,6 +17,8 @@ zuite = getattr(context.portal_tests, zuite_id) ...@@ -16,6 +17,8 @@ zuite = getattr(context.portal_tests, zuite_id)
if zuite.getMetaType() != "ERP5 Test Tool": if zuite.getMetaType() != "ERP5 Test Tool":
raise ValueError("Zuite is not a ERP5 Test Tool") raise ValueError("Zuite is not a ERP5 Test Tool")
zuite.manage_delObjects(zuite.objectIds()) try:
zuite.manage_delObjects(zuite.objectIds())
except BadRequest:
pass
return zuite return zuite
...@@ -43,6 +43,8 @@ from MySQLdb import ProgrammingError ...@@ -43,6 +43,8 @@ from MySQLdb import ProgrammingError
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import reindex from Products.ERP5Type.tests.utils import reindex
from zExceptions import BadRequest
import six import six
class InventoryAPITestCase(ERP5TypeTestCase): class InventoryAPITestCase(ERP5TypeTestCase):
...@@ -130,8 +132,14 @@ class InventoryAPITestCase(ERP5TypeTestCase): ...@@ -130,8 +132,14 @@ class InventoryAPITestCase(ERP5TypeTestCase):
'inventory_module', 'inventory_module',
self.folder.getId() ]: self.folder.getId() ]:
folder = self.portal[module] folder = self.portal[module]
try:
folder.manage_delObjects(list(folder.objectIds())) folder.manage_delObjects(list(folder.objectIds()))
except BadRequest:
pass
try:
self.portal.portal_skins.custom.manage_delObjects(list(self.portal.portal_skins.custom.objectIds())) self.portal.portal_skins.custom.manage_delObjects(list(self.portal.portal_skins.custom.objectIds()))
except BadRequest:
pass
self.tic() self.tic()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment