Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper method to stub single holding locations #3542

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions spec/features/login_account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@
stub_delivery_locations
stub_request(:get, "#{Requests::Config[:pulsearch_base]}/catalog/SCSB-2143785/raw")
.to_return(status: 200, body: fixture('/scsb/SCSB-2143785.json'), headers: {})
stub_request(:get, "#{Requests::Config[:bibdata_base]}/locations/holding_locations/scsbcul.json")
.to_return(status: 200, body: fixture('/bibdata/scsbcul_holding_locations.json'))
stub_single_holding_location('scsbcul')
stub_request(:get, "#{Requests::Config[:bibdata_base]}/bibliographic/SCSB-2143785/holdings/2110046/availability.json")
.to_return(status: 200)
end
Expand Down Expand Up @@ -153,8 +152,7 @@
before do
stub_request(:get, "#{Requests::Config[:pulsearch_base]}/catalog/coin-1167/raw")
.to_return(status: 200, body: fixture('/numismatics/coin-1167.json'), headers: {})
stub_request(:get, "#{Requests::Config[:bibdata_base]}/locations/holding_locations/rare$num.json")
.to_return(status: 200, body: fixture('/bibdata/numismatics_holding_locations.json'))
stub_single_holding_location('rare$num')
end

it 'does not require authentication', js: true do
Expand All @@ -168,8 +166,7 @@
before do
stub_request(:get, "#{Requests::Config[:pulsearch_base]}/catalog/dsp01tq57ns24j/raw")
.to_return(status: 200, body: fixture('/theses_and_dissertations/dsp01tq57ns24j.json'), headers: {})
stub_request(:get, "#{Requests::Config[:bibdata_base]}/locations/holding_locations/mudd$stacks.json")
.to_return(status: 200, body: fixture('/bibdata/mudd_stacks_holding_locations.json'))
stub_single_holding_location('mudd$stacks')
end
it 'does not require authentication', js: true do
visit "/catalog/dsp01tq57ns24j"
Expand All @@ -185,8 +182,7 @@
before do
stub_request(:get, "#{Requests::Config[:pulsearch_base]}/catalog/99496133506421/raw")
.to_return(status: 200, body: fixture('/alma/99496133506421.json'), headers: {})
stub_request(:get, "#{Requests::Config[:bibdata_base]}/locations/holding_locations/rare$map.json")
.to_return(status: 200, body: fixture('/bibdata/rare_map_holding_locations.json'))
stub_single_holding_location('rare$map')
stub_request(:get, "#{Requests::Config[:bibdata_base]}/bibliographic/99496133506421/holdings/22745123330006421/availability.json")
.to_return(status: 200, body: availability)
end
Expand Down
12 changes: 3 additions & 9 deletions spec/features/requests/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1727,14 +1727,10 @@
patron:
}
end
let(:stacks_holding_location_info) { File.open('spec/fixtures/bibdata/engineer_stacks_holding_locations.json') }
let(:res_holding_location_info) { File.open('spec/fixtures/bibdata/engineer_res_holding_locations.json') }

before do
stub_request(:get, 'https://bibdata-staging.princeton.edu/locations/holding_locations/engineer$stacks.json')
.to_return(status: 200, body: stacks_holding_location_info)
stub_request(:get, 'https://bibdata-staging.princeton.edu/locations/holding_locations/engineer$res.json')
.to_return(status: 200, body: res_holding_location_info)
stub_single_holding_location('engineer$stacks')
stub_single_holding_location('engineer$res')
stub_request(:get, bibdata_availability_url)
.to_return(status: 200, body: bibdata_availability_response)
stub_request(:get, 'https://catalog.princeton.edu/catalog/9960102253506421/raw')
Expand Down Expand Up @@ -1766,7 +1762,6 @@
patron:
}
end
let(:holding_location_info) { File.open('spec/fixtures/bibdata/recap_pa_holding_locations.json') }
let(:first_item) { request_scsb.items['22511126440006421'].first }

before do
Expand All @@ -1775,8 +1770,7 @@
.to_return(status: 200, body: bibdata_availability_response)
stub_request(:get, 'https://catalog.princeton.edu/catalog/99122304923506421/raw')
.to_return(status: 200, body: File.read('spec/fixtures/raw_99122304923506421.json'))
stub_request(:get, 'https://bibdata-staging.princeton.edu/locations/holding_locations/recap$pa.json')
.to_return(status: 200, body: holding_location_info)
stub_single_holding_location('recap$pa')
stub_request(:get, "#{Requests::Config[:bibdata_base]}/patron/#{user.uid}?ldap=true")
.to_return(status: 200, body: valid_patron_response, headers: {})
login_as user
Expand Down
19 changes: 19 additions & 0 deletions spec/fixtures/holding_locations/RES_SHARE_OUT_RS_REQ.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"label": "Borrowing Resource Sharing Requests",
"code": "RES_SHARE$OUT_RS_REQ",
"aeon_location": false,
"recap_electronic_delivery_location": false,
"open": true,
"requestable": true,
"always_requestable": false,
"circulates": true,
"remote_storage": "",
"fulfillment_unit": "RES_FU",
"library": {
"label": "Resource Sharing Library",
"code": "RES_SHARE",
"order": 0
},
"holding_library": null,
"delivery_locations": []
}
4 changes: 1 addition & 3 deletions spec/models/concerns/requests/scsb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,15 @@
patron:
}
end
let(:holding_location_info) { File.open('spec/fixtures/bibdata/recap_pa_holding_locations.json') }
let(:first_item) { request_scsb.items['22511126440006421'].first }

