Sha256: 1b3ec8de39637df69a7c79a6a24beeba76b538ec1bcfb6aab90c7c1dadbff95c

Contents?: true

Size: 1.86 KB

Versions: 5

Compression:

Stored size: 1.86 KB

Contents

require 'test_helper'
class PatronTest < ActiveSupport::TestCase
  def setup
    @rest_url = "http://aleph.library.nyu.edu:1891/rest-dlf"
    @aleph_doc_library = "NYU01"
    @aleph_doc_number = "000062856"
    @nyuidn = "N12162279"
    @aleph_adm_library = "NYU50"
    @aleph_item_id = "NYU50000062856000010"
    @aleph_renew_item_id = "NYU50000647049"
    @pickup_location = "BOBST"
    @bogus_url = "http://library.nyu.edu/bogus"
  end

  # Test exception handling for bogus response.
  test "test_bogus_response" do
    patron = Exlibris::Aleph::Patron.new(@nyuidn, @bogus_url)
    assert_raise(MultiXml::ParseError) { patron.loans }
    assert_raise(MultiXml::ParseError) { patron.renew_loans() }
    assert_raise(MultiXml::ParseError) { patron.renew_loans(@aleph_renew_item_id) }
    assert_raise(MultiXml::ParseError) { patron.place_hold(@aleph_adm_library, @aleph_doc_library, @aleph_doc_number, @aleph_item_id, {:pickup_location => @pickup_location}) }
  end

  # Test patron
  test "test_patron" do
    patron = Exlibris::Aleph::Patron.new(@nyuidn, @rest_url)
    loans = patron.loans
    assert_nil(patron.error, "Failure in #{patron.class} while getting loans: #{patron.error}")
    #renew_loans = patron.renew_loans()
    #assert_nil(patron.error, "Failure in #{patron.class} while renewing all loans: #{patron.error}")
    #renew_loans = patron.renew_loans(@aleph_renew_item_id)
    #assert_nil(patron.error, "Failure in #{patron.class} while renewing loan #{@aleph_renew_item_id}: #{patron.error}")
    assert_raise(RuntimeError) { patron.place_hold(@aleph_adm_library, @aleph_doc_library, @aleph_doc_number, @aleph_item_id, {}) }
    place_hold = patron.place_hold(@aleph_adm_library, @aleph_doc_library, @aleph_doc_number, @aleph_item_id, {:pickup_location => @pickup_location})
    assert_nil(patron.error, "Failure in #{patron.class} while placing hold: #{patron.error}")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
exlibris-aleph-0.1.2 test/unit/patron_test.rb
exlibris-aleph-0.1.1 test/unit/patron_test.rb
exlibris-aleph-0.1.0 test/unit/patron_test.rb
exlibris-aleph-0.0.2 test/unit/patron_test.rb
exlibris-aleph-0.0.1 test/unit/patron_test.rb