Skip to content

Commit

Permalink
Define an enum for Reboot Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
vvolam committed Sep 18, 2024
1 parent 49caaca commit 0e0fc79
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/host_modules/systemd_service_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import sys
import os
import pytest
from enum import Enum
from unittest import mock
from host_modules import systemd_service

class RebootMethod(Enum):
COLD = 1
HALT = 3

class TestSystemdService(object):
@mock.patch("dbus.SystemBus")
@mock.patch("dbus.service.BusName")
Expand Down Expand Up @@ -98,8 +103,7 @@ def test_execute_reboot_cold(self, MockInit, MockBusName, MockSystemBus):
res_mock.configure_mock(returncode=test_ret, stderr=test_msg)
mock_run.return_value = res_mock

# Define reboot method and instantiate the service
method = 1 # Method 1 corresponds to cold reboot
method = RebootMethod.COLD
systemd_service_stub = systemd_service.SystemdService(systemd_service.MOD_NAME)

# Execute the reboot method
Expand All @@ -126,8 +130,7 @@ def test_execute_reboot_halt(self, MockInit, MockBusName, MockSystemBus):
res_mock.configure_mock(returncode=test_ret, stderr=test_msg)
mock_run.return_value = res_mock

# Define reboot method and instantiate the service
method = 3 # Method 3 corresponds to halt reboot
method = RebootMethod.HALT
systemd_service_stub = systemd_service.SystemdService(systemd_service.MOD_NAME)

# Execute the reboot method
Expand Down

0 comments on commit 0e0fc79

Please sign in to comment.