def test_add_dataset_from_xml(self): new_dataset = Dataset.from_xml_file(ATOM_DATASET) self.dataverse._add_dataset(new_dataset) retrieved_dataset = self.dataverse.get_dataset_by_title( 'Roasting at Home') assert retrieved_dataset self.dataverse.delete_dataset(retrieved_dataset)
def create_dataset(self, title, description, creator, **kwargs): dataset = Dataset(title=title, description=description, creator=creator, **kwargs) self._add_dataset(dataset) return dataset
def test_delete_a_dataset(self): xmlDataset = Dataset.from_xml_file(ATOM_DATASET) self.dataverse._add_dataset(xmlDataset) atomDataset = self.dataverse.get_dataset_by_title('Roasting at Home') num_datasets = len(self.dataverse.get_datasets()) assert num_datasets > 0 self.dataverse.delete_dataset(atomDataset) assert atomDataset.get_state(refresh=True) == 'DEACCESSIONED' assert len(self.dataverse.get_datasets()) == num_datasets - 1
def test_init_from_xml(self): dataset = Dataset.from_xml_file(ATOM_DATASET) title = utils.get_element(dataset.get_entry(), namespace='dcterms', tag='title').text publisher = utils.get_element(dataset.get_entry(), namespace='dcterms', tag='rights').text assert title == 'Roasting at Home' assert publisher == 'Creative Commons CC-BY 3.0 (unported) http://creativecommons.org/licenses/by/3.0/'
def test_init(self): dataset = Dataset(title='My Dataset', publisher='Mr. Pub Lisher') title = utils.get_element(dataset._entry, namespace='dcterms', tag='title').text publisher = utils.get_element(dataset._entry, namespace='dcterms', tag='publisher').text assert title == 'My Dataset' assert title == dataset.title assert publisher == 'Mr. Pub Lisher'
def test_delete_a_dataset(self): xmlDataset = Dataset.from_xml_file(ATOM_DATASET) self.dv.add_dataset(xmlDataset) atomDataset = self.dv.get_dataset_by_title("Roasting at Home") self.assertTrue(atomDataset) num_datasets = len(self.dv.get_datasets()) self.assertTrue(num_datasets > 0) self.dv.delete_dataset(atomDataset) self.assertEqual(atomDataset.get_state(refresh=True), 'DEACCESSIONED') self.assertEqual(len(self.dv.get_datasets()), num_datasets - 1)
def test_init_from_xml(self): dataset = Dataset.from_xml_file(ATOM_DATASET) title = utils.get_element( dataset.get_entry(), namespace='dcterms', tag='title' ).text publisher = utils.get_element( dataset.get_entry(), namespace='dcterms', tag='rights' ).text self.assertEqual(title, 'Roasting at Home') self.assertEqual(publisher, 'Creative Commons CC-BY 3.0 (unported) http://creativecommons.org/licenses/by/3.0/')
def get_datasets(self, refresh=False, timeout=None): collection_info = self.get_collection_info(refresh, timeout=timeout) entries = get_elements(collection_info, tag='entry') return [Dataset.from_dataverse(entry, self) for entry in entries]
def setup_method(self, method): # create a dataset for each test dataset = Dataset(**PICS_OF_CATS_DATASET) self.dataverse._add_dataset(dataset) self.dataset = self.dataverse.get_dataset_by_doi(dataset.doi)
def test_add_dataset_from_xml(self): new_dataset = Dataset.from_xml_file(ATOM_DATASET) self.dataverse._add_dataset(new_dataset) retrieved_dataset = self.dataverse.get_dataset_by_title('Roasting at Home') assert retrieved_dataset self.dataverse.delete_dataset(retrieved_dataset)
def test_create_dataset_from_xml(self): new_dataset = Dataset.from_xml_file(ATOM_DATASET) self.dv.add_dataset(new_dataset) retrieved_dataset = self.dv.get_dataset_by_title("Roasting at Home") self.assertTrue(retrieved_dataset) self.dv.delete_dataset(retrieved_dataset)