def test_on_complete_remove_tags(stc): ctor = CScriptableCreator() project = CStcSystem.Instance().GetObject('project') tags = project.GetObject('Tags') # Create two tags tag1 = ctor.Create('Tag', tags) tag1.Set('Name', 'Tag1') tag2 = ctor.Create('Tag', tags) tag2.Set('Name', 'Tag2') # Check tags exist tag_list = tag_utils.get_tag_objects_from_string_names(['Tag1', 'Tag2']) assert len(tag_list) == 2 # Remove one of the tags and check only one exists mix_utils.on_complete_remove_tags('Tag2') tag_list = tag_utils.get_tag_objects_from_string_names(['Tag1', 'Tag2']) assert len(tag_list) == 1
def test_get_tag_objects_from_string_names(stc): stc_sys = CStcSystem.Instance() project = stc_sys.GetObject("Project") ctor = CScriptableCreator() tags = project.GetObject("Tags") if tags is None: tags = ctor.Create("Tags", project) assert tags is not None tag1 = ctor.Create("Tag", tags) tag1.Set("Name", "Tag1") tag2 = ctor.Create("Tag", tags) tag2.Set("Name", "Tag2") tag3 = ctor.Create("Tag", tags) tag3.Set("Name", "Another Tag") tlist = tag_utils.get_tag_objects_from_string_names(["Tag1"]) assert len(tlist) == 1 assert tlist[0].GetObjectHandle() == tag1.GetObjectHandle() tlist = tag_utils.get_tag_objects_from_string_names(["Tag1", "Another Tag"]) assert len(tlist) == 2 found_tag1 = False found_tag3 = False for tag in tlist: if tag.GetObjectHandle() == tag1.GetObjectHandle(): found_tag1 = True elif tag.GetObjectHandle() == tag3.GetObjectHandle(): found_tag3 = True assert found_tag1 assert found_tag3 # Invalid tag name tlist = tag_utils.get_tag_objects_from_string_names(["Tag12"]) assert len(tlist) == 0 tlist = tag_utils.get_tag_objects_from_string_names(["Tag1", "Tag12"]) assert len(tlist) == 1 assert tlist[0].GetObjectHandle() == tag1.GetObjectHandle()