def test_posting_contentless_note():
    client = AtomClient(**AUTH)
    slug = client.add_child('test-fonds',
                           title='Yet another subfonds',
                           level='subfonds',
                           notes=[{'type': 'general', 'content': ''}])
    assert client.get_record(slug)['notes'] == []
def test_adding_child_with_note():
    client = AtomClient(**AUTH)
    slug = client.add_child('test-fonds',
                           title='Another subfonds',
                           level='subfonds',
                           notes=[{'type': 'general', 'content': 'This is a test note'}])
    assert slug == 'another-subfonds'
def test_augment_ids():
    client = AtomClient(**AUTH)
    data = client.augment_resource_ids(['top-level-fonds', 'test-fonds'])
    assert len(data) == 2
    assert data[0]['title'] == 'Top Fonds'
    assert data[0]['type'] == 'resource'
    assert data[1]['title'] == 'Test fonds'
    assert data[1]['type'] == 'resource'
def test_find_resource_children():
    client = AtomClient(**AUTH)
    data = client.get_resource_component_and_children('test-fonds')

    assert type(data) == dict
    assert len(data['children']) == 1
    assert data['has_children'] is True
    assert data['title'] == 'Test fonds'
    assert data['type'] == 'resource'
def test_empty_dates():
    client = AtomClient(**AUTH)
    record = client.get_resource_component_children('test-child')
    assert record['dates'] == ''
    assert record['date_expression'] == ''
    record = client.get_resource_component_and_children('test-child',
                                                        recurse_max_level=1)
    # dates are mandatory for resources, so this record does have a date but no expression
    assert record['date_expression'] == ''
    collections = client.find_collections()
    assert collections[0]['date_expression'] == ''
def test_listing_collections_sort():
    client = AtomClient(**AUTH)
    asc = client.find_collections(sort_by='asc')
    assert len(asc) == 2
    assert asc[0]['title'] == 'Test fonds'
    assert asc[0]['type'] == 'resource'

    desc = client.find_collections(sort_by='desc')
    assert len(desc) == 2
    assert desc[0]['title'] == 'Top Fonds'
    assert desc[0]['type'] == 'resource'
def test_levels_of_description():
    client = AtomClient(**AUTH)
    levels = client.get_levels_of_description()
    assert levels == [
        u"Collection",
        u"File",
        u"Fonds",
        u"Item",
        u"Part",
        u"Series",
        u"Subfonds",
        u"Subseries",
    ]
Esempio n. 8
0
def test_edit_archival_object():
    client = AtomClient(**AUTH)
    original = client.get_record('second-subfonds')
    assert original['title'] == 'Second subfonds'
    assert original['dates'][0]['end'] == '2015-01-01'
    assert not original['notes']
    new_record = {
        'slug': 'second-subfonds',
        'title': 'Test edited subfonds',
        'start_date': '2014-11-01',
        'end_date': '2015-11-01',
        'date_expression': 'November, 2014 to November, 2015',
        'notes': [{
            'type': 'general',
            'content': 'This is a test note'
        }],
    }
    client.edit_record(new_record)
    updated = client.get_record('second-subfonds')
    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]['content'] == new_record['notes'][0]['content']
Esempio n. 9
0
def test_delete_record_resource():
    client = AtomClient(**AUTH)
    slug = 'another-subfonds'
    assert client.get_record(slug)
    r = client.delete_record(slug)
    assert r['status'] == 'Deleted'
    with pytest.raises(CommunicationError):
        client.get_record(slug)
def test_delete_record_resource():
    client = AtomClient(**AUTH)
    slug = "another-subfonds"
    assert client.get_record(slug)
    r = client.delete_record(slug)
    assert r["status"] == "Deleted"
    with pytest.raises(CommunicationError):
        client.get_record(slug)
def test_edit_record_empty_note():
    client = AtomClient(**AUTH)
    original = client.get_record("second-subfonds")
    assert original["notes"]
    new_record = {
        "slug": "second-subfonds",
        "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": "general", "content": ""}],
    }
    client.edit_record(new_record)
    updated = client.get_record("second-subfonds")
    assert not updated["notes"]
Esempio n. 12
0
def test_edit_record_empty_note():
    client = AtomClient(**AUTH)
    original = client.get_record('second-subfonds')
    assert original['notes']
    new_record = {
        'slug': 'second-subfonds',
        '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': 'general',
            'content': ''
        }],
    }
    client.edit_record(new_record)
    updated = client.get_record('second-subfonds')
    assert not updated['notes']
