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

Docstrings and ai exclude #660

Merged
merged 2 commits into from
Nov 15, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

- id: setmatrix
run: |
set stringified_matrix (tox -l | sed -e '/unit/d' -e '/get_urls/d' -e '/doc/d' -e '/lint/d' -e '/fips/d' | jo -a)
set stringified_matrix (tox -l | sed -e '/unit/d' -e '/get_urls/d' -e '/doc/d' -e '/lint/d' -e '/fips/d' -e '/ai/d' | jo -a)

set users_envs (echo $PR_BODY | awk -F' ' '/^\[CI:TOXENVS\]/ { print $2 }')
if [ -n "$users_envs" ]
Expand Down
29 changes: 29 additions & 0 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,41 @@


def test_host_fips_supported(tmp_path):
"""Check that ``host_fips_supported`` correctly returns True if the fips
file exists.

"""
fipsfile = tmp_path / "fips"
fipsfile.write_text("")
assert host_fips_supported(f"{fipsfile}")


def test_host_fips_enabled(tmp_path):
"""Check that ``host_fips_enabled`` correctly returns True if the fips file
contains a 1.

"""
fipsfile = tmp_path / "fips"
fipsfile.write_text("1")
assert host_fips_enabled(f"{fipsfile}")


def test_host_fips_disabled(tmp_path):
"""Check that ``host_fips_enabled`` correctly returns False if the fips file
contains nothing.

"""
fipsfile = tmp_path / "fips"
fipsfile.write_text("")
assert not host_fips_enabled(f"{fipsfile}")


def test_repository_from_xml():
"""Test that ``get_repos_from_zypper_xmlout`` correctly identifies the
SLE_BCI and the microsoft .Net repository from a saved output of
``zypper -x repos``.

"""
repos = get_repos_from_zypper_xmlout(
"""<?xml version='1.0'?>
<stream>
Expand Down Expand Up @@ -69,16 +86,28 @@ def test_repository_from_xml():


def test_selinux_disabled(tmp_path: Path) -> None:
"""Validate that ``selinux_status`` reports ``disabled`` if the sysfs
directory is empty.

"""
assert selinux_status(str(tmp_path)) == "disabled"


def test_selinux_enforcing(tmp_path: Path) -> None:
"""Check that ``selinux_status`` returns ``enforcing`` when there's a file
:file:`enforce` in the sysfs directory and it contains a ``1``.

"""
(tmp_path / "enforce").touch()
(tmp_path / "enforce").write_text("1\n")
assert selinux_status(str(tmp_path)) == "enforcing"


def test_selinux_permissive(tmp_path: Path) -> None:
"""Check that ``selinux_status`` returns ``permissive`` when there's a file
:file:`enforce` in the sysfs directory and it contains a ``0``.

"""
(tmp_path / "enforce").touch()
(tmp_path / "enforce").write_text("0\n")
assert selinux_status(str(tmp_path)) == "permissive"
Loading