From 9ea88c5bef28a63761201df4cd2995fc0cc8e5b4 Mon Sep 17 00:00:00 2001 From: Tyler Levy Conde Date: Tue, 4 Jun 2024 15:15:34 -0600 Subject: [PATCH] removed clutter --- .../pytests/unit/state/test_state_compiler.py | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/tests/pytests/unit/state/test_state_compiler.py b/tests/pytests/unit/state/test_state_compiler.py index b1bfacece1c..5cbebbf77c7 100644 --- a/tests/pytests/unit/state/test_state_compiler.py +++ b/tests/pytests/unit/state/test_state_compiler.py @@ -855,6 +855,128 @@ def test_call_chunk_sub_state_run(minion_opts): assert sub_state["__sls__"] == "external" +def test_aggregate_requisites(minion_opts): + """ + Test to ensure that the requisites are included in the aggregated low state. + """ + # The low that is returned from _mod_aggregrate + low = { + "state": "pkg", + "name": "other_pkgs", + "__sls__": "47628", + "__env__": "base", + "__id__": "other_pkgs", + "pkgs": ["byobu", "vim", "tmux", "google-cloud-sdk"], + "aggregate": True, + "order": 10002, + "fun": "installed", + "__agg__": True, + } + + # Chunks that have been processed through the pkg mod_aggregate function + chunks = [ + { + "state": "file", + "name": "/tmp/install-vim", + "__sls__": "47628", + "__env__": "base", + "__id__": "/tmp/install-vim", + "order": 10000, + "fun": "managed", + }, + { + "state": "file", + "name": "/tmp/install-tmux", + "__sls__": "47628", + "__env__": "base", + "__id__": "/tmp/install-tmux", + "order": 10001, + "fun": "managed", + }, + { + "state": "pkg", + "name": "other_pkgs", + "__sls__": "47628", + "__env __": "base", + "__id__": "other_pkgs", + "pkgs": ["byobu"], + "aggregate": True, + "order": 10002, + "fun": "installed", + }, + { + "state": "pkg", + "name": "bc", + "__sls__": "47628", + "__env__": "base", + "__id__": "bc", + "hold": True, + "__agg__": True, + "order": 10003, + "fun": "installed", + }, + { + "state": "pkg", + "name": "vim", + "__sls__": "47628", + "__env__": "base", + "__agg__": True, + "__id__": "vim", + "require": ["/tmp/install-vim"], + "order": 10004, + "fun": "installed", + }, + { + "state": "pkg", + "name": "tmux", + "__sls__": "47628", + "__env__": "base", + "__agg__": True, + "__id__": "tmux", + "require": ["/tmp/install-tmux"], + "order": 10005, + "fun": "installed", + }, + { + "state": "pkgrepo", + "name": "deb https://packages.cloud.google.com/apt cloud-sdk main", + "__sls__": "47628", + "__env__": "base", + "__id__": "google-cloud-repo", + "humanname": "Google Cloud SDK", + "file": "/etc/apt/sources.list.d/google-cloud-sdk.list", + "key_url": "https://packages.cloud.google.com/apt/doc/apt-key.gpg", + "order": 10006, + "fun": "managed", + }, + { + "state": "pkg", + "name": "google-cloud-sdk", + "__sls__": "47628", + "__env__": "base", + "__agg__": True, + "__id__": "google-cloud-sdk", + "require": ["google-cloud-repo"], + "order": 10007, + "fun": "installed", + }, + ] + + with patch("salt.state.State._gather_pillar"): + state_obj = salt.state.State(minion_opts) + low_ret = state_obj._aggregate_requisites(low, chunks) + + # Ensure the low returned contains require + assert "require" in low_ret + + # Ensure all the requires from pkg states are in low + assert low_ret["require"] == [ + "/tmp/install-vim", + "/tmp/install-tmux", + "google-cloud-repo", + ] + + def test_mod_aggregate(minion_opts): """ Test to ensure that the requisites are included in the aggregated low state.