def test_edit_archival_object():
    client = ArchivesSpaceClient(**AUTH)
    original = client.get_record('/repositories/2/archival_objects/3')
    assert original['title'] == 'Test subseries'
    assert original['dates'][0]['end'] == '2015-01-01'
    assert not original['notes']
    new_record = {
        'id': '/repositories/2/archival_objects/3',
        'title': 'Test edited subseries',
        'start_date': '2014-11-01',
        'end_date': '2015-11-01',
        'date_expression': 'November, 2014 to November, 2015',
        'notes': [{
            'type': 'odd',
            'content': 'This is a test note'
        }],
    }
    client.edit_record(new_record)
    updated = client.get_record('/repositories/2/archival_objects/3')
    assert updated['title'] == new_record['title']
    assert updated['dates'][0]['begin'] == new_record['start_date']
    assert updated['dates'][0]['end'] == new_record['end_date']
    assert updated['dates'][0]['expression'] == new_record['date_expression']
    assert updated['notes'][0]['type'] == new_record['notes'][0]['type']
    assert updated['notes'][0]['subnotes'][0]['content'] == new_record['notes'][0]['content']
コード例 #2
0
def test_edit_archival_object():
    client = ArchivesSpaceClient(**AUTH)
    original = client.get_record('/repositories/2/archival_objects/3')
    assert original['title'] == 'Test subseries'
    assert original['dates'][0]['end'] == '2015-01-01'
    assert not original['notes']
    new_record = {
        'id': '/repositories/2/archival_objects/3',
        'title': 'Test edited subseries',
        'start_date': '2014-11-01',
        'end_date': '2015-11-01',
        'date_expression': 'November, 2014 to November, 2015',
        'notes': [{
            'type': 'odd',
            'content': 'This is a test note'
        }],
    }
    client.edit_record(new_record)
    updated = client.get_record('/repositories/2/archival_objects/3')
    assert updated['title'] == new_record['title']
    assert updated['dates'][0]['begin'] == new_record['start_date']
    assert updated['dates'][0]['end'] == new_record['end_date']
    assert updated['dates'][0]['expression'] == new_record['date_expression']
    assert updated['notes'][0]['type'] == new_record['notes'][0]['type']
    assert updated['notes'][0]['subnotes'][0]['content'] == new_record['notes'][0]['content']
def test_delete_record_archival_object():
    client = ArchivesSpaceClient(**AUTH)
    record_id = '/repositories/2/archival_objects/4'
    assert client.get_record(record_id)
    r = client.delete_record(record_id)
    assert r['status'] == 'Deleted'
    with pytest.raises(CommunicationError):
        client.get_record(record_id)
コード例 #4
0
def test_delete_record_archival_object():
    client = ArchivesSpaceClient(**AUTH)
    record_id = '/repositories/2/archival_objects/4'
    assert client.get_record(record_id)
    r = client.delete_record(record_id)
    assert r['status'] == 'Deleted'
    with pytest.raises(CommunicationError):
        client.get_record(record_id)
コード例 #5
0
def test_adding_a_digital_object_to_a_record_with_a_singlepart_note():
    client = ArchivesSpaceClient(**AUTH)
    do = client.add_digital_object('/repositories/2/archival_objects/21',
                                   identifier='5f464db2-9365-492f-b7c7-7958baeb0388',
                                   title='Test digital object whose parent has a singlepart note')
    note = client.get_record(do['id'])['notes'][0]
    assert len(note['content']) == 1
コード例 #6
0
def test_posting_contentless_note():
    client = ArchivesSpaceClient(**AUTH)
    uri = client.add_child('/repositories/2/resources/1',
                           title='Test child',
                           level='recordgrp',
                           notes=[{'type': 'odd', 'content': ''}])
    assert client.get_record(uri)['notes'] == []
コード例 #7
0
def test_posting_contentless_note():
    client = ArchivesSpaceClient(**AUTH)
    uri = client.add_child('/repositories/2/resources/1',
                           title='Test child',
                           level='recordgrp',
                           notes=[{'type': 'odd', 'content': ''}])
    assert client.get_record(uri)['notes'] == []
コード例 #8
0
def test_adding_a_digital_object_to_a_record_with_a_singlepart_note():
    client = ArchivesSpaceClient(**AUTH)
    do = client.add_digital_object('/repositories/2/archival_objects/21',
                                   identifier='5f464db2-9365-492f-b7c7-7958baeb0388',
                                   title='Test digital object whose parent has a singlepart note')
    note = client.get_record(do['id'])['notes'][0]
    assert len(note['content']) == 1
コード例 #9
0
def test_add_nested_digital_object_component():
    client = ArchivesSpaceClient(**AUTH)
    parent = '/repositories/2/digital_object_components/3'
    doc = client.add_digital_object_component('/repositories/2/digital_objects/1',
                                              parent_digital_object_component=parent,
                                              label='Child DOC',
                                              title='This is a child DOC')
    assert client.get_record(doc['id'])['parent']['ref'] == parent
