def test_get_accession_id_no_script(self): accession_id = transfer.get_accession_id(os.path.curdir) self.assertEqual(accession_id, None)
def _start_transfer(ss_url, ss_user, ss_api_key, ts_location_uuid, ts_path, depth, am_url, am_user, am_api_key, transfer_type, see_files, session): """ Start a new transfer. This is an early implementation and an alternative to ``transfer.start_transfer`` that uses the new ``/api/v2beta/package`` API. Because transfers start immediately we don't run the scripts inside the pre-transfer directory like ``transfer.start_transfer`` does. :param ss_url: URL of the Storage Sevice to query :param ss_user: User on the Storage Service for authentication :param ss_api_key: API key for user on the Storage Service for authentication :param ts_location_uuid: UUID of the transfer source Location :param ts_path: Relative path inside the Location to work with. :param depth: Depth relative to ts_path to create a transfer from. Should be 1 or greater. :param am_url: URL of Archivematica pipeline to start transfer on :param am_user: User on Archivematica for authentication :param am_api_key: API key for user on Archivematica for authentication :param bool see_files: If true, start transfers from files as well as directories :param session: SQLAlchemy session with the DB :returns: Tuple of Transfer information about the new transfer or None on error. """ # Start new transfer completed = {x[0] for x in session.query(Unit.path).all()} target = get_next_transfer(ss_url, ss_user, ss_api_key, ts_location_uuid, ts_path, depth, completed, see_files) if not target: LOGGER.warning( "All potential transfers in %s have been created. Exiting", ts_path) return None LOGGER.info("Starting with %s", target) # Get accession ID accession = get_accession_id(target) LOGGER.info("Accession ID: %s", accession) try: result = _api_create_package( am_url, am_user, am_api_key, os.path.basename(target), transfer_type, accession, ts_location_uuid, target, ) except (requests.exceptions.HTTPError, ValueError, DashboardAPIError) as err: LOGGER.error('Unable to start transfer: %s', err) new_transfer = Unit(path=target, unit_type='transfer', status='FAILED', current=False) session.add(new_transfer) return None LOGGER.info('Package created: %s', result['id']) new_transfer = Unit(uuid=result['id'], path=target, unit_type='transfer', current=True) LOGGER.info('New transfer: %s', new_transfer) session.add(new_transfer) return new_transfer
def test_get_accession_id_no_script(self): accession_id = transfer.get_accession_id(os.path.curdir) assert accession_id is None