conftest.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import shutil
  2. import pytest
  3. @pytest.fixture(scope="package")
  4. def pillar_state_tree(tmp_path_factory):
  5. _pillar_state_tree = tmp_path_factory.mktemp("pillar")
  6. try:
  7. yield _pillar_state_tree
  8. finally:
  9. shutil.rmtree(str(_pillar_state_tree), ignore_errors=True)
  10. @pytest.fixture(scope="package")
  11. def extension_modules(tmp_path_factory):
  12. _extension_modules = tmp_path_factory.mktemp("pillar")
  13. try:
  14. yield _extension_modules
  15. finally:
  16. shutil.rmtree(str(_extension_modules), ignore_errors=True)
  17. @pytest.fixture(scope="package")
  18. def salt_master(salt_factories, pillar_state_tree, extension_modules):
  19. config_defaults = {
  20. "pillar_roots": {"base": [str(pillar_state_tree)]},
  21. "open_mode": True,
  22. "extension_modules": str(extension_modules),
  23. "ext_pillar_first": False,
  24. "ext_pillar": [],
  25. "decrypt_pillar_default": "gpg",
  26. "decrypt_pillar_delimiter": ":",
  27. "decrypt_pillar_renderers": ["gpg"],
  28. }
  29. factory = salt_factories.get_salt_master_daemon(
  30. "pillar-functional-master", config_defaults=config_defaults
  31. )
  32. return factory
  33. @pytest.fixture(scope="package")
  34. def salt_minion_1(salt_master):
  35. factory = salt_master.get_salt_minion_daemon(
  36. "pillar-functional-minion-1", config_defaults={"open_mode": True}
  37. )
  38. return factory
  39. @pytest.fixture(scope="package")
  40. def salt_minion_2(salt_master):
  41. factory = salt_master.get_salt_minion_daemon(
  42. "pillar-functional-minion-2", config_defaults={"open_mode": True}
  43. )
  44. return factory