Skip to content

Add tests for minimum free disk space check#7

Open
kpushkaryov wants to merge 1 commit intomainfrom
kp-tests-check-disk-space
Open

Add tests for minimum free disk space check#7
kpushkaryov wants to merge 1 commit intomainfrom
kp-tests-check-disk-space

Conversation

@kpushkaryov
Copy link
Copy Markdown
Contributor

No description provided.

@kpushkaryov kpushkaryov self-assigned this Jan 25, 2024
Comment thread tests/common_checks.py
"/usr": {"source": "/dev/sda1", "target": "/", "avail": req_sum},
"/var": {"source": "/dev/sdb1", "target": "/var", "avail": self._requirements["/var"]},
}
with mock.patch(
Copy link
Copy Markdown
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.

"""Paths belonging to this device."""


def check_min_free_disk_space(requirements: typing.Dict[str, int]) -> typing.List[MinFreeDiskSpaceViolation]:
Copy link
Copy Markdown
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.

Comment thread tests/test_main.py
from pleskdistup.common import log


def init_logger():
Copy link
Copy Markdown
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