test_minions.py 824 B

12345678910111213141516171819202122
  1. import salt.utils.minions
  2. import salt.utils.network
  3. from tests.support.mock import patch
  4. def test_connected_ids():
  5. """
  6. test ckminion connected_ids when
  7. local_port_tcp returns 127.0.0.1
  8. """
  9. opts = {"publish_port": 4505}
  10. minion = "minion"
  11. ip = salt.utils.network.ip_addrs()
  12. mdata = {"grains": {"ipv4": ip, "ipv6": []}}
  13. ckminions = salt.utils.minions.CkMinions({"minion_data_cache": True})
  14. patch_net = patch("salt.utils.network.local_port_tcp", return_value={"127.0.0.1"})
  15. patch_list = patch("salt.cache.Cache.list", return_value=[minion])
  16. patch_fetch = patch("salt.cache.Cache.fetch", return_value=mdata)
  17. with patch.dict(ckminions.opts, opts):
  18. with patch_net, patch_list, patch_fetch:
  19. ret = ckminions.connected_ids()
  20. assert ret == {minion}