def test_alias(self): """Add a group with an alias""" okconfig.addgroup("testgroup1", alias="the first testgroup") contacts = Model.Contactgroup.objects.filter( contactgroup_name='testgroup1', alias='the first testgroup') self.assertEqual(1, len(contacts))
def test_conflict(self): """Test adding a conflicting group""" okconfig.addgroup("testgroup1") self.assertRaises(okconfig.OKConfigError, okconfig.addgroup, "testgroup1")
def test_basic(self): """Add a group""" okconfig.addgroup("testgroup1") contacts = Model.Contactgroup.objects.filter( contactgroup_name='testgroup1') self.assertEqual(1, len(contacts), 'There can be only one') hostgroups = Model.Hostgroup.objects.filter( hostgroup_name='testgroup1') self.assertEqual(1, len(hostgroups), 'There can be only one')
def test_basic(self): """Add a group""" okconfig.addgroup("testgroup1") contacts = Model.Contactgroup.objects.filter( contactgroup_name='testgroup1' ) self.assertEqual(1, len(contacts), 'There can be only one') hostgroups = Model.Hostgroup.objects.filter( hostgroup_name='testgroup1' ) self.assertEqual(1, len(hostgroups), 'There can be only one')
def addgroup(request): c = {} c['messages'] = [] c['errors'] = [] # If there is a problem with the okconfig setup, lets display an error if not okconfig.is_valid(): return verify_okconfig(request) if request.method == 'GET': f = forms.AddGroupForm(initial=request.GET) elif request.method == 'POST': f = forms.AddGroupForm(request.POST) if f.is_valid(): group_name = f.cleaned_data['group_name'] alias = f.cleaned_data['alias'] #description = f.cleaned_data['description'] force = f.cleaned_data['force'] try: c['filelist'] = okconfig.addgroup(group_name=group_name, alias=alias, force=force) c['group_name'] = group_name return addcomplete(request, c) except Exception, e: c['errors'].append("error adding group: %s" % e) else: c['errors'].append('Could not validate input')
def addgroup(request): """ Add a new okconfig group """ c = {} c['messages'] = [] c['errors'] = [] # If there is a problem with the okconfig setup, lets display an error if not okconfig.is_valid(): return verify_okconfig(request) if request.method == 'GET': f = forms.AddGroupForm(initial=request.GET) elif request.method == 'POST': f = forms.AddGroupForm(request.POST) if f.is_valid(): group_name = f.cleaned_data['group_name'] alias = f.cleaned_data['alias'] #description = f.cleaned_data['description'] force = f.cleaned_data['force'] try: c['filelist'] = okconfig.addgroup( group_name=group_name, alias=alias, force=force) c['group_name'] = group_name return addcomplete(request, c) except Exception, e: c['errors'].append(_("error adding group: %s") % e) else: c['errors'].append(_('Could not validate input'))
def addgroup(request): """ Add a new okconfig group """ c = {} c['messages'] = [] c['errors'] = [] # If there is a problem with the okconfig setup, lets display an error if not okconfig.is_valid(): return verify_okconfig(request) if request.method == 'GET': f = forms.AddGroupForm(initial=request.GET) elif request.method == 'POST': f = forms.AddGroupForm(request.POST) if f.is_valid(): group_name = f.cleaned_data['group_name'] alias = f.cleaned_data['alias'] force = f.cleaned_data['force'] try: c['filelist'] = okconfig.addgroup(group_name=group_name, alias=alias, force=force) c['group_name'] = group_name return addcomplete(request, c) except Exception as e: c['errors'].append(_("error adding group: %s") % e) else: c['errors'].append(_('Could not validate input')) else: raise Exception("Sorry i only support GET or POST") c['form'] = f return render_to_response('addgroup.html', c, context_instance=RequestContext(request))
def addgroup(request): """ Add a new okconfig group """ c = {} c["messages"] = [] c["errors"] = [] # If there is a problem with the okconfig setup, lets display an error if not okconfig.is_valid(): return verify_okconfig(request) if request.method == "GET": f = forms.AddGroupForm(initial=request.GET) elif request.method == "POST": f = forms.AddGroupForm(request.POST) if f.is_valid(): group_name = f.cleaned_data["group_name"] alias = f.cleaned_data["alias"] # description = f.cleaned_data['description'] force = f.cleaned_data["force"] try: c["filelist"] = okconfig.addgroup(group_name=group_name, alias=alias, force=force) c["group_name"] = group_name return addcomplete(request, c) except Exception, e: c["errors"].append("error adding group: %s" % e) else: c["errors"].append("Could not validate input")
def test_force(self): """Test force adding a group""" okconfig.addgroup("testgroup1") okconfig.addgroup("testgroup1", force=True)