示例#1
0
    def test_delete_group(self):
        self.mox.StubOutWithMock(api, 'security_group_delete')
        api.security_group_delete(IsA(http.HttpRequest), 2)

        self.mox.ReplayAll()

        form_data = {"action": "security_groups__delete__%s" % '2'}
        req = self.factory.post(INDEX_URL, form_data)
        table = SecurityGroupsTable(req, self.security_groups)
        handled = table.maybe_handle()

        self.assertEqual(strip_absolute_base(handled['location']), INDEX_URL)
示例#2
0
文件: tests.py 项目: asomya/horizon
    def test_delete_group(self):
        sec_group = self.security_groups.get(name="other_group")

        self.mox.StubOutWithMock(api, 'security_group_delete')
        api.security_group_delete(IsA(http.HttpRequest), sec_group.id)
        self.mox.ReplayAll()

        form_data = {"action": "security_groups__delete__%s" % sec_group.id}
        req = self.factory.post(INDEX_URL, form_data)
        table = SecurityGroupsTable(req, self.security_groups.list())
        handled = table.maybe_handle()
        self.assertEqual(strip_absolute_base(handled['location']),
                         INDEX_URL)
示例#3
0
    def test_delete_group(self):

        formData = {'method': 'DeleteGroup',
                    'tenant_id': self.TEST_TENANT,
                    'security_group_id': SECGROUP_ID,
                   }

        self.mox.StubOutWithMock(api, 'security_group_delete')
        api.security_group_delete(IsA(http.HttpRequest), SECGROUP_ID)

        self.mox.ReplayAll()

        res = self.client.post(SG_INDEX_URL, formData)

        self.assertRedirectsNoFollow(res, SG_INDEX_URL)
示例#4
0
文件: tests.py 项目: ehazlett/horizon
    def test_delete_group(self):

        formData = {'method': 'DeleteGroup',
                    'tenant_id': self.TEST_TENANT,
                    'security_group_id': SECGROUP_ID,
                   }

        self.mox.StubOutWithMock(api, 'security_group_delete')
        api.security_group_delete(IsA(http.HttpRequest), SECGROUP_ID)

        self.mox.ReplayAll()

        res = self.client.post(SG_INDEX_URL, formData)

        self.assertRedirectsNoFollow(res, SG_INDEX_URL)
示例#5
0
    def test_delete_group_exception(self):
        sec_group = self.security_groups.get(name="other_group")

        self.mox.StubOutWithMock(api, 'security_group_delete')
        api.security_group_delete(IsA(http.HttpRequest),
                                  sec_group.id).AndRaise(self.exceptions.nova)

        self.mox.ReplayAll()

        form_data = {"action": "security_groups__delete__%s" % sec_group.id}
        req = self.factory.post(INDEX_URL, form_data)
        table = SecurityGroupsTable(req, self.security_groups.list())
        handled = table.maybe_handle()

        self.assertEqual(strip_absolute_base(handled['location']),
                         INDEX_URL)
示例#6
0
    def test_delete_group_exception(self):
        self.mox.StubOutWithMock(api, 'security_group_delete')
        exception = novaclient_exceptions.ClientException('ClientException',
                                                  message='ClientException')
        api.security_group_delete(IsA(http.HttpRequest), 2).\
                                  AndRaise(exception)

        self.mox.ReplayAll()

        form_data = {"action": "security_groups__delete__%s" % '2'}
        req = self.factory.post(INDEX_URL, form_data)
        table = SecurityGroupsTable(req, self.security_groups)
        handled = table.maybe_handle()

        self.assertEqual(strip_absolute_base(handled['location']),
                         INDEX_URL)
示例#7
0
    def test_delete_group_exception(self):
        exception = novaclient_exceptions.ClientException('ClientException',
                                                  message='ClientException')

        formData = {'method': 'DeleteGroup',
                    'tenant_id': self.TEST_TENANT,
                    'security_group_id': SECGROUP_ID,
                   }

        self.mox.StubOutWithMock(api, 'security_group_delete')
        api.security_group_delete(IsA(http.HttpRequest), SECGROUP_ID).\
                                  AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.post(SG_INDEX_URL, formData)

        self.assertRedirectsNoFollow(res, SG_INDEX_URL)
示例#8
0
文件: tests.py 项目: ehazlett/horizon
    def test_delete_group_exception(self):
        exception = novaclient_exceptions.ClientException('ClientException',
                                                  message='ClientException')

        formData = {'method': 'DeleteGroup',
                    'tenant_id': self.TEST_TENANT,
                    'security_group_id': SECGROUP_ID,
                   }

        self.mox.StubOutWithMock(api, 'security_group_delete')
        api.security_group_delete(IsA(http.HttpRequest), SECGROUP_ID).\
                                  AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.post(SG_INDEX_URL, formData)

        self.assertRedirectsNoFollow(res, SG_INDEX_URL)
示例#9
0
文件: forms.py 项目: katzj/horizon
    def handle(self, request, data):
        try:
            LOG.info('Delete security_group: "%s"' % data)

            security_group = api.security_group_delete(request,
                                                     data['security_group_id'])
            messages.info(request, _('Successfully deleted security_group: %s')
                                    % data['security_group_id'])
        except novaclient_exceptions.ClientException, e:
            LOG.exception("ClientException in DeleteGroup")
            messages.error(request, _('Error deleting security group: %s')
                                     % e.message)
示例#10
0
文件: forms.py 项目: ehazlett/horizon
    def handle(self, request, data):
        try:
            LOG.info('Delete security_group: "%s"' % data)

            security_group = api.security_group_delete(
                request, data['security_group_id'])
            messages.success(
                request,
                _('Successfully deleted security_group: %s') %
                data['security_group_id'])
        except novaclient_exceptions.ClientException, e:
            LOG.exception("ClientException in DeleteGroup")
            messages.error(request,
                           _('Error deleting security group: %s') % e.message)
示例#11
0
 def delete(self, request, obj_id):
     api.security_group_delete(request, obj_id)
示例#12
0
 def delete(self, request, obj_id):
     api.security_group_delete(request, obj_id)