def test_add_nested_digital_object_component():
    client = ArchivesSpaceClient(**AUTH)
    parent = '/repositories/2/digital_object_components/3'
    doc = client.add_digital_object_component('/repositories/2/digital_objects/1',
                                              parent_digital_object_component=parent,
                                              label='Child DOC',
                                              title='This is a child DOC')
    assert client.get_record(doc['id'])['parent']['ref'] == parent
コード例 #11
0
def test_digital_object_with_location_of_originals_note():
    client = ArchivesSpaceClient(**AUTH)
    do = client.add_digital_object('/repositories/2/archival_objects/3',
                                   identifier='925bfc8a-d6f8-4479-9b6a-d811a4e7f6bf',
                                   title='Test digital object with note',
                                   location_of_originals='The ether')
    note = client.get_record(do['id'])['notes'][0]
    assert note['content'][0] == 'The ether'
    assert note['type'] == 'originalsloc'
コード例 #12
0
def test_edit_record_empty_note():
    client = ArchivesSpaceClient(**AUTH)
    original = client.get_record('/repositories/2/archival_objects/3')
    assert original['notes']
    new_record = {
        'id': '/repositories/2/archival_objects/3',
        'title': 'Test edited subseries w/ empty note',
        'start_date': '2014-11-01',
        'end_date': '2015-11-01',
        'date_expression': 'November, 2014 to November, 2015',
        'notes': [{
            'type': 'odd',
            'content': ''
        }],
    }
    client.edit_record(new_record)
    updated = client.get_record('/repositories/2/archival_objects/3')
    assert not updated['notes']
コード例 #13
0
def test_edit_record_empty_note():
    client = ArchivesSpaceClient(**AUTH)
    original = client.get_record('/repositories/2/archival_objects/3')
    assert original['notes']
    new_record = {
        'id': '/repositories/2/archival_objects/3',
        'title': 'Test edited subseries w/ empty note',
        'start_date': '2014-11-01',
        'end_date': '2015-11-01',
        'date_expression': 'November, 2014 to November, 2015',
        'notes': [{
            'type': 'odd',
            'content': ''
        }],
    }
    client.edit_record(new_record)
    updated = client.get_record('/repositories/2/archival_objects/3')
    assert not updated['notes']
def test_digital_object_with_location_of_originals_note():
    client = ArchivesSpaceClient(**AUTH)
    do = client.add_digital_object('/repositories/2/archival_objects/3',
                                   identifier='925bfc8a-d6f8-4479-9b6a-d811a4e7f6bf',
                                   title='Test digital object with note',
                                   location_of_originals='The ether')
    note = client.get_record(do['id'])['notes'][0]
    assert note['content'][0] == 'The ether'
    assert note['type'] == 'originalsloc'
コード例 #15
0
def test_posting_multiple_notes():
    client = ArchivesSpaceClient(**AUTH)
    uri = client.add_child('/repositories/2/resources/1',
                           title='Test child',
                           level='recordgrp',
                           notes=[{'type': 'odd', 'content': 'General'}, {'type': 'accessrestrict', 'content': 'Access'}])
    record = client.get_record(uri)
    assert record['notes'][0]['type'] == 'odd'
    assert record['notes'][0]['subnotes'][0]['content'] == 'General'
    assert record['notes'][1]['type'] == 'accessrestrict'
    assert record['notes'][1]['subnotes'][0]['content'] == 'Access'
コード例 #16
0
def test_posting_multiple_notes():
    client = ArchivesSpaceClient(**AUTH)
    uri = client.add_child('/repositories/2/resources/1',
                           title='Test child',
                           level='recordgrp',
                           notes=[{'type': 'odd', 'content': 'General'}, {'type': 'accessrestrict', 'content': 'Access'}])
    record = client.get_record(uri)
    assert record['notes'][0]['type'] == 'odd'
    assert record['notes'][0]['subnotes'][0]['content'] == 'General'
    assert record['notes'][1]['type'] == 'accessrestrict'
    assert record['notes'][1]['subnotes'][0]['content'] == 'Access'
コード例 #17
0
def test_edit_record_multiple_notes():
    client = ArchivesSpaceClient(**AUTH)
    new_record = {
        'id': '/repositories/2/archival_objects/9253',
        'notes': [
            {
                'type': 'odd',
                'content': 'General note content'
            },
            {
                'type': 'accessrestrict',
                'content': 'Access restriction note',
            }
        ],
    }
    client.edit_record(new_record)
    updated = client.get_record('/repositories/2/archival_objects/9253')
    assert updated['notes'][0]['type'] == new_record['notes'][0]['type']
    assert updated['notes'][0]['subnotes'][0]['content'] == new_record['notes'][0]['content']

    assert updated['notes'][1]['type'] == new_record['notes'][1]['type']
    assert updated['notes'][1]['subnotes'][0]['content'] == new_record['notes'][1]['content']