Skip to content

Commit

Permalink
refactor: DetectVirtNotFoundError -> UnknownVirtStateError
Browse files Browse the repository at this point in the history
Signed-off-by: Jason C. Nucciarone <[email protected]>
  • Loading branch information
NucciTheBoss committed Jul 10, 2024
1 parent b225c56 commit aeb2418
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/charms/hpc_libs/v0/is_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def _on_install(self, _: InstallEvent) -> None:
LIBPATCH = 1


class DetectVirtNotFoundError(Exception):
"""Raise error if `systemd-detect-virt` executable is not found on machine."""
class UnknownVirtStateError(Exception):
"""Raise error if unknown virtualization state is returned."""

@property
def message(self) -> str:
Expand All @@ -70,7 +70,7 @@ def is_container() -> bool:
DetectVirtNotFoundError: Raised if `systemd-detect-virt` is not found on machine.
"""
if shutil.which("systemd-detect-virt") is None:
raise DetectVirtNotFoundError(
raise UnknownVirtStateError(
(
"executable `systemd-detect-virt` not found. "
+ "cannot determine if machine is a container instance"
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_is_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from unittest import TestCase
from unittest.mock import patch

from charms.hpc_libs.v0.is_container import DetectVirtNotFoundError, is_container
from charms.hpc_libs.v0.is_container import UnknownVirtStateError, is_container


@patch("charms.hpc_libs.v0.is_container.shutil.which", return_value="/usr/bin/systemd-detect-virt")
Expand All @@ -30,7 +30,7 @@ def test_detect_virt_not_found(self, _, which) -> None:

try:
is_container()
except DetectVirtNotFoundError as e:
except UnknownVirtStateError as e:
self.assertEqual(
e.message,
(
Expand Down

0 comments on commit aeb2418

Please sign in to comment.