'Tests the find_image_by_name_or_id function.'

def test_find_image_by_name_or_id(self):

    img_id = str(uuid.uuid4())
    img_name = 'myfakeimage'
    self.my_image.id = img_id
    self.my_image.name = img_name
    self.glance_client.images.get.side_effect = [self.my_image, exc.HTTPNotFound(), exc.HTTPNotFound(), exc.HTTPNotFound()]
    self.glance_client.images.list.side_effect = [[self.my_image], [], [self.my_image, self.my_image]]
    self.assertEqual(img_id, self.glance_plugin.find_image_by_name_or_id(img_id))
    self.assertEqual(img_id, self.glance_plugin.find_image_by_name_or_id(img_name))
    self.assertRaises(exception.EntityMatchNotFound, self.glance_plugin.find_image_by_name_or_id, 'noimage')
    self.assertRaises(exception.EntityUniqueMatchNotFound, self.glance_plugin.find_image_by_name_or_id, 'myfakeimage')
