1
0

test_status.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. """
  2. tests.pytests.unit.beacons.test_status
  3. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. Status beacon test cases
  5. """
  6. import pytest
  7. import salt.modules.status as status_module
  8. from salt.beacons import status
  9. @pytest.fixture(autouse=True)
  10. def setup_loader():
  11. setup_loader_modules = {
  12. status: {
  13. "__salt__": pytest.helpers.salt_loader_module_functions(status_module)
  14. },
  15. status_module: {"__grains__": {"kernel": "Linux"}, "__salt__": {}},
  16. }
  17. with pytest.helpers.loader_mock(setup_loader_modules) as loader_mock:
  18. yield loader_mock
  19. def test_empty_config():
  20. config = []
  21. ret = status.validate(config)
  22. assert ret == (True, "Valid beacon configuration")
  23. ret = status.beacon(config)
  24. expected = sorted(["loadavg", "meminfo", "cpustats", "vmstats", "time"])
  25. assert sorted(list(ret[0]["data"])) == expected
  26. def test_deprecated_dict_config():
  27. config = {"time": ["all"]}
  28. ret = status.validate(config)
  29. assert ret == (False, "Configuration for status beacon must be a list.")
  30. def test_list_config():
  31. config = [{"time": ["all"]}]
  32. ret = status.validate(config)
  33. assert ret == (True, "Valid beacon configuration")
  34. ret = status.beacon(config)
  35. expected = ["time"]
  36. assert list(ret[0]["data"]) == expected