Skip to content
This repository was archived by the owner on Aug 9, 2024. It is now read-only.

Drop needs_reboot conditional in _check_status(...) #11

Merged
merged 4 commits into from
Apr 28, 2023
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
6 changes: 1 addition & 5 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,8 @@ def _check_slurmdbd(self, max_attemps=5) -> None:
else:
self.unit.status = BlockedStatus("Cannot start slurmdbd")

def _check_status(self) -> bool:
def _check_status(self) -> bool: # noqa C901
"""Check that we have the things we need."""
if self._slurm_manager.needs_reboot:
self.unit.status = BlockedStatus("Machine needs reboot")
return False

slurm_installed = self._stored.slurm_installed
if not slurm_installed:
self.unit.status = BlockedStatus("Error installing slurm")
Expand Down
15 changes: 1 addition & 14 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,7 @@ def test_is_not_leader(self, _) -> None:
"""Test opposite case of _is_leader method."""
self.assertEqual(self.harness.charm._is_leader(), self.harness.charm.unit.is_leader())

@patch("slurm_ops_manager.SlurmManager.needs_reboot", return_value=True)
def test_check_status_needs_reboot(self, _) -> None:
"""Test that _check_status method works if unit needs reboot."""
res = self.harness.charm._check_status()
self.assertEqual(self.harness.charm.unit.status, BlockedStatus("Machine needs reboot"))
self.assertFalse(
res, msg="_check_status returned value True instead of expected value False."
)

@patch(
"slurm_ops_manager.SlurmManager.needs_reboot",
new_callable=PropertyMock(return_value=False),
)
def test_check_status_slurm_not_installed(self, _) -> None:
def test_check_status_slurm_not_installed(self) -> None:
"""Test that _check_status method works if slurm is not installed."""
self.harness.charm._stored.slurm_installed = True
res = self.harness.charm._check_status()
Expand Down