示例#1
0
    def test_instance_update_post_api_exception(self):
        SERVER = self.servers[0]

        self.mox.StubOutWithMock(api, 'server_get')
        self.mox.StubOutWithMock(api, 'server_update')

        api.server_get(IsA(http.HttpRequest), unicode(SERVER.id)) \
                      .AndReturn(self.servers[0])
        exception = nova_exceptions.ClientException(500)
        api.server_update(IsA(http.HttpRequest), str(SERVER.id), SERVER.name) \
                          .AndRaise(exception)

        self.mox.ReplayAll()

        formData = {
            'method': 'UpdateInstance',
            'instance': SERVER.id,
            'name': SERVER.name,
            'tenant_id': self.TEST_TENANT
        }
        url = reverse('horizon:nova:instances_and_volumes:instances:update',
                      args=[SERVER.id])
        res = self.client.post(url, formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)
示例#2
0
文件: tests.py 项目: katzj/horizon
    def test_instance_update_post_api_exception(self):
        INSTANCE_ID = self.servers[0].id
        NAME = 'myname'
        formData = {'method': 'UpdateInstance',
                    'instance': INSTANCE_ID,
                    'name': NAME,
                    'tenant_id': self.TEST_TENANT}

        self.mox.StubOutWithMock(api, 'server_get')
        api.server_get(IsA(http.HttpRequest),
                           unicode(INSTANCE_ID)).AndReturn(self.servers[0])

        exception = api_exceptions.ApiException('apiException')
        self.mox.StubOutWithMock(api, 'server_update')
        api.server_update(IsA(http.HttpRequest),
                          str(INSTANCE_ID), NAME).\
                          AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:instances:update',
                                       args=[INSTANCE_ID]),
                               formData)

        self.assertRedirectsNoFollow(res,
                                     reverse('horizon:nova:instances:index'))

        self.mox.VerifyAll()
示例#3
0
    def test_instance_update_post_api_exception(self):
        INSTANCE_ID = self.servers[0].id
        NAME = 'myname'
        formData = {
            'method': 'UpdateInstance',
            'instance': INSTANCE_ID,
            'name': NAME,
            'tenant_id': self.TEST_TENANT
        }

        self.mox.StubOutWithMock(api, 'server_get')
        api.server_get(IsA(http.HttpRequest),
                       unicode(INSTANCE_ID)).AndReturn(self.servers[0])

        exception = api_exceptions.ApiException('apiException')
        self.mox.StubOutWithMock(api, 'server_update')
        api.server_update(IsA(http.HttpRequest),
                          str(INSTANCE_ID), NAME).\
                          AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.post(
            reverse('horizon:nova:instances_and_volumes:instances:update',
                    args=[INSTANCE_ID]), formData)

        self.assertRedirectsNoFollow(
            res, reverse('horizon:nova:instances_and_volumes:instances:index'))
示例#4
0
    def handle(self, request, data):
        try:
            api.server_update(request, data['instance'], data['name'])
            messages.success(request,
                             _('Instance "%s" updated.') % data['name'])
        except:
            exceptions.handle(request, _('Unable to update instance.'))

        return shortcuts.redirect('horizon:nova:instances_and_volumes:index')
示例#5
0
文件: forms.py 项目: termie/horizon
 def handle(self, request, data):
     tenant_id = data['tenant_id']
     try:
         api.server_update(request, data['instance'], data['name'])
         messages.success(request,
                          _("Instance '%s' updated") % data['name'])
     except api_exceptions.ApiException, e:
         messages.error(request,
                        _('Unable to update instance: %s') % e.message)
示例#6
0
文件: forms.py 项目: andycjw/horizon
    def handle(self, request, data):
        try:
            api.server_update(request, data['instance'], data['name'])
            messages.success(request,
                             _('Instance "%s" updated.') % data['name'])
        except:
            exceptions.handle(request, _('Unable to update instance.'))

        return shortcuts.redirect('horizon:nova:instances:index')
示例#7
0
 def handle(self, request, data):
     tenant_id = data['tenant_id']
     try:
         api.server_update(request,
                           data['instance'],
                           data['name'])
         messages.success(request, _("Instance '%s' updated") %
                                   data['name'])
     except api_exceptions.ApiException, e:
         messages.error(request,
                    _('Unable to update instance: %s') % e.message)
示例#8
0
文件: tests.py 项目: haluomao/horizon
    def test_instance_update_post(self):
        server = self.servers.first()

        self.mox.StubOutWithMock(api, "server_get")
        self.mox.StubOutWithMock(api, "server_update")
        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name)
        self.mox.ReplayAll()

        formData = {"method": "UpdateInstance", "instance": server.id, "name": server.name, "tenant_id": self.tenant.id}
        url = reverse("horizon:nova:instances_and_volumes:instances:update", args=[server.id])
        res = self.client.post(url, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
示例#9
0
文件: tests.py 项目: hien/horizon
    def test_instance_update_post_api_exception(self):
        server = self.servers.first()

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name).AndRaise(self.exceptions.nova)

        self.mox.ReplayAll()

        formData = {"method": "UpdateInstance", "instance": server.id, "name": server.name, "tenant_id": self.tenant.id}
        url = reverse("horizon:project:instances:update", args=[server.id])
        res = self.client.post(url, formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)
