'Tests the case that the tenant does not exist in Keystone.'

@mock.patch('nova.api.openstack.identity.verify_project_id', side_effect=exc.HTTPBadRequest(explanation='Project    ID    proj2    is    not    a    valid    project.'))
def test_add_tenant_access_with_invalid_tenant(self, mock_verify):

    req = fakes.HTTPRequest.blank((self._prefix + '/flavors/2/action'), use_admin_context=True)
    body = {'addTenantAccess': {'tenant': 'proj2'}}
    self.assertRaises(exc.HTTPBadRequest, self.flavor_action_controller._add_tenant_access, req, '2', body=body)
    mock_verify.assert_called_once_with(req.environ['nova.context'], 'proj2')
