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