Exemple #1
0
def test_node_snapshot_list(mock_do_snapshot_request, mock_get, mock_cosmos):
    """
    Test _snapshot_manage(), should not fail
    """

    mock_cosmos().enabled.return_value = True
    m = mock.MagicMock()
    m.json.return_value = {
        'capabilities': [{'name': 'SUPPORT_CLUSTER_REPORT'}]
    }
    mock_get.return_value = m
    mock_do_snapshot_request.return_value = {
        '127.0.0.1': [
            {
                'file_name': 'snapshot.zip',
                'file_size': 123
            }
        ]
    }

    # _snapshot_manage(list_snapshots, status, cancel, json)
    main._snapshot_manage(True, False, False, False)
    mock_do_snapshot_request.assert_called_once_with(
        '/system/health/v1/report/snapshot/list/all',
        'GET'
    )
Exemple #2
0
def test_node_snapshot_cancel(mock_do_snapshot_request, mock_get, mock_cosmos):
    """
    Test _snapshot_manage(), should not fail
    """

    mock_cosmos().enabled.return_value = True
    m = mock.MagicMock()
    m.json.return_value = {
        'capabilities': [{'name': 'SUPPORT_CLUSTER_REPORT'}]
    }
    mock_get.return_value = m
    mock_do_snapshot_request.return_value = {
        'status': 'success'
    }

    # _snapshot_manage(list_snapshots, status, cancel, json)
    main._snapshot_manage(False, False, True, False)
    mock_do_snapshot_request.assert_called_once_with(
        '/system/health/v1/report/snapshot/cancel',
        'POST'
    )