Convert test_custom grains test to pytest

Converts the test_custom grains test from an old style test to a pytest
test. This is just to make it easier for me to debug why it is failing
and needs to be done at some point anyway.
This commit is contained in:
Barney Sowood 2025-01-16 21:02:53 +00:00 committed by Daniel Wozniak
parent 2ca8551615
commit 9a327c5919
3 changed files with 21 additions and 24 deletions

View file

@ -155,7 +155,7 @@ salt/engines/*:
- pytests.unit.engines.test_engines
salt/grains/*:
- integration.grains.test_custom
- pytests.integration.grains.test_custom
salt/matchers/*:
- integration.states.test_match

View file

@ -1,23 +0,0 @@
"""
Test the core grains
"""
import pytest
from tests.support.case import ModuleCase
@pytest.mark.windows_whitelisted
class TestGrainsCore(ModuleCase):
"""
Test the core grains grains
"""
@pytest.mark.slow_test
def test_grains_passed_to_custom_grain(self):
"""
test if current grains are passed to grains module functions that have a grains argument
"""
self.assertEqual(
self.run_function("grains.get", ["custom_grain_test"]), "itworked"
)

View file

@ -0,0 +1,20 @@
"""
Test the custom grains
"""
import pytest
pytestmark = [
pytest.mark.windows_whitelisted,
pytest.mark.slow_test,
]
def test_grains_passed_to_custom_grain(salt_call_cli):
"""
test if current grains are passed to grains module functions that have a grains argument
"""
ret = salt_call_cli.run("grains.item", "custom_grain_test")
assert ret.returncode == 0
assert ret.data
assert ret.data["custom_grain_test"] == "itworked"