def test_migrate(self): migration.migrate(dry_run=False) assert_equal( DropboxUserSettings.find().count(), 6 ) assert_equal( DropboxNodeSettings.find().count(), 3 ) for user_settings in DropboxUserSettings.find(): assert_is_not_none(user_settings.owner) assert_false(hasattr(user_settings, 'access_token')) for node_settings in DropboxNodeSettings.find(): assert_is_not_none(node_settings.owner) if ( not node_settings.user_settings or not node_settings.external_account ): assert_in( node_settings.folder, map( lambda d: d['folder'], self.unauthorized_node_settings_documents ) )
def test_remove_old_documents(self): user_settings_collection = database['dropboxusersettings'] old_user_settings = list(user_settings_collection.find()) old_user_settings_count = user_settings_collection.count() node_settings_collection = database['dropboxnodesettings'] old_node_settings = list(node_settings_collection.find()) old_node_settings_count = node_settings_collection.count migration.migrate(dry_run=False, remove_old=False) assert_equal( database['dropboxusersettings'].count(), 15 ) # 3 + 3 + 3 + 6 (non-deleted) assert_equal( database['dropboxnodesettings'].count(), 9 ) # 3 + 3 + 3 migration.remove_old_documents( old_user_settings, old_user_settings_count, old_node_settings, old_node_settings_count, dry_run=False ) assert_equal( database['dropboxusersettings'].count(), 6 ) assert_equal( database['dropboxnodesettings'].count(), 3 )
def test_migrate(self): migration.migrate(dry_run=False) assert_equal(DropboxUserSettings.find().count(), 6) assert_equal(DropboxNodeSettings.find().count(), 3) for user_settings in DropboxUserSettings.find(): assert_is_not_none(user_settings.owner) assert_false(hasattr(user_settings, 'access_token')) for node_settings in DropboxNodeSettings.find(): assert_is_not_none(node_settings.owner) if (not node_settings.user_settings or not node_settings.external_account): assert_in( node_settings.folder, map(lambda d: d['folder'], self.unauthorized_node_settings_documents))
def test_remove_old_documents(self): user_settings_collection = database['dropboxusersettings'] old_user_settings = list(user_settings_collection.find()) old_user_settings_count = user_settings_collection.count() node_settings_collection = database['dropboxnodesettings'] old_node_settings = list(node_settings_collection.find()) old_node_settings_count = node_settings_collection.count migration.migrate(dry_run=False, remove_old=False) assert_equal(database['dropboxusersettings'].count(), 15) # 3 + 3 + 3 + 6 (non-deleted) assert_equal(database['dropboxnodesettings'].count(), 9) # 3 + 3 + 3 migration.remove_old_documents(old_user_settings, old_user_settings_count, old_node_settings, old_node_settings_count, dry_run=False) assert_equal(database['dropboxusersettings'].count(), 6) assert_equal(database['dropboxnodesettings'].count(), 3)