Sha256: 617955762c3a5105bc1f97692356387056193d62e0c63302cd0989a3974c5b74

Contents?: true

Size: 1.96 KB

Versions: 4

Compression:

Stored size: 1.96 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
    VCR.turned_off 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
  end

  # Test patron
  test "test_patron" do
    VCR.use_cassette('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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
exlibris-aleph-0.1.6 test/unit/patron_test.rb
exlibris-aleph-0.1.5 test/unit/patron_test.rb
exlibris-aleph-0.1.4 test/unit/patron_test.rb
exlibris-aleph-0.1.3 test/unit/patron_test.rb