def test_remove_a_tag(self): lib.remove_tag( elem for elem in get_tags(self.cib) if elem.get("id") == "second_tag" ) assert_xml_equal(FIXTURE_ONE_TAG, etree_to_str(self.cib))
def remove(env: LibraryEnvironment, tag_list: Iterable[str]) -> None: """ Remove specified tags from a cib. env -- provides all for communication with externals tag_list -- list of tags for the removal """ with cib_tags_section(env) as tags_section: env.report_processor.report_list( tag.validate_remove_tag( get_constraints(get_root(tags_section)), tag_list, ) ) tag_elements, report_list = tag.find_tag_elements_by_ids( tags_section, tag_list, ) if env.report_processor.report_list(report_list).has_errors: raise LibraryError() tag.remove_tag(tag_elements)
def test_remove_more_tags(self): lib.remove_tag(elem for elem in get_tags(self.cib)) assert_xml_equal( "<cib><configuration><tags/></configuration></cib>", etree_to_str(self.cib), )
def test_remove_empty_list(self): lib.remove_tag([]) assert_xml_equal(FIXTURE_TWO_TAGS, etree_to_str(self.cib))