Esempio n. 1
0
def dataverse_get_datasets(node_addon, **kwargs):
    alias = request.json.get("alias")
    user_settings = node_addon.user_settings

    connection = client.connect_from_settings(user_settings)
    dataverse = client.get_dataverse(connection, alias)
    datasets = client.get_datasets(dataverse)
    ret = {"datasets": [{"title": dataset.title, "doi": dataset.doi} for dataset in datasets]}
    return ret, http.OK
Esempio n. 2
0
def dataverse_get_datasets(node_addon, **kwargs):
    """Get list of datasets from provided Dataverse alias"""
    alias = request.json.get('alias')

    connection = client.connect_from_settings(node_addon)
    dataverse = client.get_dataverse(connection, alias)
    datasets = client.get_datasets(dataverse)
    ret = {
        'alias': alias,  # include alias to verify dataset container
        'datasets': [{'title': dataset.title, 'doi': dataset.doi} for dataset in datasets],
    }
    return ret, http.OK
Esempio n. 3
0
def dataverse_get_datasets(node_addon, **kwargs):
    """Get list of datasets from provided Dataverse alias"""
    alias = request.json.get('alias')

    connection = client.connect_from_settings(node_addon)
    dataverse = client.get_dataverse(connection, alias)
    datasets = client.get_datasets(dataverse)
    ret = {
        'alias': alias,  # include alias to verify dataset container
        'datasets': [{'title': dataset.title, 'doi': dataset.doi} for dataset in datasets],
    }
    return ret, http.OK
Esempio n. 4
0
    def test_get_datasets(self):
        mock_dataset1 = mock.create_autospec(Dataset)
        mock_dataset2 = mock.create_autospec(Dataset)
        mock_dataset3 = mock.create_autospec(Dataset)
        mock_dataset1.get_state.return_value = "DRAFT"
        mock_dataset2.get_state.return_value = "RELEASED"
        mock_dataset3.get_state.return_value = "DEACCESSIONED"
        self.mock_dataverse.get_datasets.return_value = [mock_dataset1, mock_dataset2, mock_dataset3]

        datasets = get_datasets(self.mock_dataverse)
        self.mock_dataverse.get_datasets.assert_called_once_with()
        assert_in(mock_dataset1, datasets)
        assert_in(mock_dataset2, datasets)
        assert_in(mock_dataset3, datasets)
Esempio n. 5
0
def dataverse_get_datasets(node_addon, **kwargs):
    alias = request.json.get('alias')
    user_settings = node_addon.user_settings

    connection = client.connect_from_settings(user_settings)
    dataverse = client.get_dataverse(connection, alias)
    datasets = client.get_datasets(dataverse)
    ret = {
        'datasets': [{
            'title': dataset.title,
            'doi': dataset.doi
        } for dataset in datasets],
    }
    return ret, http.OK
Esempio n. 6
0
    def test_get_datasets(self):
        mock_dataset1 = mock.create_autospec(Dataset)
        mock_dataset2 = mock.create_autospec(Dataset)
        mock_dataset3 = mock.create_autospec(Dataset)
        mock_dataset1.get_state.return_value = 'DRAFT'
        mock_dataset2.get_state.return_value = 'RELEASED'
        mock_dataset3.get_state.return_value = 'DEACCESSIONED'
        self.mock_dataverse.get_datasets.return_value = [
            mock_dataset1, mock_dataset2, mock_dataset3
        ]

        datasets = get_datasets(self.mock_dataverse)
        assert_is(self.mock_dataverse.get_datasets.assert_called_once_with(timeout=settings.REQUEST_TIMEOUT), None)
        assert_in(mock_dataset1, datasets)
        assert_in(mock_dataset2, datasets)
        assert_in(mock_dataset3, datasets)
Esempio n. 7
0
    def test_get_datasets(self):
        mock_dataset1 = mock.create_autospec(Dataset)
        mock_dataset2 = mock.create_autospec(Dataset)
        mock_dataset3 = mock.create_autospec(Dataset)
        mock_dataset1.get_state.return_value = 'DRAFT'
        mock_dataset2.get_state.return_value = 'RELEASED'
        mock_dataset3.get_state.return_value = 'DEACCESSIONED'
        self.mock_dataverse.get_datasets.return_value = [
            mock_dataset1, mock_dataset2, mock_dataset3
        ]

        datasets = get_datasets(self.mock_dataverse)
        self.mock_dataverse.get_datasets.assert_called_once_with()
        assert_in(mock_dataset1, datasets)
        assert_in(mock_dataset2, datasets)
        assert_in(mock_dataset3, datasets)
Esempio n. 8
0
 def test_get_datasets_no_dataverse(self):
     datasets = get_datasets(None)
     assert_equal(datasets, [])
Esempio n. 9
0
 def test_get_datasets_no_dataverse(self):
     datasets = get_datasets(None)
     assert_equal(datasets, [])