Skip to content

Commit

Permalink
Merge pull request #5470 from avalonmediasystem/complete_proxies
Browse files Browse the repository at this point in the history
Test that all attributes are being stored in solr
  • Loading branch information
cjcolvar authored Nov 27, 2023
2 parents 615e0a3 + a362d1b commit 13e8aaf
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 12 deletions.
4 changes: 4 additions & 0 deletions app/models/concerns/master_file_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def build_caption_hash(caption)
}
end

def supplemental_file_captions
supplemental_files(tag: 'caption')
end

# Supplies the route to the master_file as an rdf formatted URI
# @return [String] the route as a uri
# @example uri for a mf on avalon.iu.edu with a id of: avalon:1820
Expand Down
4 changes: 0 additions & 4 deletions app/models/master_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,6 @@ def self.post_processing_move_filename(oldpath, options = {})
end
end

def supplemental_file_captions
supplemental_files(tag: 'caption')
end

def has_audio?
# The MasterFile doesn't have an audio track unless the first derivative does
# This is useful to skip unnecessary waveform generation
Expand Down
7 changes: 5 additions & 2 deletions config/initializers/presenter_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
file_size: nil,
date_digitized: nil,
file_checksum: nil,
supplemental_file_captions: [],
identifier: []
identifier: [],
percent_complete: nil,
status_code: nil,
operation: nil,
error: nil
}
include MasterFileIntercom
include MasterFileBehavior
Expand Down
23 changes: 23 additions & 0 deletions spec/presenters/speedy_af/proxy/admin/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@
let(:collection) { FactoryBot.create(:collection) }
let(:presenter) { described_class.find(collection.id) }

describe 'attributes' do
let(:collection) { FactoryBot.create(:collection, dropbox_directory_name: "dir", identifier: ["1234"], default_lending_period: 10000, cdl_enabled: true, default_read_users: ['user1'], default_read_groups: ['group1'], default_hidden: true) }

it 'returns all attributes' do
expect(presenter.name).to be_present
expect(presenter.unit).to be_present
expect(presenter.description).to be_present
expect(presenter.contact_email).to be_present
expect(presenter.website_label).to be_present
expect(presenter.website_url).to be_present
expect(presenter.dropbox_directory_name).to be_present
expect(presenter.default_read_groups).to be_present
expect(presenter.default_read_users).to be_present
expect(presenter.default_hidden).not_to be_nil
expect(presenter.identifier).to be_present
expect(presenter.default_lending_period).to be_present
expect(presenter.cdl_enabled).not_to be_nil
expect(presenter.collection_managers).to be_present
expect(presenter.edit_users).to be_present
expect(presenter.read_users).to be_present
end
end

describe 'cdl_enabled' do
context 'collections disabled at the application level' do
before { allow(Settings.controlled_digital_lending).to receive(:collections_enabled).and_return(false) }
Expand Down
34 changes: 28 additions & 6 deletions spec/presenters/speedy_af/proxy/derivative_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,37 @@

describe SpeedyAF::Proxy::Derivative do
let(:derivative) { FactoryBot.create(:derivative) }
before(:each) do
derivative.video_codec = nil
derivative.video_bitrate = nil
derivative.mime_type = nil
derivative.save
end
subject(:presenter) { described_class.find(derivative.id) }

describe 'attributes' do
let(:derivative) { FactoryBot.create(:derivative, mime_type: 'video/mp4') }

it 'returns all attributes' do
expect(presenter.location_url).to be_present #also stored as stream_path_ssi?
expect(presenter.hls_url).to be_present
expect(presenter.duration).to be_present
expect(presenter.track_id).to be_present
expect(presenter.hls_track_id).to be_present
expect(presenter.managed).not_to be_nil
expect(presenter.derivativeFile).to be_present
expect(presenter.quality).to be_present
expect(presenter.mime_type).to be_present
expect(presenter.audio_bitrate).to be_present
expect(presenter.audio_codec).to be_present
expect(presenter.video_bitrate).to be_present
expect(presenter.video_codec).to be_present
expect(presenter.resolution).to be_present
end
end

