-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import unittest | ||
from unittest.mock import patch | ||
|
||
from prometheus_hardware_exporter.collectors.dmidecode import Dmidecode | ||
from prometheus_hardware_exporter.utils import Command, Result | ||
|
||
TYPE_39_OUTPUT = "tests/unit/test_resources/dmidecode/dmidecode_type_39_output.txt" | ||
|
||
|
||
class TestDmidecode(unittest.TestCase): | ||
"""Test the Dmidecode class.""" | ||
|
||
@patch.object(Command, "__call__") | ||
def test_00_get_power_capacities_success(self, mock_call): | ||
with open(TYPE_39_OUTPUT, "r") as content: | ||
mock_call.return_value = Result(content.read(), None) | ||
dmidecode = Dmidecode() | ||
power_capacities = dmidecode.get_power_capacities() | ||
self.assertEqual(power_capacities, [1400, 1400]) | ||
|
||
@patch.object(Command, "__call__") | ||
def test_01_get_power_capacities_error(self, mock_call): | ||
mock_call.return_value = Result("", True) | ||
|
||
dmidecode = Dmidecode() | ||
power_capacities = dmidecode.get_power_capacities() | ||
self.assertEqual(power_capacities, []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/unit/test_resources/dmidecode/dmidecode_type_39_output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# dmidecode 3.3 | ||
Getting SMBIOS data from sysfs. | ||
SMBIOS 3.3.0 present. | ||
|
||
Handle 0x2700, DMI type 39, 22 bytes | ||
System Power Supply | ||
Location: Not Specified | ||
Name: PWR SPLY,1400W,RDNT,LTON | ||
Manufacturer: DELL | ||
Serial Number: CNLOD0019M3A6D | ||
Asset Tag: Not Specified | ||
Model Part Number: 01CW9GA04 | ||
Revision: Not Specified | ||
Max Power Capacity: 1400 W | ||
Status: Present, Unknown | ||
Type: Unknown | ||
Input Voltage Range Switching: Unknown | ||
Plugged: Yes | ||
Hot Replaceable: Yes | ||
|
||
Handle 0x2701, DMI type 39, 22 bytes | ||
System Power Supply | ||
Location: Not Specified | ||
Name: PWR SPLY,1400W,RDNT,LTON | ||
Manufacturer: DELL | ||
Serial Number: CNLOD0019M369D | ||
Asset Tag: Not Specified | ||
Model Part Number: 01CW9GA04 | ||
Revision: Not Specified | ||
Max Power Capacity: 1400 W | ||
Status: Present, Unknown | ||
Type: Unknown | ||
Input Voltage Range Switching: Unknown | ||
Plugged: Yes | ||
Hot Replaceable: Yes |
3 changes: 3 additions & 0 deletions
3
tests/unit/test_resources/ipmi/ipmitool_sdr_ps_sample_output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
PS Redundancy,77h,ok,7.1,Fully Redundant | ||
Status,85h,ok,10.1,Presence detected | ||
Status,86h,ok,10.2,Presence detected |