"Fossies" - the Fresh Open Source Software Archive

Member "salt-3002.2/tests/pytests/unit/test_minion.py" (18 Nov 2020, 770 Bytes) of package /linux/misc/salt-3002.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 import salt.minion
    2 from tests.support.mock import patch
    3 
    4 
    5 def test_minion_grains_in_opts():
    6     """
    7     Minion does not generate grains when they are already in opts
    8     """
    9     opts = {"random_startup_delay": 0, "grains": {"foo": "bar"}}
   10     with patch("salt.loader.grains") as grainsfunc:
   11         minion = salt.minion.Minion(opts)
   12         assert minion.opts["grains"] == opts["grains"]
   13         grainsfunc.assert_not_called()
   14 
   15 
   16 def test_minion_grains_not_in_opts():
   17     """
   18     Minion generates grains when they are not already in opts
   19     """
   20     opts = {"random_startup_delay": 0, "grains": {}}
   21     with patch("salt.loader.grains") as grainsfunc:
   22         minion = salt.minion.Minion(opts)
   23         assert minion.opts["grains"] != {}
   24         grainsfunc.assert_called()