Esempio n. 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)
Esempio n. 2
0
    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)
Esempio n. 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)
Esempio n. 4
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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 8
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)
Esempio n. 9
0
    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)
Esempio n. 10
0
    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)
Esempio n. 11
0
 def delete(self, request, obj_id):
     api.security_group_delete(request, obj_id)
Esempio n. 12
0
 def delete(self, request, obj_id):
     api.security_group_delete(request, obj_id)