Beispiel #1
0
def test_delete_organisation(reindex, db, minimal_organisation_record,
                             minimal_member_record):
    """Test Organisation delete."""
    org = OrganisationWithMembers.create(minimal_organisation_record,
                                         dbcommit=True)
    member1 = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    pid1 = PersistentIdentifier.get_by_object('memb', 'rec', member1.id)
    member2 = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    pid2 = PersistentIdentifier.get_by_object('memb', 'rec', member2.id)
    member3 = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    pid3 = PersistentIdentifier.get_by_object('memb', 'rec', member3.id)
    org.add_member(member1, dbcommit=True)
    org.add_member(member2, dbcommit=True)
    org.add_member(member3, dbcommit=True)
    assert OrganisationsMembersMetadata.query.count() == 3
    assert RecordMetadata.query.count() == 4
    assert pid1.is_registered()
    assert pid2.is_registered()
    assert pid3.is_registered()
    org.delete(force=True)
    assert OrganisationsMembersMetadata.query.count() == 0
    assert RecordMetadata.query.count() == 0
    assert pid1.is_deleted()
    assert pid2.is_deleted()
    assert pid3.is_deleted()
Beispiel #2
0
def test_delete_member(reindex, db, minimal_member_record,
                       minimal_location_record):
    """Test Member delete."""
    memb = MemberWithLocations.create(minimal_member_record)
    location1 = Location.create(minimal_location_record)
    memb.add_location(location1)
    pid1 = PersistentIdentifier.get_by_object('loc', 'rec', location1.id)
    location2 = Location.create(minimal_location_record)
    memb.add_location(location2)
    pid2 = PersistentIdentifier.get_by_object('loc', 'rec', location2.id)
    location3 = Location.create(minimal_location_record)
    memb.add_location(location3)
    pid3 = PersistentIdentifier.get_by_object('loc', 'rec', location3.id)
    memb.dbcommit()
    assert MembersLocationsMetadata.query.count() == 3
    assert RecordMetadata.query.count() == 4
    assert pid1.is_registered()
    assert pid2.is_registered()
    assert pid3.is_registered()
    memb.delete(force=True)
    assert MembersLocationsMetadata.query.count() == 0
    assert RecordMetadata.query.count() == 0
    assert pid1.is_deleted()
    assert pid2.is_deleted()
    assert pid3.is_deleted()
Beispiel #3
0
def create_minimal_resources_on_loan(db, minimal_member_record,
                                     minimal_location_record,
                                     item_record_on_loan, minimal_book_record):
    """Simple patron record."""
    member = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    location = Location.create(minimal_location_record, dbcommit=True)
    member.add_location(location)
    doc = DocumentsWithItems.create(minimal_book_record, dbcommit=True)
    item = Item.create({})
    item.update(item_record_on_loan, dbcommit=True)
    doc.add_item(item, dbcommit=True)
    db.session.commit()
    yield doc, item, member, location
Beispiel #4
0
def test_members_locations_create(db, minimal_member_record,
                                  minimal_location_record):
    """Test organisation with members creation."""
    memb = MemberWithLocations.create(minimal_member_record)
    loc = Record.create(minimal_location_record)
    assert memb.locations == []

    memb.add_location(loc)
    memb.dbcommit()
    assert memb.locations[0] == loc

    dump = memb.dumps()
    assert dump['locations'][0] == loc.dumps()
Beispiel #5
0
def test_organisation_members_create(db, minimal_organisation_record,
                                     minimal_member_record):
    """Test organisation with members creation."""
    org = OrganisationWithMembers.create(minimal_organisation_record,
                                         dbcommit=True)
    memb = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    assert org.members == []

    org.add_member(memb, dbcommit=True)
    assert org.members[0] == memb

    dump = org.dumps()
    assert dump['members'][0] == memb.dumps()
Beispiel #6
0
def test_delete_member(reindex, db, minimal_organisation_record,
                       minimal_member_record):
    """Test OrganisationsMembers delete."""
    org = OrganisationWithMembers.create(minimal_organisation_record,
                                         dbcommit=True)
    member = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    org.add_member(member, dbcommit=True)
    pid = PersistentIdentifier.get_by_object('memb', 'rec', member.id)
    assert pid.is_registered()
    org.remove_member(member)
    assert pid.is_deleted()
    assert org.members == []

    member1 = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    org.add_member(member1, dbcommit=True)
    member2 = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    org.add_member(member2, dbcommit=True)
    member3 = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    org.add_member(member3, dbcommit=True)
    org.remove_member(member2)
    assert len(org.members) == 2
    assert org.members[0]['pid'] == '2'
    assert org.members[1]['pid'] == '4'
def test_create(db, minimal_document_record, minimal_item_record,
                minimal_member_record, minimal_location_record):
    """Test DocumentWithItems creation."""
    memb = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    loc = Location.create(minimal_location_record, dbcommit=True)
    memb.add_location(loc, dbcommit=True)
    minimal_item_record['location_pid'] = loc.pid
    item = Item.create(minimal_item_record, dbcommit=True)
    doc = DocumentsWithItems.create(minimal_document_record, dbcommit=True)
    assert doc.itemslist == []

    doc.add_item(item, dbcommit=True)
    assert doc.itemslist[0] == item

    dump = doc.dumps()
    assert dump['itemslist'][0] == item.dumps()
Beispiel #8
0
def test_member_name(db, minimal_member_record, minimal_item_record,
                     minimal_location_record):
    """Test member names."""
    member = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    assert member
    location = Location.create(minimal_location_record, dbcommit=True)
    assert location
    member.add_location(location, dbcommit=True)
    assert member.locations
    item = Item.create({})
    item.update(minimal_item_record, dbcommit=True)
    assert item
    data = item.dumps()
    assert data.get('member_pid') == '1'
    assert data.get('member_name') == 'MV Sion'
    holding = data.get('_circulation').get('holdings')[1]
    assert holding['pickup_member_name'] == 'MV Sion'
Beispiel #9
0
def test_delete_location(reindex, db, minimal_member_record,
                         minimal_location_record):
    """Test MembersLocations delete."""
    memb = MemberWithLocations.create(minimal_member_record, dbcommit=True)
    location = Location.create(minimal_location_record, dbcommit=True)
    memb.add_location(location, dbcommit=True)
    pid = PersistentIdentifier.get_by_object('loc', 'rec', location.id)
    assert pid.is_registered()
    memb.remove_location(location)
    assert pid.is_deleted()
    assert memb.locations == []

    location1 = Location.create(minimal_location_record, dbcommit=True)
    memb.add_location(location1, dbcommit=True)
    location2 = Location.create(minimal_location_record, dbcommit=True)
    memb.add_location(location2, dbcommit=True)
    location3 = Location.create(minimal_location_record, dbcommit=True)
    memb.add_location(location3, dbcommit=True)
    memb.remove_location(location2)
    assert len(memb.locations) == 2
    assert memb.locations[0]['pid'] == '2'
    assert memb.locations[1]['pid'] == '4'