Improve TestLocalRoleManagement resilience

Don't fail if a previous --save test was interrupted before cleanup.

Delete in beforeTearDown() the person that was added on afterSetUp().
parent 71e8596e
...@@ -478,14 +478,19 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -478,14 +478,19 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
),) ),)
""") """)
# configure group, site, function categories # configure group, site, function categories
category_tool = self.getCategoryTool()
for bc in ['group', 'site', 'function']: for bc in ['group', 'site', 'function']:
base_cat = self.getCategoryTool()[bc] base_cat = category_tool[bc]
code = bc[0].upper() code = bc[0].upper()
if base_cat.get('subcat', None) is not None:
continue
base_cat.newContent(portal_type='Category', base_cat.newContent(portal_type='Category',
id='subcat', id='subcat',
codification="%s1" % code) codification="%s1" % code)
# add another function subcategory. # add another function subcategory.
self.getCategoryTool()['function'].newContent(portal_type='Category', function_category = category_tool['function']
if function_category.get('another_subcat', None) is not None:
function_category.newContent(portal_type='Category',
id='another_subcat', id='another_subcat',
codification='F2') codification='F2')
self.defined_category = "group/subcat\n"\ self.defined_category = "group/subcat\n"\
...@@ -505,11 +510,13 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -505,11 +510,13 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
site='subcat', site='subcat',
function='subcat' ) function='subcat' )
assignment.open() assignment.open()
self.person = pers
self.tic() self.tic()
def beforeTearDown(self): def beforeTearDown(self):
"""Called before teardown.""" """Called before teardown."""
# clear base categories # clear base categories
self.person.getParentValue().manage_delObjects([self.person.getId()])
for bc in ['group', 'site', 'function']: for bc in ['group', 'site', 'function']:
base_cat = self.getCategoryTool()[bc] base_cat = self.getCategoryTool()[bc]
base_cat.manage_delObjects(list(base_cat.objectIds())) base_cat.manage_delObjects(list(base_cat.objectIds()))
......
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