'Tests the find_flavor_by_name_or_id function.'

def test_find_flavor_by_name_or_id(self):

    flav_id = str(uuid.uuid4())
    flav_name = 'X-Large'
    my_flavor = mock.MagicMock()
    my_flavor.name = flav_name
    my_flavor.id = flav_id
    self.nova_client.flavors.get.side_effect = [my_flavor, nova_exceptions.NotFound(''), nova_exceptions.NotFound('')]
    self.nova_client.flavors.find.side_effect = [my_flavor, nova_exceptions.NotFound('')]
    self.assertEqual(flav_id, self.nova_plugin.find_flavor_by_name_or_id(flav_id))
    self.assertEqual(flav_id, self.nova_plugin.find_flavor_by_name_or_id(flav_name))
    self.assertRaises(nova_exceptions.ClientException, self.nova_plugin.find_flavor_by_name_or_id, 'noflavor')
    self.assertEqual(3, self.nova_client.flavors.get.call_count)
    self.assertEqual(2, self.nova_client.flavors.find.call_count)
