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

Add tests for minimum free disk space check #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kpushkaryov
Copy link
Contributor

No description provided.

@kpushkaryov kpushkaryov self-assigned this Jan 25, 2024
"/usr": {"source": "/dev/sda1", "target": "/", "avail": req_sum},
"/var": {"source": "/dev/sdb1", "target": "/var", "avail": self._requirements["/var"]},
}
with mock.patch(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going to mock all subprocess.run function calls here, this could cause issues when we add more function calls within check_min_free_disk_space.

@@ -158,6 +158,60 @@ class MinFreeDiskSpaceViolation(typing.NamedTuple):
"""Paths belonging to this device."""


def check_min_free_disk_space(requirements: typing.Dict[str, int]) -> typing.List[MinFreeDiskSpaceViolation]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we could split this function into two parts - retrieving data from the findmnt utility and check restrictions. So in tests we could just mock the retriving data function itself, but not the subprocess.run.

from pleskdistup.common import log


def init_logger():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could move the change into separated commit. Something like: "Enable logging for tests"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants