def setUp(self): self.env_assist, self.config = get_env_tools(self) self.config.runner.cib.load( resources=fixture_resouces_for_reference_ids( ["e1", "e2", "e3", "a", "b"]), tags=fixture_tags_xml([("t", ["e1", "e2", "e3"])]), )
def test_remove_all_existing_but_add_new_ones(self): self.config.env.push_cib(tags=fixture_tags_xml([("t", ["a", "b"])]), ) cmd_tag.update( self.env_assist.get_env(), "t", ["a", "b"], ["e1", "e2", "e3"], ) self.env_assist.assert_reports([])
def setUp(self): self.env_assist, self.config = get_env_tools(self) self.config.runner.cib.load( tags=fixture_tags_xml([ ("tag1", ("i1", "i2")), ("tag2", ("j1", "j2")), ]), resources=fixture_resources_for_ids(), )
def test_combination_add_before_remove(self): self.config.env.push_cib(tags=fixture_tags_xml([("t", ["a", "b", "e2"])]), ) cmd_tag.update( self.env_assist.get_env(), "t", ["a", "b"], ["e1", "e3"], adjacent_idref="e2", )
def test_move_existing_before(self): self.config.env.push_cib(tags=fixture_tags_xml([ ("t", ["e2", "e3", "e1"]) ]), ) cmd_tag.update( self.env_assist.get_env(), "t", ["e2", "e3"], [], adjacent_idref="e1", )
def test_add_ids_after(self): self.config.env.push_cib(tags=fixture_tags_xml([ ("t", ["e1", "b", "a", "e2", "e3"]) ]), ) cmd_tag.update( self.env_assist.get_env(), "t", ["b", "a"], [], adjacent_idref="e1", put_after_adjacent=True, )
def test_nonexistent_tag_ids(self): self.config.runner.cib.load(tags=fixture_tags_xml(TAG_DEFINITIONS)) self.env_assist.assert_raise_library_error(lambda: cmd_tag.remove( self.env_assist.get_env(), ["nonexistent_tag1", "nonexistent_tag2"], )) self.env_assist.assert_reports([ fixture.report_not_found(_id, expected_types=["tag"], context_type="tags") for _id in ["nonexistent_tag1", "nonexistent_tag2"] ])
def test_not_tag_ids(self): self.config.runner.cib.load( resources=fixture_resources_for_ids(), tags=fixture_tags_xml(TAG_DEFINITIONS), ) self.env_assist.assert_raise_library_error( lambda: cmd_tag.remove(self.env_assist.get_env(), ["id1", "id2"])) self.env_assist.assert_reports([ fixture.report_unexpected_element( _id, "primitive", expected_types=["tag"], ) for _id in ["id1", "id2"] ])
def test_tag_referenced_in_constraint(self): self.config.runner.cib.load( constraints=fixture_constraints_for_tags( tag[0] for tag in TAG_DEFINITIONS), tags=fixture_tags_xml(TAG_DEFINITIONS), ) self.env_assist.assert_raise_library_error(lambda: cmd_tag.remove( self.env_assist.get_env(), ["tag1"], )) self.env_assist.assert_reports([ fixture.error( # pylint: disable=line-too-long reports.codes.TAG_CANNOT_REMOVE_TAG_REFERENCED_IN_CONSTRAINTS, tag_id="tag1", constraint_id_list=["location-tag1"], ), ])
def test_mixed_ids(self): self.config.runner.cib.load( resources=fixture_resources_for_ids(), tags=fixture_tags_xml(TAG_DEFINITIONS), ) self.env_assist.assert_raise_library_error(lambda: cmd_tag.remove( self.env_assist.get_env(), ["tag1", "nonexistent_tag1", "id1"], )) self.env_assist.assert_reports([ fixture.report_not_found( "nonexistent_tag1", expected_types=["tag"], context_type="tags", ), fixture.report_unexpected_element( "id1", "primitive", expected_types=["tag"], ), ])
def test_remove_ids(self): self.config.env.push_cib(tags=fixture_tags_xml([("t", ["e2"])]), ) cmd_tag.update(self.env_assist.get_env(), "t", [], ["e1", "e3"])
from unittest import TestCase from pcs_test.tier0.lib.commands.tag.tag_common import ( fixture_resources_for_ids, fixture_tags_xml, ) from pcs_test.tools import fixture from pcs_test.tools.command_env import get_env_tools from pcs.common import reports from pcs.lib.commands import tag as cmd_tag TAG1_ID1_ID2 = fixture_tags_xml([("tag1", ("id1", "id2"))]) class TestTagCreate(TestCase): def setUp(self): self.env_assist, self.config = get_env_tools(self) self.config.runner.cib.load(resources=fixture_resources_for_ids(), ) def test_success_create(self): self.config.env.push_cib(tags=TAG1_ID1_ID2) cmd_tag.create(self.env_assist.get_env(), "tag1", ["id1", "id2"]) def test_success_create_cib_upgrade(self): self.config.runner.cib.load( name="load_cib_old_version", filename="cib-empty-1.2.xml", resources=fixture_resources_for_ids(), before="runner.cib.load", )
def test_remove_all_tags(self): self.config.runner.cib.load(tags=fixture_tags_xml(TAG_DEFINITIONS)) self.config.env.push_cib(tags="<tags/>") cmd_tag.remove(self.env_assist.get_env(), ["tag1", "tag2", "tag3"])
def test_remove_tags_others_are_kept(self): self.config.runner.cib.load(tags=fixture_tags_xml(TAG_DEFINITIONS), ) self.config.env.push_cib(tags=fixture_tags_xml(TAG_DEFINITIONS[2:3]), ) cmd_tag.remove(self.env_assist.get_env(), ["tag1", "tag2"])
def test_tags_element_is_kept(self): self.config.runner.cib.load(tags=fixture_tags_xml( TAG_DEFINITIONS[0:1]), ) self.config.env.push_cib(tags="<tags/>") cmd_tag.remove(self.env_assist.get_env(), ["tag1"])