'Tests that we handle a duplicate flavor when migrating and that
we handle when the exception message is in unicode.'

@mock.patch('nova.objects.flavor.LOG.error')
def test_migrate_flavors_duplicate_unicode(self, mock_log_error):

    main_flavor = _create_main_flavor(self.context)
    del main_flavor['id']
    api_flavor = ForcedFlavor(self.context, **main_flavor)
    api_flavor.create()
    with mock.patch.object(exception.FlavorIdExists, 'msg_fmt', u'\xf0\x9f\x92\xa9'):
        with mock.patch.object(exception.FlavorExists, 'msg_fmt', u'\xf0\x9f\x92\xa9'):
            (match, done) = flavor_obj.migrate_flavors(self.context, 50)
            self.assertEqual(1, match)
            self.assertEqual(0, done)
            mock_log_error.assert_called()
