def test_load_group_information_empty(tmp_path): environ = dict(create_environ(), REQUEST_URI='') with AppContext(DummyApplication(environ, None)), \ RequestContext(htmllib.html(Request(environ))): assert groups.load_contact_group_information() == {} assert groups.load_host_group_information() == {} assert groups.load_service_group_information() == {}
def list_groups(params): """List service-groups""" return constructors.serve_json({ 'id': 'folders', 'value': [ constructors.collection_object('service_group', 'service_group', group) for group in load_service_group_information().values() ], 'links': [constructors.link_rel('self', '/collections/service_group')] })
def _load_groups(self): return load_service_group_information()
def _get_all_servicegroups(self, request): return load_service_group_information()
def test_load_group_information(tmp_path): with open(cmk.utils.paths.check_mk_config_dir + "/wato/groups.mk", "w") as f: f.write("""# encoding: utf-8 if type(define_contactgroups) != dict: define_contactgroups = {} define_contactgroups.update({'all': u'Everything'}) if type(define_hostgroups) != dict: define_hostgroups = {} define_hostgroups.update({'all_hosts': u'All hosts :-)'}) if type(define_servicegroups) != dict: define_servicegroups = {} define_servicegroups.update({'all_services': u'All särvices'}) """) with open( cmk.utils.paths.default_config_dir + "/multisite.d/wato/groups.mk", "w") as f: f.write("""# encoding: utf-8 multisite_hostgroups = { "all_hosts": { "ding": "dong", }, } multisite_servicegroups = { "all_services": { "d1ng": "dong", }, } multisite_contactgroups = { "all": { "d!ng": "dong", }, } """) environ = dict(create_environ(), REQUEST_URI='') with AppContext(DummyApplication(environ, None)), \ RequestContext(htmllib.html(Request(environ))): assert groups.load_group_information() == { 'contact': { 'all': { 'alias': u'Everything', "d!ng": "dong", } }, 'host': { 'all_hosts': { 'alias': u'All hosts :-)', "ding": "dong", } }, 'service': { 'all_services': { 'alias': u'All s\xe4rvices', "d1ng": "dong", } }, } assert groups.load_contact_group_information() == { 'all': { 'alias': u'Everything', "d!ng": "dong", } } assert groups.load_host_group_information() == { 'all_hosts': { 'alias': u'All hosts :-)', "ding": "dong", } } assert groups.load_service_group_information() == { 'all_services': { 'alias': u'All s\xe4rvices', "d1ng": "dong", } }
def _fetch_service_group(ident): groups = load_service_group_information() group = groups[ident].copy() group['id'] = ident return group
def test_load_group_information(tmp_path): with open(cmk.utils.paths.check_mk_config_dir + "/wato/groups.mk", "w") as f: f.write("""# encoding: utf-8 if type(define_contactgroups) != dict: define_contactgroups = {} define_contactgroups.update({'all': u'Everything'}) if type(define_hostgroups) != dict: define_hostgroups = {} define_hostgroups.update({'all_hosts': u'All hosts :-)'}) if type(define_servicegroups) != dict: define_servicegroups = {} define_servicegroups.update({'all_services': u'All särvices'}) """) with open( cmk.utils.paths.default_config_dir + "/multisite.d/wato/groups.mk", "w") as f: f.write("""# encoding: utf-8 multisite_hostgroups = { "all_hosts": { "ding": "dong", }, } multisite_servicegroups = { "all_services": { "d1ng": "dong", }, } multisite_contactgroups = { "all": { "d!ng": "dong", }, } """) assert groups._load_group_information() == { 'contact': { 'all': { 'alias': u'Everything', "d!ng": "dong", } }, 'host': { 'all_hosts': { 'alias': u'All hosts :-)', "ding": "dong", } }, 'service': { 'all_services': { 'alias': u'All s\xe4rvices', "d1ng": "dong", } }, } assert groups.load_contact_group_information() == { 'all': { 'alias': u'Everything', "d!ng": "dong", } } assert groups.load_host_group_information() == { 'all_hosts': { 'alias': u'All hosts :-)', "ding": "dong", } } assert groups.load_service_group_information() == { 'all_services': { 'alias': u'All s\xe4rvices', "d1ng": "dong", } }
def test_load_group_information_empty(tmp_path): assert groups.load_contact_group_information() == {} assert groups.load_host_group_information() == {} assert groups.load_service_group_information() == {}