Skip to content

Commit 36b990c

Browse files
committed
utest update
1 parent 0bd03e6 commit 36b990c

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

test/unit/plugin/test_dimms_collector.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,16 @@ def test_run_linux(collector, system_info):
6868
system_info.os_family = OSFamily.LINUX
6969

7070
collector._run_sut_cmd = MagicMock(
71-
return_value=MagicMock(
72-
exit_code=0,
73-
stdout="Size: 64 GB\nSize: 64 GB\nSize: 128 GB\n",
74-
)
71+
side_effect=[
72+
MagicMock(
73+
exit_code=0,
74+
stdout="Full dmidecode output...",
75+
),
76+
MagicMock(
77+
exit_code=0,
78+
stdout="Size: 64 GB\nSize: 64 GB\nSize: 128 GB\n",
79+
),
80+
]
7581
)
7682

7783
result, data = collector.collect_data()
@@ -84,15 +90,23 @@ def test_run_linux_error(collector, system_info):
8490
system_info.os_family = OSFamily.LINUX
8591

8692
collector._run_sut_cmd = MagicMock(
87-
return_value=MagicMock(
88-
exit_code=1,
89-
stderr="Error occurred",
90-
)
93+
side_effect=[
94+
MagicMock(
95+
exit_code=1,
96+
stderr="Error occurred",
97+
command="dmidecode",
98+
),
99+
MagicMock(
100+
exit_code=1,
101+
stderr="Error occurred",
102+
command="sh -c 'dmidecode -t 17 | ...'",
103+
),
104+
]
91105
)
92106

93107
result, data = collector.collect_data()
94108

95109
assert result.status == ExecutionStatus.ERROR
96110
assert data is None
97-
assert result.events[0].category == EventCategory.OS.value
98-
assert result.events[0].description == "Error checking dimms"
111+
assert result.events[1].category == EventCategory.OS.value
112+
assert result.events[1].description == "Error checking dimms"

0 commit comments

Comments
 (0)