def test_delete_reparent_hosts(self): g1, g2 = Group(name='todelete'), Group(name='parent') host1 = Host(name='host') host1.add_group(g1) g1.add_parent(g2) g1.delete(reparent_hosts=True) assert g2 in host1.groups assert g1 not in host1.groups
def test_remove_group_from_hosts(self): groupa = Group('groupa') hosta, hostb = Host('a'), Host('b') hosta.add_group(groupa) hostb.add_group(groupa) assert len(groupa.hosts) == 2 groupa.delete() assert len(hosta.groups) == 0 assert len(hostb.groups) == 0
def test_delete_reparent_vars(self): child1, child2 = Group(name='child1'), Group(name='child2') mid = Group(name='mid') mid.vars['groupvarname'] = 'value' parent1, parent2 = Group(name='par'), Group(name='par2') for child in [child1, child2]: child.add_parent(mid) for par in [parent1, parent2]: mid.add_parent(par) mid.delete(reparent_vars=True) for parent in [parent1, parent2]: assert parent.vars['groupvarname'] == 'value'
def test_delete_reparent_groups(self): child1, child2 = Group(name='child1'), Group(name='child2') mid = Group(name='mid') parent1, parent2 = Group(name='par'), Group(name='par2') for child in [child1, child2]: child.add_parent(mid) for par in [parent1, parent2]: mid.add_parent(par) mid.delete(reparent_groups=True) for child in [child1, child2]: assert parent1 in child.parents assert parent2 in child.parents assert mid not in child.parents