def test_remove_nonexisting_host(self): pool = ZerobootPool( name="test", data={"zerobootHosts": ["host1", "host2", "host3"]}) pool._validate_host = MagicMock() # remove non existing host pool.remove("ghost_host") assert len(pool.data.get("zerobootHosts")) == 3 # remove a host and try get a ghost again pool.remove("host3") pool.remove("ghost_host") assert len(pool.data.get("zerobootHosts")) == 2 # add a host and try get a ghost again pool.add("host3") pool.remove("ghost_host") assert len(pool.data.get("zerobootHosts")) == 3 # empty list and try get a ghost again pool.remove("host1") pool.remove("host2") pool.remove("host3") pool.remove("ghost_host") assert len(pool.data.get("zerobootHosts")) == 0
def test_add_duplicate(self): pool = ZerobootPool(name="test", data={"zerobootHosts": ["host1", "host2"]}) pool._validate_host = MagicMock() # add already existing host with pytest.raises( ValueError, message="Adding already present host should raise ValueError"): pool.add("host1")
def test_add(self): pool = ZerobootPool(name="test", data={"zerobootHosts": ["host1", "host2"]}) pool._validate_host = MagicMock() # add new host pool.add("host3") assert len(pool.data.get("zerobootHosts")) == 3 # add another pool.add("host4") assert len(pool.data.get("zerobootHosts")) == 4