def test_augment_ids(): client = ArchivesSpaceClient(**AUTH) data = client.augment_resource_ids( ['/repositories/2/resources/1', '/repositories/2/resources/2']) assert len(data) == 2 assert data[0]['title'] == 'Test fonds' assert data[1]['title'] == 'Some other fonds'
def test_identifier_search_exact_match(): client = ArchivesSpaceClient(**AUTH) assert client.find_collection_ids(identifier='F1') == [ '/repositories/2/resources/1' ] assert client.count_collections(identifier='F1') == 1 assert len(client.find_collections(identifier='F1')) == 1
def test_listing_collections_search(): client = ArchivesSpaceClient(**AUTH) collections = client.find_collections(search_pattern='Test fonds') assert len(collections) == 1 assert collections[0]['title'] == 'Test fonds' no_results = client.find_collections(search_pattern='No such fonds') assert len(no_results) == 0
def test_find_resource_children(): client = ArchivesSpaceClient(**AUTH) data = client.get_resource_component_and_children( '/repositories/2/resources/1') assert type(data) == dict assert len(data['children']) == 2 assert data['title'] == 'Test fonds'
def test_listing_collections_sort(): client = ArchivesSpaceClient(**AUTH) asc = client.find_collections(sort_by='asc') assert len(asc) == 2 assert asc[0]['title'] == 'Some other fonds' desc = client.find_collections(sort_by='desc') assert len(desc) == 2 assert desc[0]['title'] == 'Test fonds'
def test_find_resource_children_recursion_level(): client = ArchivesSpaceClient(**AUTH) data = client.get_resource_component_and_children( '/repositories/2/resources/1', recurse_max_level=1) assert data['children'] is False data = client.get_resource_component_and_children( '/repositories/2/resources/1', recurse_max_level=2) assert len(data['children']) == 2
def test_find_by_id_refid(): client = ArchivesSpaceClient(**AUTH) data = client.find_by_id('archival_objects', 'ref_id', 'a118514fab1b2ee6a7e9ad259e1de355') assert len(data) == 1 item = data[0] assert item['identifier'] == 'a118514fab1b2ee6a7e9ad259e1de355' assert item['id'] == '/repositories/2/archival_objects/752250' assert item['title'] == 'Test AO' assert item['levelOfDescription'] == 'file'
def test_find_component_parent(): client = ArchivesSpaceClient(**AUTH) type, id = client.find_parent_id_for_component( '/repositories/2/archival_objects/3') assert type == ArchivesSpaceClient.RESOURCE_COMPONENT assert id == '/repositories/2/archival_objects/1' type, id = client.find_parent_id_for_component( '/repositories/2/archival_objects/1') assert type == ArchivesSpaceClient.RESOURCE assert id == '/repositories/2/resources/1'
def test_identifier_search_wildcard(): client = ArchivesSpaceClient(**AUTH) # Searching for an identifier prefix with no wildcard returns nothing assert client.find_collection_ids(identifier='F') == [] assert client.count_collections(identifier='F') == 0 assert len(client.find_collections(identifier='F')) == 0 assert client.find_collection_ids(identifier='F*') == [ '/repositories/2/resources/1', '/repositories/2/resources/2' ] assert client.count_collections(identifier='F*') == 2 assert len(client.find_collections(identifier='F*')) == 2
def test_find_resource_id(): client = ArchivesSpaceClient(**AUTH) assert client.find_resource_id_for_component( '/repositories/2/archival_objects/3') == '/repositories/2/resources/1'
def test_find_collection_ids(): client = ArchivesSpaceClient(**AUTH) ids = client.find_collection_ids() assert ids == [ '/repositories/2/resources/1', '/repositories/2/resources/2' ]
def test_listing_collections(): client = ArchivesSpaceClient(**AUTH) collections = client.find_collections() assert len(collections) == 1 assert collections[0]['title'] == 'Test fonds'
def test_get_resource_type(): client = ArchivesSpaceClient(**AUTH) assert client.resource_type('/repositories/2/resources/2') == 'resource' assert client.resource_type( '/repositories/2/archival_objects/3') == 'resource_component'
def test_count_collection_ids_search(): client = ArchivesSpaceClient(**AUTH) ids = client.count_collections(search_pattern='Some') assert ids == 1
def test_count_collection_ids(): client = ArchivesSpaceClient(**AUTH) ids = client.count_collections() assert ids == 2
def test_find_collection_ids_search(): client = ArchivesSpaceClient(**AUTH) ids = client.find_collection_ids(search_pattern='Some') assert ids == ['/repositories/2/resources/2']
def test_get_resource_type_raises_on_invalid_input(): client = ArchivesSpaceClient(**AUTH) with pytest.raises(ArchivesSpaceError): client.resource_type('invalid')
parser.add_argument('--use_statement', help='USE statement') parser.add_argument('--uri_prefix', help='URI prefix') parser.add_argument('--access_conditions', help='Conditions governing access', default='') parser.add_argument('--use_conditions', help='Conditions governing use', default='') parser.add_argument( '--inherit_notes', help='Inherit digital object notes from the parent component', default='no', type=str) parser.add_argument('--version', action='version', version='%(prog)s 0.1.0') args = parser.parse_args() args.inherit_notes = args.inherit_notes.lower() in INHERIT_NOTES_CHOICES client = ArchivesSpaceClient(host=args.host, user=args.user, passwd=args.passwd) files = get_files_from_dip(args.dip_location, args.dip_name, args.dip_uuid) upload_to_archivesspace(files, client, args.xlink_show, args.xlink_actuate, args.object_type, args.use_statement, args.uri_prefix, args.dip_uuid, args.access_conditions, args.use_conditions, args.restrictions, args.dip_location, args.inherit_notes)