示例#10
0
    def test_instance_update_post(self):
        server = self.servers.first()

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name)

        self.mox.ReplayAll()

        formData = {'method': 'UpdateInstance',
                    'instance': server.id,
                    'name': server.name,
                    'tenant_id': self.tenant.id}
        url = reverse('horizon:nova:instances:update',
                      args=[server.id])
        res = self.client.post(url, formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)
示例#11
0
文件: tests.py 项目: hagix9/horizon
    def test_instance_update_post(self):
        server = self.servers.first()

        self.mox.StubOutWithMock(api, 'server_get')
        self.mox.StubOutWithMock(api, 'server_update')
        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name)
        self.mox.ReplayAll()

        formData = {'method': 'UpdateInstance',
                    'instance': server.id,
                    'name': server.name,
                    'tenant_id': self.tenant.id}
        url = reverse('horizon:nova:instances_and_volumes:instances:update',
                      args=[server.id])
        res = self.client.post(url, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
示例#12
0
文件: tests.py 项目: artofwar/stack
    def test_instance_update_post_api_exception(self):
        server = self.servers.first()

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name) \
                          .AndRaise(self.exceptions.nova)

        self.mox.ReplayAll()

        formData = {'method': 'UpdateInstance',
                    'instance': server.id,
                    'name': server.name,
                    'tenant_id': self.tenant.id}
        url = reverse('horizon:nova:instances:update',
                      args=[server.id])
        res = self.client.post(url, formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)
示例#13
0
    def test_instance_update_post_api_exception(self):
        server = self.servers.first()

        self.mox.StubOutWithMock(api, 'server_get')
        self.mox.StubOutWithMock(api, 'server_update')
        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name) \
                          .AndRaise(self.exceptions.nova)
        self.mox.ReplayAll()

        formData = {
            'method': 'UpdateInstance',
            'instance': server.id,
            'name': server.name,
            'tenant_id': self.tenant.id
        }
        url = reverse('horizon:nova:instances_and_volumes:instances:update',
                      args=[server.id])
        res = self.client.post(url, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
示例#14
0
文件: forms.py 项目: 1ukash/horizon
 def handle(self, request, data):
     try:
         server = api.server_update(request, data['instance'], data['name'])
         messages.success(request,
                          _('Instance "%s" updated.') % data['name'])
         return server
     except:
         redirect = reverse("horizon:project:instances:index")
         exceptions.handle(request,
                           _('Unable to update instance.'),
                           redirect=redirect)
示例#15
0
 def handle(self, request, data):
     try:
         server = api.server_update(request, data['instance'], data['name'])
         messages.success(request,
                          _('Instance "%s" updated.') % data['name'])
         return server
     except:
         redirect = reverse("horizon:project:instances:index")
         exceptions.handle(request,
                           _('Unable to update instance.'),
                           redirect=redirect)
示例#16
0
    def test_instance_update_post_api_exception(self):
        SERVER = self.servers[0]

        self.mox.StubOutWithMock(api, 'server_get')
        self.mox.StubOutWithMock(api, 'server_update')

        api.server_get(IsA(http.HttpRequest), unicode(SERVER.id)) \
                      .AndReturn(self.servers[0])
        exception = nova_exceptions.ClientException(500)
        api.server_update(IsA(http.HttpRequest), str(SERVER.id), SERVER.name) \
                          .AndRaise(exception)

        self.mox.ReplayAll()

        formData = {'method': 'UpdateInstance',
                    'instance': SERVER.id,
                    'name': SERVER.name,
                    'tenant_id': self.TEST_TENANT}
        url = reverse('horizon:nova:instances_and_volumes:instances:update',
                      args=[SERVER.id])
        res = self.client.post(url, formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)
示例#17
0
    def test_instance_update_post(self):
        INSTANCE_ID = self.servers[0].id
        NAME = 'myname'
        formData = {'method': 'UpdateInstance',
                    'instance': self.servers[0].id,
                    'name': NAME,
                    'tenant_id': self.TEST_TENANT}

        self.mox.StubOutWithMock(api, 'server_get')
        api.server_get(IsA(http.HttpRequest),
                           unicode(INSTANCE_ID)).AndReturn(self.servers[0])

        self.mox.StubOutWithMock(api, 'server_update')
        api.server_update(IsA(http.HttpRequest),
                          str(INSTANCE_ID), NAME)

        self.mox.ReplayAll()

        res = self.client.post(
                reverse('horizon:nova:instances_and_volumes:instances:update',
                        args=[INSTANCE_ID]), formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)