Skip to content

Commit 2872014

Browse files
committed
Dev: unittests: Adjust unit test for previous commit
1 parent 6655669 commit 2872014

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

test/unittests/test_crashtest_utils.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -367,23 +367,14 @@ def test_check_node_status(self, mock_run, mock_error):
367367
])
368368
mock_error.assert_not_called()
369369

370-
@mock.patch('crmsh.sh.ShellUtils.get_stdout_stderr')
371-
def test_online_nodes_empty(self, mock_run):
372-
mock_run.return_value = (0, "data", None)
373-
res = utils.online_nodes()
374-
self.assertEqual(res, [])
375-
mock_run.assert_called_once_with("crm_mon -1")
376-
377-
@mock.patch('crmsh.sh.ShellUtils.get_stdout_stderr')
378-
def test_online_nodes(self, mock_run):
379-
output = """
380-
Node List:
381-
* Online: [ 15sp2-1 15sp2-2 ]
382-
"""
383-
mock_run.return_value = (0, output, None)
370+
@mock.patch('crmsh.xmlutil.CrmMonXmlParser')
371+
def test_online_nodes(self, mock_crmmon_parser):
372+
mock_inst = mock.Mock()
373+
mock_crmmon_parser.return_value = mock_inst
374+
mock_inst.get_node_list.return_value = ["node1", "node2"]
384375
res = utils.online_nodes()
385-
self.assertEqual(res, ["15sp2-1", "15sp2-2"])
386-
mock_run.assert_called_once_with("crm_mon -1")
376+
self.assertEqual(res, ["node1", "node2"])
377+
mock_inst.get_node_list.assert_called_once_with(online=True, node_type='member')
387378

388379
@mock.patch('crmsh.crash_test.utils.online_nodes')
389380
def test_peer_node_list_empty(self, mock_online):

test/unittests/test_utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,11 +1052,13 @@ def test_set_dlm_option(mock_get_dict, mock_run):
10521052
mock_run_inst.get_stdout_or_raise_error.assert_called_once_with('dlm_tool set_config "key2=test"', None)
10531053

10541054

1055-
@mock.patch('crmsh.utils.has_resource_configured')
1056-
def test_is_dlm_configured(mock_configured):
1057-
mock_configured.return_value = True
1055+
@mock.patch('crmsh.xmlutil.CrmMonXmlParser')
1056+
def test_is_dlm_configured(mock_crmmon):
1057+
mock_crmmon_inst = mock.Mock()
1058+
mock_crmmon.return_value = mock_crmmon_inst
1059+
mock_crmmon_inst.is_resource_configured.return_value = True
10581060
assert utils.is_dlm_configured() is True
1059-
mock_configured.assert_called_once_with(constants.DLM_CONTROLD_RA, peer=None)
1061+
mock_crmmon_inst.is_resource_configured.assert_called_once_with(constants.DLM_CONTROLD_RA)
10601062

10611063

10621064
@mock.patch('crmsh.sh.cluster_shell')

0 commit comments

Comments
 (0)