def test_not_found_because_flavor(self):
        req = self._get_request('1/os-extra_specs/key5',
                                use_admin_context=True)
        with mock.patch('patron.db.flavor_get_by_flavor_id') as mock_get:
            mock_get.side_effect = exception.FlavorNotFound(flavor_id='1')
            self.assertRaises(webob.exc.HTTPNotFound, self.controller.show,
                              req, 1, 'key5')
            self.assertRaises(webob.exc.HTTPNotFound,
                              self.controller.update,
                              req,
                              1,
                              'key5',
                              body={'key5': 'value5'})
            self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete,
                              req, 1, 'key5')

        req = self._get_request('1/os-extra_specs', use_admin_context=True)
        with mock.patch('patron.db.flavor_get_by_flavor_id') as mock_get:
            mock_get.side_effect = exception.FlavorNotFound(flavor_id='1')
            self.assertRaises(webob.exc.HTTPNotFound,
                              self.controller.create,
                              req,
                              1,
                              body={'extra_specs': {
                                  'key5': 'value5'
                              }})
Example #2
0
def fake_get_flavor_by_flavor_id(flavorid, ctxt=None, read_deleted='yes'):
    if flavorid == 'failtest':
        raise exception.FlavorNotFound(flavor_id=flavorid)
    elif not str(flavorid) == '1234':
        raise Exception("This test expects flavorid 1234, not %s" % flavorid)
    if read_deleted != 'no':
        raise test.TestingException("Should not be reading deleted")
    return fake_db_flavor(flavorid=flavorid)
 def fake_instance_type_extra_specs_update_or_create(*args, **kwargs):
     raise exception.FlavorNotFound(flavor_id='')
Example #4
0
def return_flavor_not_found(flavor_id, ctxt=None):
    raise exception.FlavorNotFound(flavor_id=flavor_id)