def test_get_member_iplist_None(mock_get_stdout_stderr, mock_common_debug): mock_get_stdout_stderr.return_value = ( 1, None, "Failed to initialize the cmap API. Error CS_ERR_LIBRARY") assert utils.get_member_iplist() is None mock_get_stdout_stderr.assert_called_once_with( 'corosync-cmapctl -b runtime.totem.pg.mrp.srp.members') mock_common_debug.assert_called_once_with( 'Failed to initialize the cmap API. Error CS_ERR_LIBRARY')
def test_get_member_iplist(): with mock.patch('crmsh.utils.get_stdout_stderr') as mock_get_stdout_stderr: cmap_value = ''' runtime.totem.pg.mrp.srp.members.336860211.config_version (u64) = 0 runtime.totem.pg.mrp.srp.members.336860211.ip (str) = r(0) ip(20.20.20.51) runtime.totem.pg.mrp.srp.members.336860211.join_count (u32) = 1 runtime.totem.pg.mrp.srp.members.336860211.status (str) = joined runtime.totem.pg.mrp.srp.members.336860212.config_version (u64) = 0 runtime.totem.pg.mrp.srp.members.336860212.ip (str) = r(0) ip(20.20.20.52) runtime.totem.pg.mrp.srp.members.336860212.join_count (u32) = 1 runtime.totem.pg.mrp.srp.members.336860212.status (str) = joined ''' mock_get_stdout_stderr.return_value = (0, cmap_value, None) assert utils.get_member_iplist() == ['20.20.20.51', '20.20.20.52'] mock_get_stdout_stderr.assert_called_once_with('corosync-cmapctl -b runtime.totem.pg.mrp.srp.members')