Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert test_custom grains test to pytest and fix integration tests fileserver issue #67164

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import _pytest.skipping
import more_itertools
import pytest
import pytestskipmarkers

import salt
import salt._logging
Expand Down Expand Up @@ -426,7 +427,8 @@ def pytest_itemcollected(item):
pytest.fail(
"The test {!r} appears to be written for pytest but it's not under"
" {!r}. Please move it there.".format(
item.nodeid, str(PYTESTS_DIR.relative_to(CODE_DIR)), pytrace=False
item.nodeid,
str(PYTESTS_DIR.relative_to(CODE_DIR)),
)
)

Expand Down Expand Up @@ -801,6 +803,12 @@ def salt_factories_default_root_dir(salt_factories_default_root_dir):
dictionary, then that's the value used, and not the one returned by
this fixture.
"""
if os.environ.get("CI") and pytestskipmarkers.utils.platform.is_windows():
tempdir = pathlib.Path(
os.environ.get("RUNNER_TEMP", r"C:\Windows\Temp")
).resolve()
return tempdir / "stsuite"

return salt_factories_default_root_dir / "stsuite"


Expand Down
2 changes: 1 addition & 1 deletion tests/filename_map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 0 additions & 23 deletions tests/integration/grains/test_custom.py

This file was deleted.

20 changes: 20 additions & 0 deletions tests/pytests/integration/grains/test_custom.py
Original file line number Diff line number Diff line change
@@ -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"
Loading