describe "#defaults" do
before(:each) do
derivative.video_codec = nil
derivative.video_bitrate = nil
derivative.mime_type = nil
derivative.save
end

it "sets video_bitrate to nil" do
expect(subject.inspect).to include("video_bitrate")
expect(subject.video_bitrate).to be_nil
Expand Down
35 changes: 35 additions & 0 deletions spec/presenters/speedy_af/proxy/lease_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2011-2023, The Trustees of Indiana University and Northwestern
# University. Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
# --- END LICENSE_HEADER BLOCK ---

require 'rails_helper'

describe SpeedyAF::Proxy::Lease do
let(:lease) { FactoryBot.create(:lease, lease_type: "user") }
subject(:presenter) { described_class.find(lease.id) }

it "returns all fields" do
expect(subject.begin_time).to be_present
expect(subject.end_time).to be_present
expect(subject.lease_type).to be_present
end

describe "#defaults" do
let(:lease) { FactoryBot.create(:lease) }

it "sets lease_type to nil" do
expect(subject.inspect).to include("lease_type")
expect(subject.lease_type).to be_nil
end
end
end
30 changes: 30 additions & 0 deletions spec/presenters/speedy_af/proxy/master_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,36 @@
let(:master_file) { FactoryBot.create(:master_file) }
subject(:presenter) { described_class.find(master_file.id) }

describe 'attributes' do
let(:master_file) { FactoryBot.create(:master_file, :with_comments, permalink: 'http://permalink', supplemental_files_json: '[]', title: 'Castle', file_checksum: 'abcd1234', file_size: 10, physical_description: 'LP', encoder_classname: 'ActiveEncode::Base', working_file_path: ['path/to/file']) }

it 'returns all attributes' do
expect(presenter.permalink).to be_present
expect(presenter.supplemental_files_json).to be_present
expect(presenter.title).to be_present
expect(presenter.file_location).to be_present
expect(presenter.file_checksum).to be_present
expect(presenter.file_size).to be_present
expect(presenter.duration).to be_present
expect(presenter.display_aspect_ratio).to be_present
expect(presenter.width).to be_present
expect(presenter.height).to be_present
expect(presenter.original_frame_size).to be_present
expect(presenter.file_format).to be_present
expect(presenter.poster_offset).to be_present
expect(presenter.thumbnail_offset).to be_present
expect(presenter.date_digitized).to be_present
expect(presenter.physical_description).to be_present
expect(presenter.masterFile).to be_present
expect(presenter.identifier).to be_present
expect(presenter.comment).to be_present
expect(presenter.workflow_id).to be_present
expect(presenter.encoder_classname).to be_present
expect(presenter.workflow_name).to be_present
expect(presenter.working_file_path).to be_present
end
end

describe "#encoder_class" do
it "should default to WatchedEncode" do
expect(subject.encoder_class).to eq(WatchedEncode)
Expand Down
16 changes: 16 additions & 0 deletions spec/presenters/speedy_af/proxy/media_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,20 @@
expect(presenter.visibility).to eq media_object.visibility
end
end

describe 'attributes' do
let(:media_object) { FactoryBot.create(:fully_searchable_media_object, :with_master_file, permalink: 'http://permalink', supplemental_files_json: '[]', duration: 10, avalon_uploader: 'user1', identifier: ['abc123'], lending_period: 12000) }

it 'returns all attributes' do
expect(presenter.permalink).to be_present
expect(presenter.supplemental_files_json).to be_present
expect(presenter.duration).to be_present
expect(presenter.avalon_resource_type).to be_present
expect(presenter.avalon_publisher).to be_present
expect(presenter.avalon_uploader).to be_present
expect(presenter.identifier).to be_present
expect(presenter.comment).to be_present
expect(presenter.lending_period).to be_present
end
end
end

0 comments on commit 13e8aaf

Please sign in to comment.