Skip to content

Commit

Permalink
Fix error logging tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklaus Johner committed Jan 4, 2021
1 parent 80a4258 commit 5810cb7
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions opengever/bundle/tests/test_os_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from opengever.bundle.sections.constructor import BUNDLE_GUID_KEY
from opengever.globalindex.handlers.task import TaskSqlSyncer
from opengever.maintenance.scripts.repository_migration_analyse import MigrationPreconditionsError
from opengever.maintenance.scripts.repository_migration_analyse import MigrationValidationError
from opengever.maintenance.scripts.repository_migration_analyse import OperationItem
from opengever.maintenance.scripts.repository_migration_analyse import RepositoryExcelAnalyser
from opengever.maintenance.scripts.repository_migration_analyse import RepositoryMigrator
Expand All @@ -33,7 +32,7 @@ def emit(self, record):
self.log_list.append(record.msg)


logger = logging.getLogger('migration')
logger = logging.getLogger('opengever.maintenance')


class TestOSMigrationAnalysisPreconditions(IntegrationTestCase):
Expand Down Expand Up @@ -434,6 +433,9 @@ def test_repository_excel_analyser_os_test_invalid(self):
self.assertIn(
"could not find new parent for create operation.",
log_list[2])
self.assertIn(
"Invalid operation: parent not found.",
log_list[3])

guid = invalid_rows[3]['new_position_guid']
self.assertEqual(
Expand All @@ -459,7 +461,7 @@ def test_repository_excel_analyser_os_test_invalid(self):
'repository_depth_violated': False,
'uid': None},
invalid_rows[3])
self.assertIn("leaf node principle violated", log_list[3])
self.assertIn("leaf node principle violated", log_list[4])

guid = invalid_rows[4]['new_position_guid']
parent_guid = invalid_rows[4]['new_position_parent_guid']
Expand Down Expand Up @@ -488,7 +490,7 @@ def test_repository_excel_analyser_os_test_invalid(self):
invalid_rows[4])
self.assertIn(
"repository depth violated.",
log_list[4])
log_list[5])

logger.removeHandler(handler)

Expand Down Expand Up @@ -1690,8 +1692,8 @@ def test_validation_fails_if_title_is_not_set_correctly(self):
migrator.validate()

self.branch_repofolder.title_de = "modified"
with self.assertRaises(MigrationValidationError):
migrator.validate()
migrator.validate()
self.assertTrue(migrator.validation_failed)

self.assertEqual([self.branch_repofolder.UID()],
migrator.validation_errors.keys())
Expand All @@ -1717,8 +1719,8 @@ def test_validation_fails_if_uid_cannot_be_resolved(self):
migrator.validate()

migrator.operations_list[0]['uid'] = "foo"
with self.assertRaises(MigrationValidationError):
migrator.validate()
migrator.validate()
self.assertTrue(migrator.validation_failed)

self.assertEqual(0, len(migrator.validation_errors))
self.assertTrue(migrator.validation_failed)
Expand All @@ -1742,8 +1744,8 @@ def test_validation_fails_if_data_is_not_consistent(self):
self.branch_repofolder.title_de = "modified"
self.branch_repofolder.reindexObject()
self.branch_repofolder.title_de = initial_title
with self.assertRaises(MigrationValidationError):
migrator.validate()
migrator.validate()
self.assertTrue(migrator.validation_failed)

self.assertEqual([self.branch_repofolder.UID()],
migrator.validation_errors.keys())
Expand Down

0 comments on commit 5810cb7

Please sign in to comment.