예제 #1
0
파일: test_tag.py 프로젝트: CtrlZmaster/pcs
 def test_remove_refs_from_multiple_tags_with_removing_tags(self):
     lib.remove_obj_ref(get_elements_by_ids(self.cib, ["common", "ref4"]))
     assert_xml_equal(
         """
         <tags>
             <tag id="tag-A">
                 <obj_ref id="ref1"/>
                 <obj_ref id="ref2"/>
                 <obj_ref id="ref3"/>
             </tag>
             <tag id="tag-B">
                 <obj_ref id="ref5"/>
             </tag>
         </tags>
         """,
         etree_to_str(self.cib),
     )
예제 #2
0
파일: tag.py 프로젝트: zht750808/pcs
def update(
    env: LibraryEnvironment,
    tag_id: str,
    idref_add: Sequence[str],
    idref_remove: Sequence[str],
    adjacent_idref: Optional[str] = None,
    put_after_adjacent: bool = False,
) -> None:
    """
    Update specified tag by given id references.

    env -- provides all for communication with externals
    tag_id -- id of an existing tag to be updated
    idref_add -- reference ids to be added
    idref_remove -- reference ids to be removed
    adjacent_idref -- id of the element next to which the added elements will
        be put
    put_after_adjacent -- put elements after (True) or before (False) the
        adjacent element
    """
    with cib_tags_section(env) as tags_section:
        validator = tag.ValidateTagUpdateByIds(
            tag_id,
            idref_add,
            idref_remove,
            adjacent_idref,
        )
        if env.report_processor.report_list(
                validator.validate(
                    get_resources(get_root(tags_section)),
                    tags_section,
                )).has_errors:
            raise LibraryError()
        # check for mypy
        tag_element = validator.tag_element()
        if tag_element is not None:
            tag.add_obj_ref(
                tag_element,
                validator.add_obj_ref_element_list(),
                validator.adjacent_obj_ref_element(),
                put_after_adjacent,
            )
            tag.remove_obj_ref(validator.remove_obj_ref_element_list())
예제 #3
0
파일: test_tag.py 프로젝트: CtrlZmaster/pcs
 def test_remove_empty_list(self):
     lib.remove_obj_ref([])
     assert_xml_equal(FIXTURE_OBJ_REFS, etree_to_str(self.cib))