def test_edit_rules_get_exception(self): exception = engineclient_exceptions.ClientException('ClientException', message='ClientException') self.mox.StubOutWithMock(api, 'security_group_get') api.security_group_get(IsA(http.HttpRequest), SECGROUP_ID) \ .AndRaise(exception) self.mox.ReplayAll() res = self.client.get(SG_EDIT_RULE_URL) self.assertRedirects(res, INDEX_URL)
def test_edit_rules_get(self): self.mox.StubOutWithMock(api, 'security_group_get') api.security_group_get(IsA(http.HttpRequest), SECGROUP_ID).AndReturn( self.security_groups[1]) self.mox.ReplayAll() res = self.client.get(SG_EDIT_RULE_URL) self.assertTemplateUsed(res, 'engine/access_and_security/security_groups/edit_rules.html') self.assertItemsEqual(res.context['security_group'].name, self.security_groups[1].name)
def get_data(self): security_group_id = self.kwargs["security_group_id"] try: self.object = api.security_group_get(self.request, security_group_id) rules = [api.engine.SecurityGroupRule(rule) for rule in self.object.rules] except engineclient_exceptions.ClientException, e: self.object = None rules = [] LOG.exception("ClientException in security_groups rules edit") messages.error(self.request, _("Error getting security_group: %s") % e)
def get_data(self): security_group_id = self.kwargs['security_group_id'] try: self.object = api.security_group_get(self.request, security_group_id) rules = [ api.engine.SecurityGroupRule(rule) for rule in self.object.rules ] except engineclient_exceptions.ClientException, e: self.object = None rules = [] LOG.exception("ClientException in security_groups rules edit") messages.error(self.request, _('Error getting security_group: %s') % e)