def test_edit_group(web, group_type): group_id = "%s_testgroup_id" % group_type group_alias = "%s_testgroup_alias" % group_type group_alias2 = "%s_testgroup_otheralias" % group_type try: web.add_group(group_type, group_id, {"alias": group_alias}) web.edit_group(group_type, group_id, {"alias": group_alias2}) all_groups = web.get_all_groups(group_type) assert group_id in all_groups assert group_alias2 in all_groups[group_id]["alias"] finally: web.delete_group(group_type, group_id)
def test_edit_group_missing(web, group_type): group_id = "%s_testgroup_id" % group_type group_alias = "%s_testgroup_alias" % group_type group_alias2 = "%s_testgroup_otheralias" % group_type try: web.add_group(group_type, group_id, {"alias": group_alias}) try: #web.edit_group(group_type, group_id, {"alias": group_alias2}, expect_error = True) web.edit_group(group_type, "%s_missing" % group_id, {"alias": group_alias2}, expect_error=True) except APIError, e: assert str(e) != str(None) return assert False
def test_add_group(web, group_type): group_id = "%s_testgroup_id" % group_type group_alias = "%s_testgroup_alias" % group_type try: attributes = {"alias": group_alias} if cmk_version.is_managed_edition(): attributes["customer"] = "provider" web.add_group(group_type, group_id, attributes) all_groups = web.get_all_groups(group_type) assert group_id in all_groups assert group_alias == all_groups[group_id]["alias"] if cmk_version.is_managed_edition(): assert all_groups[group_id]["provider"] == "provider" finally: all_groups = web.get_all_groups(group_type) if group_id in all_groups: web.delete_group(group_type, group_id)
def test_edit_cg_group_with_nagvis_maps(web, site): dummy_map_filepath1 = "%s/etc/nagvis/maps/blabla.cfg" % site.root dummy_map_filepath2 = "%s/etc/nagvis/maps/bloblo.cfg" % site.root try: file(dummy_map_filepath1, "w") file(dummy_map_filepath2, "w") web.add_group("contact", "nagvis_test", { "alias": "nagvis_test_alias", "nagvis_maps": ["blabla"] }) web.edit_group("contact", "nagvis_test", { "alias": "nagvis_test_alias", "nagvis_maps": ["bloblo"] }) all_groups = web.get_all_groups("contact") assert "nagvis_test" in all_groups assert "bloblo" in all_groups["nagvis_test"]["nagvis_maps"] finally: web.delete_group("contact", "nagvis_test") os.unlink(dummy_map_filepath1) os.unlink(dummy_map_filepath2)
def test_edit_group_missing(web, group_type): group_id = "%s_testgroup_id" % group_type group_alias = "%s_testgroup_alias" % group_type group_alias2 = "%s_testgroup_otheralias" % group_type try: attributes = {"alias": group_alias} if cmk_version.is_managed_edition(): attributes["customer"] = "provider" web.add_group(group_type, group_id, attributes) try: #web.edit_group(group_type, group_id, {"alias": group_alias2}, expect_error = True) web.edit_group(group_type, "%s_missing" % group_id, {"alias": group_alias2}, expect_error=True) except APIError as e: assert str(e) != str(None) return assert False finally: web.delete_group(group_type, group_id)
def test_edit_group(web, group_type): # noqa: F811 # pylint: disable=redefined-outer-name group_id = "%s_testgroup_id" % group_type group_alias = "%s_testgroup_alias" % group_type group_alias2 = "%s_testgroup_otheralias" % group_type try: attributes = {"alias": group_alias} if cmk_version.is_managed_edition(): attributes["customer"] = "provider" web.add_group(group_type, group_id, attributes) attributes["alias"] = group_alias2 web.edit_group(group_type, group_id, attributes) all_groups = web.get_all_groups(group_type) assert group_id in all_groups assert group_alias2 == all_groups[group_id]["alias"] if cmk_version.is_managed_edition(): assert all_groups[group_id]["customer"] == "provider" finally: web.delete_group(group_type, group_id)
def test_edit_cg_group_with_nagvis_maps(web, site): dummy_map_filepath1 = "%s/etc/nagvis/maps/blabla.cfg" % site.root dummy_map_filepath2 = "%s/etc/nagvis/maps/bloblo.cfg" % site.root try: open(dummy_map_filepath1, "w") open(dummy_map_filepath2, "w") attributes = {"alias": "nagvis_test_alias", "nagvis_maps": ["blabla"]} if cmk_version.is_managed_edition(): attributes["customer"] = "provider" web.add_group("contact", "nagvis_test", attributes) attributes["nagvis_maps"] = ["bloblo"] web.edit_group("contact", "nagvis_test", attributes) all_groups = web.get_all_groups("contact") assert "nagvis_test" in all_groups assert "bloblo" in all_groups["nagvis_test"]["nagvis_maps"] finally: web.delete_group("contact", "nagvis_test") os.unlink(dummy_map_filepath1) os.unlink(dummy_map_filepath2)