before do
stub_single_holding_location('recap$pa')
stub_scsb_availability(bib_id: "99122304923506421", institution_id: "PUL", barcode: nil, item_availability_status: nil, error_message: "Bib Id doesn't exist in SCSB database.")
stub_request(:get, bibdata_availability_url)
.to_return(status: 200, body: bibdata_availability_response)
stub_request(:get, 'https://catalog.princeton.edu/catalog/99122304923506421/raw')
.to_return(status: 200, body: File.read('spec/fixtures/raw_99122304923506421.json'))
stub_request(:get, 'https://bibdata-staging.princeton.edu/locations/holding_locations/recap$pa.json')
.to_return(status: 200, body: holding_location_info)
end

it 'is in process' do
Expand Down
10 changes: 3 additions & 7 deletions spec/models/requests/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@
let(:user) { FactoryBot.create(:user) }
let(:bibdata_availability_url) { 'https://bibdata-staging.princeton.edu/bibliographic/9960102253506421/holdings/22548491940006421/availability.json' }
let(:bibdata_availability_response) { File.open('spec/fixtures/bibdata/9960102253506421_availability.json') }
let(:stacks_holding_location_info) { File.open('spec/fixtures/bibdata/engineer_stacks_holding_locations.json') }
let(:res_holding_location_info) { File.open('spec/fixtures/bibdata/engineer_res_holding_locations.json') }

before do
stub_request(:get, 'https://bibdata-staging.princeton.edu/locations/holding_locations/engineer$stacks.json')
.to_return(status: 200, body: stacks_holding_location_info)
stub_request(:get, 'https://bibdata-staging.princeton.edu/locations/holding_locations/engineer$res.json')
.to_return(status: 200, body: res_holding_location_info)
stub_single_holding_location('engineer$stacks')
stub_single_holding_location('engineer$res')
stub_request(:get, bibdata_availability_url)
.to_return(status: 200, body: bibdata_availability_response)
stub_request(:get, 'https://catalog.princeton.edu/catalog/9960102253506421/raw')
Expand Down Expand Up @@ -554,7 +550,7 @@
expect(request_with_only_system_id.requestable[0].aeon_mapped_params[:Form]).to eq('21')
end

it 'shouuld have an Aeon Action Param' do
it 'should have an Aeon Action Param' do
expect(request_with_only_system_id.requestable[0].aeon_mapped_params.key?(:Action)).to be true
expect(request_with_only_system_id.requestable[0].aeon_mapped_params[:Action]).to eq('10')
end
Expand Down
4 changes: 1 addition & 3 deletions spec/models/requests/requestable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1185,9 +1185,7 @@
'"status":"Unavailable","status_label":"Resource Sharing Request","status_source":"process_type","process_type":"ILL","on_reserve":"N","item_type":"Gen","pickup_location_id":"RES_SHARE",'\
'"pickup_location_code":"RES_SHARE","location":"RES_SHARE$OUT_RS_REQ","label":"ReCAP","description":"","enum_display":"","chron_display":"","in_temp_library":true,"temp_library_code":"RES_SHARE",'\
'"temp_library_label":"Resource Sharing Library","temp_location_code":"RES_SHARE$OUT_RS_REQ","temp_location_label":"Resource Sharing Library"}]')
stub_request(:get, "#{Requests::Config[:bibdata_base]}/locations/holding_locations/RES_SHARE$OUT_RS_REQ.json")
.to_return(status: 200, body: '{"label":"Borrowing Resource Sharing Requests","code":"RES_SHARE$OUT_RS_REQ","aeon_location":false,"recap_electronic_delivery_location":false,"open":true,"requestable":true,"always_requestable":false,"circulates":true,'\
'"remote_storage":"","library":{"label":"Resource Sharing Library","code":"RES_SHARE","order":0},"holding_library":null,"hours_location":null,"delivery_locations":[]}')
stub_single_holding_location('RES_SHARE$OUT_RS_REQ')
stub_request(:post, "#{Requests::Config[:scsb_base]}/sharedCollection/bibAvailabilityStatus")
.to_return(status: 200, body: "[{\"itemBarcode\":\"MR72802120\",\"itemAvailabilityStatus\":\"Available\",\"errorMessage\":null,\"collectionGroupDesignation\":\"Shared\"}]")
end
Expand Down
6 changes: 6 additions & 0 deletions spec/support/webmock_stubs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ def stub_alma_holding_locations
body: File.read(File.join(fixture_path, 'bibdata', 'alma', 'holding_locations.json')))
end

def stub_single_holding_location(location_code)
file_path = File.join(fixture_path, 'holding_locations', "#{location_code.tr('$', '_')}.json")
stub_request(:get, "#{Requests.config['bibdata_base']}/locations/holding_locations/#{location_code}.json")
.to_return(status: 200, body: File.read(file_path))
end

def stub_test_document
stub_request(:get, "#{Requests.config['bibdata_base']}/bibliographic/test-id")
.to_return(status: 200, body: '')
Expand Down