def test_dataset(self): # downloading the example dataset urn = 'urn:nbn:fi:att:d2cf4977-36fa-4762-adb3-126ea06108ed' download_status, download_data = download.download_dataset(urn) self.assertIn(download_status, self.OK, "Download could not download the dataset")
def test_download_directory_from_dataset(self): # downloading a dir from the example dataset urn_and_dir = '%s?dir=%s' % (self._test_dataset_identifier, self._test_root_directory_identifier) download_status, download_data = download.download_dataset(urn_and_dir) self.assertIn(download_status, self.OK, "Download could not download the file")
def test_download_single_file_from_dataset(self): # get identifier of a single file in the dataset. using a bit more params to ensure files are returned... response = requests.get( '%s/rest/directories/%s/files?cr_identifier=%s&recursive=true&depth=*&file_fields=identifier' % (metax_host, self._test_root_directory_identifier, self._test_dataset_identifier), auth=metax_auth, verify=False) self.assertEqual( response.status_code, 200, 'test setup failed - metax says: %s' % str(response.json())) file_identifier = response.json()[0]['identifier'] urn_and_file = '%s?file=%s' % (self._test_dataset_identifier, file_identifier) download_status, download_data = download.download_dataset( urn_and_file) self.assertIn(download_status, self.OK, "Download could not download the file")
def test_dir(self): # downloading a dir from the example dataset urn = 'urn:nbn:fi:att:d2cf4977-36fa-4762-adb3-126ea06108ed?dir=c66c97e387933b82a734d904cc9572a3' download_status, download_data = download.download_dataset(urn) self.assertIn(download_status, self.OK, "Download could not download the file")
def test_file(self): # downloading a file from the example dataset urn = 'urn:nbn:fi:att:d2cf4977-36fa-4762-adb3-126ea06108ed?file=5b7d486c951df671401089f134223' download_status, download_data = download.download_dataset(urn) self.assertIn(download_status, self.OK, "Download could not download the file")
def test_download_all_files_from_dataset(self): # downloading the example dataset download_status, download_data = download.download_dataset( self._test_dataset_identifier) self.assertIn(download_status, self.OK, "Download could not download the dataset")