def test_doesnt_raise_if_not_strict_and_user_doesnt_exist(self): migrator = CreatorMigrator( self.portal, {'old.user': '******'}, 'move', strict=False) migrator.migrate() self.assertEquals(('doesnt.exist', ), self.dossier.creators) self.assertEquals(('doesnt.exist', ), self.doc.creators)
def execute(self, principal_mapping, mode): migrator = CreatorMigrator(self.portal, principal_mapping, mode=mode, strict=True) results = migrator.migrate() return results
def test_returns_proper_results_for_moving_creator(self): migrator = CreatorMigrator( self.portal, {'old.user': '******'}, 'move') results = migrator.migrate() self.assertEquals( [ ('/plone/dossier-1', 'old.user', 'new.user'), ('/plone/dossier-1/document-1', 'old.user', 'new.user'), ], results['creators']['moved'] )
def test_creator_index_gets_updated(self): migrator = CreatorMigrator( self.portal, {'old.user': '******'}, 'move') migrator.migrate() # Index should be up to date self.assertEquals('new.user', index_data_for(self.dossier).get('Creator')) self.assertEquals('new.user', index_data_for(self.doc).get('Creator')) # Metadata should be up to date self.assertEquals(('new.user', ), obj2brain(self.dossier).listCreators) self.assertEquals(('new.user', ), obj2brain(self.doc).listCreators) self.assertEquals('new.user', obj2brain(self.dossier).Creator) self.assertEquals('new.user', obj2brain(self.doc).Creator)
def test_raises_if_strict_and_user_doesnt_exist(self): migrator = CreatorMigrator( self.portal, {'old.user': '******'}, 'move') with self.assertRaises(UserMigrationException): migrator.migrate()
def test_uppercase_creator_accessor_works_after_migration(self): migrator = CreatorMigrator( self.portal, {'old.user': '******'}, 'move') migrator.migrate() self.assertEquals('new.user', self.dossier.Creator()) self.assertEquals('new.user', self.doc.Creator())
def test_creators_get_migrated(self): migrator = CreatorMigrator( self.portal, {'old.user': '******'}, 'move') migrator.migrate() self.assertEquals(('new.user',), self.dossier.creators) self.assertEquals(('new.user',), self.doc.creators)