1
0

test_minion.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import salt.minion
  2. from tests.support.mock import patch
  3. def test_minion_load_grains_false():
  4. """
  5. Minion does not generate grains when load_grains is False
  6. """
  7. opts = {"random_startup_delay": 0, "grains": {"foo": "bar"}}
  8. with patch("salt.loader.grains") as grainsfunc:
  9. minion = salt.minion.Minion(opts, load_grains=False)
  10. assert minion.opts["grains"] == opts["grains"]
  11. grainsfunc.assert_not_called()
  12. def test_minion_load_grains_true():
  13. """
  14. Minion generates grains when load_grains is True
  15. """
  16. opts = {"random_startup_delay": 0, "grains": {}}
  17. with patch("salt.loader.grains") as grainsfunc:
  18. minion = salt.minion.Minion(opts, load_grains=True)
  19. assert minion.opts["grains"] != {}
  20. grainsfunc.assert_called()
  21. def test_minion_load_grains_default():
  22. """
  23. Minion load_grains defaults to True
  24. """
  25. opts = {"random_startup_delay": 0, "grains": {}}
  26. with patch("salt.loader.grains") as grainsfunc:
  27. minion = salt.minion.Minion(opts)
  28. assert minion.opts["grains"] != {}
  29. grainsfunc.assert_called()