def test_edit_archival_object():
    client = AtomClient(**AUTH)
    original = client.get_record("second-subfonds")
    assert original["title"] == "Second subfonds"
    assert original["dates"][0]["end"] == "2015-01-01"
    assert not original["notes"]
    new_record = {
        "slug": "second-subfonds",
        "title": "Test edited subfonds",
        "start_date": "2014-11-01",
        "end_date": "2015-11-01",
        "date_expression": "November, 2014 to November, 2015",
        "notes": [{"type": "general", "content": "This is a test note"}],
    }
    client.edit_record(new_record)
    updated = client.get_record("second-subfonds")
    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]["content"] == new_record["notes"][0]["content"]
def test_find_resource_component_children_at_max_recursion_level():
    client = AtomClient(**AUTH)
    record = client.get_resource_component_and_children('test-subfonds',
                                                        recurse_max_level=1)
    assert record['children'] == []
    assert record['has_children'] is True
def test_levels_of_description():
    client = AtomClient(**AUTH)
    levels = client.get_levels_of_description()
    assert levels == [u'Collection', u'File', u'Fonds', u'Item', u'Part', u'Series', u'Subfonds', u'Subseries'] 
def test_count_collection_ids_search():
    client = AtomClient(**AUTH)
    ids = client.count_collections(search_pattern="Top")
    assert ids == 1
def test_add_child_resource():
    client = AtomClient(**AUTH)
    slug = client.add_child("test-fonds", title="Second subfonds", level="subfonds")
    assert slug == "second-subfonds"
def test_find_resource_children_recursion_level():
    client = AtomClient(**AUTH)
    data = client.get_resource_component_and_children("test-fonds", recurse_max_level=2)
    assert len(data["children"]) == 1
    assert data["has_children"] is True
def test_find_collection_ids_search():
    client = AtomClient(**AUTH)
    ids = client.find_collection_ids(search_pattern="Test fonds")
    assert ids == ["test-fonds"]
def test_count_collection_ids_search():
    client = AtomClient(**AUTH)
    ids = client.count_collections(search_pattern='Top')
    assert ids == 1
def test_find_component_parent_with_non_top_level_parent():
    client = AtomClient(**AUTH)
    resource_id = client.find_parent_id_for_component("test-item")

    assert resource_id == "test-subfonds"
Esempio n. 22
0
def test_add_digital_object():
    client = AtomClient(**AUTH)
    do = client.add_digital_object('test-child',
                                   title='kitty.jpg',
                                   uri='http://www.artefactual.com/wp-content/uploads/2016/04/cat.jpg')
    assert do['slug'] == 'kitty-jpg'
def test_date_expression():
    client = AtomClient(**AUTH)
    record = client.get_resource_component_and_children('second-subfonds',
                                                        recurse_max_level=1)
    assert record['date_expression'] == 'November, 2014 to November, 2015'
Esempio n. 24
0
def test_listing_collections():
    client = AtomClient(**AUTH)
    collections = client.find_collections()
    assert len(collections) == 2
    assert collections[0]['title'] == 'Top Fonds'
    assert collections[0]['type'] == 'resource'
def test_identifier_search_exact_match():
    client = AtomClient(**AUTH)
    assert client.find_collection_ids(identifier='F1') == ['top-level-fonds']
    assert client.count_collections(identifier='F1') == 1
    assert len(client.find_collections(identifier='F1')) == 1
def test_add_child_resource():
    client = AtomClient(**AUTH)
    slug = client.add_child('test-fonds', title='Second subfonds', level='subfonds')
    assert slug == 'second-subfonds'
Esempio n. 27
0
def test_find_component_parent_with_top_level_parent():
    client = AtomClient(**AUTH)
    resource_id = client.find_parent_id_for_component('test-subfonds')

    assert resource_id == 'test-fonds'
def test_count_collection_ids():
    client = AtomClient(**AUTH)
    ids = client.count_collections()
    assert ids == 2
def test_find_component_parent_with_non_top_level_parent():
    client = AtomClient(**AUTH)
    resource_id = client.find_parent_id_for_component('test-item')

    assert resource_id == 'test-subfonds'
def test_date_expression():
    client = AtomClient(**AUTH)
    record = client.get_resource_component_and_children(
        "second-subfonds", recurse_max_level=1
    )
    assert record["date_expression"] == "November, 2014 to November, 2015"
