def test_migration(self):
        GoogleDriveUserSettings.remove()

        user = UserFactory()
        node = ProjectFactory(creator=user)
        account = GoogleDriveAccountFactory()

        user.external_accounts = [account]

        user.add_addon('googledrive', auth=Auth(user))
        user_addon = user.get_addon('googledrive')
        user_addon.save()


        node.add_addon('googledrive', auth=Auth(user))
        node_addon = node.get_addon('googledrive')
        node_addon.foreign_user_settings = user_addon
        node_addon.folder_id = 'abcdef0'
        node_addon.folder_path = '/'
        node_addon.save()

        assert_equal(node_addon.external_account, None)
        assert_equal(node_addon.folder_id, 'abcdef0')

        do_migration()
        node_addon.reload()

        assert_equal(node_addon.external_account, account)
        assert_equal(node_addon.folder_id, 'abcdef0')
        assert_equal(node_addon.folder_path, '/')
        assert_equal(node_addon.folder_name, '/ (Full Google Drive)')
    def test_migration_no_account(self):
        GoogleDriveUserSettings.remove()

        user = UserFactory()
        node = ProjectFactory(creator=user)

        user.add_addon('googledrive', auth=Auth(user))
        user_addon = user.get_addon('googledrive')
        user_addon.save()

        node.add_addon('googledrive', auth=Auth(user))
        node_addon = node.get_addon('googledrive')
        node_addon.foreign_user_settings = user_addon
        node_addon.save()

        do_migration()  # Would raise exception if fail