예제 #1
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
예제 #2
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)
예제 #3
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)
예제 #4
0
 def test_get_datasets_no_dataverse(self):
     datasets = get_datasets(None)
     assert_equal(datasets, [])
예제 #5
0
 def test_get_datasets_no_dataverse(self):
     datasets = get_datasets(None)
     assert_equal(datasets, [])