Skip to content

Commit c9b79dc

Browse files
authored
[Smartswitch] Update the type of reboot status variable for DPU (#311)
1 parent 805ff5b commit c9b79dc

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

host_modules/reboot.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ def populate_reboot_status_flag(self, active = False, when = 0, reason = "", met
6161
self.reboot_status_flag["reason"] = reason
6262
self.reboot_status_flag["count"] = self.reboot_count
6363
self.reboot_status_flag["method"] = method
64-
self.reboot_status_flag["status"] = status.value
64+
# status value should be of type RebootStatus
65+
self.reboot_status_flag["status"] = {
66+
"status": status.value,
67+
"message": ""
68+
}
6569
self.lock.release()
6670
return
6771

tests/host_modules/reboot_test.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,21 @@ def test_populate_reboot_status_flag(self):
7373
assert get_reboot_status_flag_data["reason"] == ""
7474
assert get_reboot_status_flag_data["count"] == 0
7575
assert get_reboot_status_flag_data["method"] == ""
76-
assert get_reboot_status_flag_data["status"] == RebootStatus.STATUS_UNKNOWN.value
76+
assert get_reboot_status_flag_data["status"] == {
77+
"status": RebootStatus.STATUS_UNKNOWN.value,
78+
"message": ""
79+
}
7780

7881
def test_populate_reboot_status_flag_with_status(self):
7982
with mock.patch("time.time", return_value=1617811205.25):
8083
self.reboot_module.populate_reboot_status_flag(status=RebootStatus.STATUS_SUCCESS)
8184
return_value, get_reboot_status_flag_data = self.reboot_module.get_reboot_status()
8285
assert return_value == 0
8386
get_reboot_status_flag_data = json.loads(get_reboot_status_flag_data)
84-
assert get_reboot_status_flag_data["status"] == RebootStatus.STATUS_SUCCESS.value
87+
assert get_reboot_status_flag_data["status"] == {
88+
"status": RebootStatus.STATUS_SUCCESS.value,
89+
"message": ""
90+
}
8591

8692
def test_validate_reboot_request_success_cold_boot_enum_method(self):
8793
reboot_request = {"method": REBOOT_METHOD_COLD_BOOT_ENUM, "reason": "test reboot request reason"}
@@ -391,7 +397,10 @@ def test_get_reboot_status_active(self):
391397
assert response_data["when"] == TIME
392398
assert response_data["reason"] == MSG
393399
assert response_data["method"] == REBOOT_METHOD_COLD_BOOT_ENUM
394-
assert response_data["status"] == RebootStatus.STATUS_SUCCESS.value
400+
assert response_data["status"] == {
401+
"status": RebootStatus.STATUS_SUCCESS.value,
402+
"message": ""
403+
}
395404

396405
def test_get_reboot_status_inactive(self):
397406
self.reboot_module.populate_reboot_status_flag(False, 0, "", REBOOT_METHOD_COLD_BOOT_ENUM, RebootStatus.STATUS_SUCCESS)
@@ -402,7 +411,10 @@ def test_get_reboot_status_inactive(self):
402411
assert response_data["when"] == 0
403412
assert response_data["reason"] == ""
404413
assert response_data["method"] == REBOOT_METHOD_COLD_BOOT_ENUM
405-
assert response_data["status"] == RebootStatus.STATUS_SUCCESS.value
414+
assert response_data["status"] == {
415+
"status": RebootStatus.STATUS_SUCCESS.value,
416+
"message": ""
417+
}
406418

407419
# assert result[1] == TEST_INACTIVE_RESPONSE_DATA
408420

0 commit comments

Comments
 (0)