Commit c1482525 authored by Jérome Perrin's avatar Jérome Perrin

IDTool: check that export / import also work when use clear=True

parent d7fca2a4
......@@ -297,6 +297,7 @@ class TestIdTool(ERP5TypeTestCase):
generator.importGeneratorIdDict(id_dict={'06':6})
self.assertEquals(7, self.id_tool.generateNewId(id_generator=id_generator,
id_group='06'))
def test_06_ExportImportDict(self):
"""
Check export import dict for generator sql and zodb
......@@ -304,6 +305,38 @@ class TestIdTool(ERP5TypeTestCase):
self.checkExportImportDict(id_generator='test_application_zodb')
self.checkExportImportDict(id_generator='test_application_sql')
def checkExportClearImportDict(self, id_generator):
"""
Check export clear import on id generator
"""
generator = self.getLastGenerator(id_generator)
self.assertEquals(0, self.id_tool.generateNewId(id_generator=id_generator,
id_group='07'))
id_dict = generator.exportGeneratorIdDict()
id_dict_before = dict(id_dict)
generator.importGeneratorIdDict(id_dict=id_dict, clear=True)
# make sure it is reimported properly
self.assertEquals(id_dict_before, generator.exportGeneratorIdDict())
# make sure generating a new id will increment
self.assertEquals(1, self.id_tool.generateNewId(id_generator=id_generator,
id_group='07'))
self.assertEquals(0, self.id_tool.generateNewId(id_generator=id_generator,
id_group='another_group'))
# reimport clearing, the group we just use should have been cleared out
generator.importGeneratorIdDict(id_dict=id_dict, clear=True)
id_dict = generator.exportGeneratorIdDict()
self.assertFalse('another_group' in id_dict, id_dict)
def test_06_ExportClearImportDict(self):
"""
Check export clear import dict for generator sql and zodb
"""
self.checkExportClearImportDict(id_generator='test_application_zodb')
self.checkExportClearImportDict(id_generator='test_application_sql')
def test_07_checkImportValueAndStoreInterval(self):
"""
Check that the store_interval store the last_id every N increments
......
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