Commit 72d2191f authored by Jérome Perrin's avatar Jérome Perrin

update test for new Base_getCategoriesSpreadSheetMapping parameter for error

reporting


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24909 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 76b1a106
...@@ -304,13 +304,13 @@ class TestOOoImport(ERP5TypeTestCase): ...@@ -304,13 +304,13 @@ class TestOOoImport(ERP5TypeTestCase):
self.assertEquals(['france'], list(region.europe.france.europe.objectIds())) self.assertEquals(['france'], list(region.europe.france.europe.objectIds()))
self.assertEquals([], list(region.europe.france.europe.france.objectIds())) self.assertEquals([], list(region.europe.france.europe.france.objectIds()))
def test_CategoryTool_importCategoryFile_DuplicateIdsAtSameLevel(self): def test_Base_getCategoriesSpreadSheetMapping_DuplicateIdsAtSameLevel(self):
# tests CategoryTool_importCategoryFile when a document contain same # tests Base_getCategoriesSpreadSheetMapping when a document contain same
# categories ID at the same level, in that case, a ValueError is raised # categories ID at the same level, in that case, a ValueError is raised
import_file = makeFileUpload( import_file = makeFileUpload(
'import_region_category_duplicate_ids_same_level.sxc') 'import_region_category_duplicate_ids_same_level.sxc')
try: try:
self.portal.portal_categories.CategoryTool_importCategoryFile( self.portal.portal_categories.Base_getCategoriesSpreadSheetMapping(
import_file=import_file) import_file=import_file)
except ValueError, error: except ValueError, error:
# 'france' is the duplicate ID in this spreadsheet # 'france' is the duplicate ID in this spreadsheet
...@@ -318,6 +318,22 @@ class TestOOoImport(ERP5TypeTestCase): ...@@ -318,6 +318,22 @@ class TestOOoImport(ERP5TypeTestCase):
else: else:
self.fail('ValueError not raised') self.fail('ValueError not raised')
# Base_getCategoriesSpreadSheetMapping performs checks on the spreadsheet,
# an "invalid spreadsheet" error handler can be provided, to report errors
# nicely.
message_list = []
def on_invalid_spreadsheet(message):
message_list.append(message)
import_file = makeFileUpload(
'import_region_category_duplicate_ids_same_level.sxc')
self.portal.portal_categories.Base_getCategoriesSpreadSheetMapping(import_file,
invalid_spreadsheet_error_handler=on_invalid_spreadsheet)
self.assertEquals(1, len(message_list))
self.assertTrue('france' in str(message_list[0]))
# simple OOoParser tests # simple OOoParser tests
def test_getSpreadSheetMapping(self): def test_getSpreadSheetMapping(self):
parser = OOoParser() parser = OOoParser()
......
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