def test_find_collection_ids():
    client = AtomClient(**AUTH)
    ids = client.find_collection_ids()
    assert ids == [u'top-level-fonds', u'test-fonds']
def test_collection_list():
    client = AtomClient(**AUTH)
    collection_ids = client.collection_list("test-fonds")
    assert len(collection_ids) == 2
    assert collection_ids[0] == "test-subfonds"
def test_find_collection_ids():
    client = AtomClient(**AUTH)
    ids = client.find_collection_ids()
    assert ids == [u"top-level-fonds", u"test-fonds"]
def test_find_collections_search():
    client = AtomClient(**AUTH)
    collections = client.find_collections(search_pattern="Test fonds")
    assert len(collections) == 1
    assert collections[0]["title"] == "Test fonds"
    assert collections[0]["type"] == "resource"
def test_count_collection_ids():
    client = AtomClient(**AUTH)
    ids = client.count_collections()
    assert ids == 2
def test_listing_collections_search_spaces():
    client = AtomClient(**AUTH)
    collections = client.find_collections(identifier="2015044 Aa Ac")
    assert len(collections) == 1
    assert collections[0]["title"] == "Resource with spaces in the identifier"
    assert collections[0]["levelOfDescription"] == "Fonds"
def test_identifier_search_exact_match():
    client = AtomClient(**AUTH)
    assert client.find_collection_ids(identifier="F1") == ["top-level-fonds"]
    assert client.count_collections(identifier="F1") == 1
    assert len(client.find_collections(identifier="F1")) == 1
def test_find_resource_children_recursion_level():
    client = AtomClient(**AUTH)
    data = client.get_resource_component_and_children('test-fonds',
                                                      recurse_max_level=2)
    assert len(data['children']) == 1
    assert data['has_children'] is True
def test_add_child_resource_component():
    client = AtomClient(**AUTH)
    slug = client.add_child("second-subfonds", title="Test child", level="item")
    assert slug == "test-child"
def test_find_collection_ids_search():
    client = AtomClient(**AUTH)
    ids = client.find_collection_ids(search_pattern='Test fonds')
    assert ids == ['test-fonds']
 def escape(s, **kwargs):
     return AtomClient._escape_lucene_query(s, **kwargs)
Esempio n. 42
0
def test_add_child_resource_component():
    client = AtomClient(**AUTH)
    slug = client.add_child('second-subfonds', title='Test child', level='item')
    assert slug == 'test-child'
def test_listing_collections():
    client = AtomClient(**AUTH)
    collections = client.find_collections()
    assert len(collections) == 2
    assert collections[0]["title"] == "Top Fonds"
    assert collections[0]["type"] == "resource"
def test_collection_list():
    client = AtomClient(**AUTH)
    collection_ids = client.collection_list('test-fonds')
    assert len(collection_ids) == 2
    assert collection_ids[0] == 'test-subfonds'
 def escape(s, **kwargs):
     return AtomClient._escape_lucene_query(s, **kwargs)
def test_rendering_record_containing_a_note():
    client = AtomClient(**AUTH)
    collections = client.find_collections()
    assert len(collections) == 2
    assert collections[0]['notes'][0]['content'] == 'Note content'
def test_rendering_record_containing_a_note():
    client = AtomClient(**AUTH)
    collections = client.find_collections()
    assert len(collections) == 2
    assert collections[0]["notes"][0]["content"] == "Note content"
Esempio n. 48
0
def test_find_collections_search():
    client = AtomClient(**AUTH)
    collections = client.find_collections(search_pattern='Test fonds')
    assert len(collections) == 1
    assert collections[0]['title'] == 'Test fonds'
    assert collections[0]['type'] == 'resource'
def test_find_collections_search_no_results():
    client = AtomClient(**AUTH)
    no_results = client.find_collections(search_pattern="Nonexistent")
    assert len(no_results) == 0
def test_find_collections_search_no_results():
    client = AtomClient(**AUTH)
    no_results = client.find_collections(search_pattern='Nonexistent')
    assert len(no_results) == 0
Esempio n. 51
0
def get_atom_client():
    settings = DashboardSetting.objects.get_dict('upload-qubit_v0.0')
    return AtomClient(settings.get('url'), settings.get('key'))
def test_listing_collections_search_spaces():
    client = AtomClient(**AUTH)
    collections = client.find_collections(identifier="2015044 Aa Ac")
    assert len(collections) == 1
    assert collections[0]['title'] == 'Resource with spaces in the identifier'
    assert collections[0]['levelOfDescription'] == 'Fonds'