fedora-migrate 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +128 -0
- data/.rubocop_todo.yml +9 -0
- data/.travis.yml +3 -2
- data/Gemfile +2 -0
- data/fedora-migrate.gemspec +1 -0
- data/lib/fedora-migrate.rb +3 -5
- data/lib/fedora_migrate/content_mover.rb +7 -11
- data/lib/fedora_migrate/datastream_mover.rb +21 -24
- data/lib/fedora_migrate/datastream_verification.rb +15 -17
- data/lib/fedora_migrate/dates_mover.rb +0 -2
- data/lib/fedora_migrate/file_configurator.rb +3 -5
- data/lib/fedora_migrate/hooks.rb +0 -2
- data/lib/fedora_migrate/logger.rb +8 -11
- data/lib/fedora_migrate/migration_options.rb +6 -7
- data/lib/fedora_migrate/migration_report.rb +18 -22
- data/lib/fedora_migrate/mover.rb +4 -6
- data/lib/fedora_migrate/object_mover.rb +28 -34
- data/lib/fedora_migrate/permissions.rb +8 -10
- data/lib/fedora_migrate/permissions_mover.rb +7 -11
- data/lib/fedora_migrate/rdf_datastream_mover.rb +1 -2
- data/lib/fedora_migrate/rels_ext_datastream_mover.rb +29 -31
- data/lib/fedora_migrate/repository_migrator.rb +40 -43
- data/lib/fedora_migrate/rights_metadata.rb +109 -114
- data/lib/fedora_migrate/rubydora_connection.rb +4 -5
- data/lib/fedora_migrate/target_constructor.rb +19 -22
- data/lib/fedora_migrate/version.rb +1 -1
- data/spec/integration/content_versions_spec.rb +12 -14
- data/spec/integration/custom_target_spec.rb +44 -0
- data/spec/integration/fedora3_interface_spec.rb +7 -11
- data/spec/integration/missing_relationships_spec.rb +8 -10
- data/spec/integration/object_migration_spec.rb +20 -31
- data/spec/integration/permission_migration_spec.rb +4 -6
- data/spec/integration/rdf_migration_spec.rb +3 -6
- data/spec/integration/relationship_migration_spec.rb +6 -7
- data/spec/integration/repository_migration_spec.rb +14 -19
- data/spec/integration/versions_spec.rb +6 -8
- data/spec/spec_helper.rb +3 -3
- data/spec/support/example_model.rb +23 -25
- data/spec/unit/content_mover_spec.rb +21 -23
- data/spec/unit/datastream_mover_spec.rb +10 -14
- data/spec/unit/datastream_verification_spec.rb +7 -9
- data/spec/unit/dates_mover_spec.rb +3 -4
- data/spec/unit/fedora_migrate_spec.rb +2 -6
- data/spec/unit/file_configurator_spec.rb +4 -8
- data/spec/unit/migration_options_spec.rb +1 -3
- data/spec/unit/migration_report_spec.rb +5 -6
- data/spec/unit/mover_spec.rb +10 -12
- data/spec/unit/object_mover_spec.rb +9 -16
- data/spec/unit/permissions_mover_spec.rb +8 -11
- data/spec/unit/rels_ext_datastream_mover_spec.rb +4 -6
- data/spec/unit/repository_migrator_spec.rb +12 -14
- data/spec/unit/rubydora_connection_spec.rb +3 -5
- data/spec/unit/target_constructor_spec.rb +10 -16
- data/tasks/dev.rake +9 -1
- metadata +21 -3
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
3
|
+
describe FedoraMigrate::ObjectMover do
|
5
4
|
let(:source) { FedoraMigrate.source.connection.find("sufia:rb68xc089") }
|
6
|
-
let(:mover) {
|
5
|
+
let(:mover) { described_class.new source, ExampleModel::MigrationObject.new }
|
7
6
|
|
8
7
|
subject do
|
9
8
|
mover.migrate
|
@@ -11,23 +10,22 @@ describe "Versions" do
|
|
11
10
|
end
|
12
11
|
|
13
12
|
# Query the metadata node for a given version and return its hasDateCreatedByApplication expressed as an integer
|
14
|
-
def date_created_by_application
|
13
|
+
def date_created_by_application(version)
|
15
14
|
uri = subject.content.versions.with_label(version).uri
|
16
|
-
response = ActiveFedora.fedora.connection.get(uri+"/fcr:metadata")
|
15
|
+
response = ActiveFedora.fedora.connection.get(uri + "/fcr:metadata")
|
17
16
|
graph = ::RDF::Graph.new << ::RDF::Reader.for(:ttl).new(response.body)
|
18
17
|
value = graph.query(predicate: RDF::URI("http://www.loc.gov/premis/rdf/v1#hasDateCreatedByApplication")).first.object.to_s
|
19
18
|
DateTime.iso8601(value).to_i
|
20
19
|
end
|
21
20
|
|
22
21
|
def desc_metadata_source_versions
|
23
|
-
source.datastreams["descMetadata"].versions.sort { |a,b| a.createDate <=> b.createDate }
|
22
|
+
source.datastreams["descMetadata"].versions.sort { |a, b| a.createDate <=> b.createDate }
|
24
23
|
end
|
25
24
|
|
26
|
-
it "
|
25
|
+
it "is migrated in the order they were created with their original creation dates" do
|
27
26
|
pending "Requires fix to Fedora 4.4; awaiting release"
|
28
27
|
expect(desc_metadata_source_versions[0].createDate.to_i).to eql date_created_by_application("version1")
|
29
28
|
expect(desc_metadata_source_versions[1].createDate.to_i).to eql date_created_by_application("version2")
|
30
29
|
expect(desc_metadata_source_versions[2].createDate.to_i).to eql date_created_by_application("version3")
|
31
30
|
end
|
32
|
-
|
33
31
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,6 +5,7 @@ require 'fedora-migrate'
|
|
5
5
|
require 'equivalent-xml/rspec_matchers'
|
6
6
|
require 'support/example_model'
|
7
7
|
require 'active_fedora/cleaner'
|
8
|
+
require 'rspec/its'
|
8
9
|
|
9
10
|
require 'http_logger'
|
10
11
|
ActiveFedora::Base.logger = Logger.new(STDERR)
|
@@ -32,16 +33,15 @@ RSpec.configure do |config|
|
|
32
33
|
# Have a clean slate for every test
|
33
34
|
config.before(:each) do
|
34
35
|
ActiveFedora::Cleaner.clean!
|
35
|
-
ActiveFedora::SolrService.instance.conn.delete_by_query('*:*', params: {'softCommit' => true})
|
36
|
+
ActiveFedora::SolrService.instance.conn.delete_by_query('*:*', params: { 'softCommit' => true })
|
36
37
|
FileUtils.rm_rf(FedoraMigrate::MigrationReport::DEFAULT_PATH)
|
37
38
|
end
|
38
39
|
|
39
40
|
config.order = :random
|
40
41
|
|
41
42
|
config.include ExampleModel
|
42
|
-
|
43
43
|
end
|
44
44
|
|
45
|
-
def load_fixture
|
45
|
+
def load_fixture(file)
|
46
46
|
File.open("spec/fixtures/datastreams/#{file}")
|
47
47
|
end
|
@@ -1,43 +1,42 @@
|
|
1
|
-
# Shenanigans because we're not in a Rails environment and we need to load bits of
|
1
|
+
# Shenanigans because we're not in a Rails environment and we need to load bits of
|
2
2
|
# code that depend on Rails in order to test migrating objects.
|
3
3
|
Hydra::Engine.config.autoload_paths.each { |path| $LOAD_PATH.unshift path }
|
4
4
|
# in gem version 2.4, .find_by_name isn't pulling up gems given in the Gemfile
|
5
5
|
# as opposed to those in the gemspec file.
|
6
6
|
# This is a workaround:
|
7
7
|
Gem::Specification.all.each do |g|
|
8
|
-
HAC_DIR = g.gem_dir if g.name
|
9
|
-
HCL_DIR = g.gem_dir if g.name
|
10
|
-
HCR_DIR = g.gem_dir if g.name
|
11
|
-
BKL_DIR = g.gem_dir if g.name
|
8
|
+
HAC_DIR = g.gem_dir if g.name == "hydra-access-controls"
|
9
|
+
HCL_DIR = g.gem_dir if g.name == "hydra-collections"
|
10
|
+
HCR_DIR = g.gem_dir if g.name == "hydra-core"
|
11
|
+
BKL_DIR = g.gem_dir if g.name == "blacklight"
|
12
12
|
end
|
13
13
|
|
14
14
|
# Load Rails-specific bits of blacklight
|
15
|
-
require BKL_DIR+'/app/controllers/concerns/blacklight/request_builders'
|
16
|
-
require BKL_DIR+'/app/controllers/concerns/blacklight/search_helper'
|
15
|
+
require BKL_DIR + '/app/controllers/concerns/blacklight/request_builders'
|
16
|
+
require BKL_DIR + '/app/controllers/concerns/blacklight/search_helper'
|
17
17
|
|
18
18
|
# Load Rails-specific bits of hydra-access-controls
|
19
|
-
require HAC_DIR+'/app/vocabularies/acl'
|
20
|
-
require HAC_DIR+'/app/vocabularies/hydra/acl'
|
21
|
-
require HAC_DIR+'/app/models/role_mapper'
|
22
|
-
require HAC_DIR+'/app/models/ability'
|
23
|
-
require HAC_DIR+'/app/models/hydra/access_controls/access_control_list'
|
24
|
-
require HAC_DIR+'/app/models/hydra/access_controls/permission'
|
25
|
-
require HAC_DIR+'/app/models/hydra/access_controls/embargo'
|
26
|
-
require HAC_DIR+'/app/models/hydra/access_controls/lease'
|
27
|
-
require HAC_DIR+'/app/models/concerns/hydra/with_depositor'
|
28
|
-
require HAC_DIR+'/app/services/hydra/lease_service'
|
29
|
-
require HAC_DIR+'/app/services/hydra/embargo_service'
|
30
|
-
require HAC_DIR+'/app/validators/hydra/future_date_validator'
|
19
|
+
require HAC_DIR + '/app/vocabularies/acl'
|
20
|
+
require HAC_DIR + '/app/vocabularies/hydra/acl'
|
21
|
+
require HAC_DIR + '/app/models/role_mapper'
|
22
|
+
require HAC_DIR + '/app/models/ability'
|
23
|
+
require HAC_DIR + '/app/models/hydra/access_controls/access_control_list'
|
24
|
+
require HAC_DIR + '/app/models/hydra/access_controls/permission'
|
25
|
+
require HAC_DIR + '/app/models/hydra/access_controls/embargo'
|
26
|
+
require HAC_DIR + '/app/models/hydra/access_controls/lease'
|
27
|
+
require HAC_DIR + '/app/models/concerns/hydra/with_depositor'
|
28
|
+
require HAC_DIR + '/app/services/hydra/lease_service'
|
29
|
+
require HAC_DIR + '/app/services/hydra/embargo_service'
|
30
|
+
require HAC_DIR + '/app/validators/hydra/future_date_validator'
|
31
31
|
|
32
32
|
# Loading hydra-collections
|
33
33
|
require 'hydra-collections'
|
34
|
-
require HCR_DIR+'/app/models/concerns/hydra/model_methods'
|
35
|
-
require HCL_DIR+'/app/models/concerns/hydra/collections/metadata'
|
36
|
-
require HCL_DIR+'/app/models/concerns/hydra/collections/relations'
|
37
|
-
require HCL_DIR+'/app/models/concerns/hydra/collection'
|
34
|
+
require HCR_DIR + '/app/models/concerns/hydra/model_methods'
|
35
|
+
require HCL_DIR + '/app/models/concerns/hydra/collections/metadata'
|
36
|
+
require HCL_DIR + '/app/models/concerns/hydra/collections/relations'
|
37
|
+
require HCL_DIR + '/app/models/concerns/hydra/collection'
|
38
38
|
|
39
39
|
module ExampleModel
|
40
|
-
|
41
40
|
class RDFProperties < ActiveFedora::Base
|
42
41
|
property :title, predicate: ::RDF::DC.title do |index|
|
43
42
|
index.as :stored_searchable, :facetable
|
@@ -95,5 +94,4 @@ module ExampleModel
|
|
95
94
|
class Collection < ActiveFedora::Base
|
96
95
|
include Hydra::Collection
|
97
96
|
end
|
98
|
-
|
99
97
|
end
|
@@ -1,32 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FedoraMigrate::ContentMover do
|
4
|
-
|
5
4
|
let(:nil_source) { double("Source", content: nil, dsid: "datastream") }
|
6
5
|
let(:source) do
|
7
|
-
double("Source",
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
double("Source",
|
7
|
+
content: "foo",
|
8
|
+
dsid: "datastream",
|
9
|
+
label: "label",
|
10
|
+
mimeType: "mimetype",
|
11
|
+
createDate: Time.new(1993, 02, 24, 12, 0, 0, "+09:00") # Rubydora returns Time objects for datastreams' creation dates
|
12
|
+
)
|
14
13
|
end
|
15
14
|
let(:target) { double("Target", content: "", original_name: nil, mime_type: nil) }
|
16
15
|
|
17
16
|
describe "#migrate" do
|
18
17
|
context "without content" do
|
19
|
-
subject {
|
18
|
+
subject { described_class.new(nil_source, target).migrate }
|
20
19
|
it "reports a nil source" do
|
21
20
|
expect(subject).to be_kind_of FedoraMigrate::ContentMover::Report
|
22
21
|
expect(subject.error).to eql "Nil source -- it's probably defined in the target but not present in the source"
|
23
22
|
end
|
24
23
|
end
|
25
24
|
context "with content" do
|
26
|
-
subject {
|
25
|
+
subject { described_class.new(source, target).migrate }
|
27
26
|
before do
|
28
|
-
allow_any_instance_of(
|
29
|
-
allow_any_instance_of(
|
27
|
+
allow_any_instance_of(described_class).to receive(:move_content).and_return(true)
|
28
|
+
allow_any_instance_of(described_class).to receive(:insert_date_created_by_application).and_return(true)
|
30
29
|
end
|
31
30
|
it { is_expected.to be_kind_of FedoraMigrate::ContentMover::Report }
|
32
31
|
end
|
@@ -37,38 +36,38 @@ describe FedoraMigrate::ContentMover do
|
|
37
36
|
allow(target).to receive(:content=).with("foo")
|
38
37
|
allow(target).to receive(:original_name=).with("label")
|
39
38
|
allow(target).to receive(:mime_type=).with("mimetype")
|
40
|
-
allow(target).to receive(:save).and_return(true)
|
39
|
+
allow(target).to receive(:save).and_return(true)
|
41
40
|
end
|
42
|
-
subject do
|
43
|
-
|
41
|
+
subject do
|
42
|
+
described_class.new(source, target).move_content
|
44
43
|
end
|
45
44
|
context "with a valid checksum" do
|
46
|
-
before { allow_any_instance_of(
|
45
|
+
before { allow_any_instance_of(described_class).to receive(:valid?).and_return(true) }
|
47
46
|
it { is_expected.to be nil }
|
48
47
|
end
|
49
48
|
context "with an invalid checksum" do
|
50
|
-
before { allow_any_instance_of(
|
49
|
+
before { allow_any_instance_of(described_class).to receive(:valid?).and_return(false) }
|
51
50
|
it { is_expected.to eql "Failed checksum" }
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
55
54
|
describe "#insert_date_created_by_application" do
|
56
|
-
subject {
|
55
|
+
subject { described_class.new(source, target).insert_date_created_by_application }
|
57
56
|
context "with a successful update" do
|
58
57
|
let(:successful_status) { double("Result", status: 204) }
|
59
|
-
before { allow_any_instance_of(
|
58
|
+
before { allow_any_instance_of(described_class).to receive(:perform_sparql_insert).and_return(successful_status) }
|
60
59
|
it { is_expected.to be nil }
|
61
60
|
end
|
62
61
|
context "with an unsuccessful update" do
|
63
62
|
let(:unsuccessful_status) { double("Result", status: 404, body: "Error!") }
|
64
|
-
before { allow_any_instance_of(
|
63
|
+
before { allow_any_instance_of(described_class).to receive(:perform_sparql_insert).and_return(unsuccessful_status) }
|
65
64
|
it { is_expected.to eql "There was a problem with sparql 404 Error!" }
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
69
68
|
describe "#sparql_insert" do
|
70
69
|
let(:sample_sparql_query) do
|
71
|
-
<<-EOF
|
70
|
+
<<-EOF
|
72
71
|
PREFIX premis: <http://www.loc.gov/premis/rdf/v1#>
|
73
72
|
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
74
73
|
DELETE WHERE { ?s premis:hasDateCreatedByApplication ?o } ;
|
@@ -78,8 +77,7 @@ INSERT {
|
|
78
77
|
WHERE { }
|
79
78
|
EOF
|
80
79
|
end
|
81
|
-
subject {
|
80
|
+
subject { described_class.new(source, target).sparql_insert }
|
82
81
|
it { is_expected.to eql sample_sparql_query }
|
83
82
|
end
|
84
|
-
|
85
83
|
end
|
@@ -1,39 +1,35 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FedoraMigrate::DatastreamMover do
|
4
|
-
|
5
4
|
describe "#post_initialize" do
|
6
5
|
specify "a target is required" do
|
7
|
-
expect{subject.new}.to raise_error(StandardError)
|
6
|
+
expect { subject.new }.to raise_error(StandardError)
|
8
7
|
end
|
9
8
|
end
|
10
9
|
|
11
10
|
describe "#versionable?" do
|
12
|
-
|
13
|
-
let(:
|
14
|
-
let(:non_versionable_target) { instance_double("Target", :versionable? => false) }
|
11
|
+
let(:versionable_target) { instance_double("Target", versionable?: true) }
|
12
|
+
let(:non_versionable_target) { instance_double("Target", versionable?: false) }
|
15
13
|
|
16
14
|
context "by default" do
|
17
|
-
subject {
|
18
|
-
it { is_expected.
|
15
|
+
subject { described_class.new("foo", "bar") }
|
16
|
+
it { is_expected.not_to be_versionable }
|
19
17
|
end
|
20
18
|
context "when the datastream is not versionable" do
|
21
|
-
subject {
|
22
|
-
it { is_expected.
|
19
|
+
subject { described_class.new("source", non_versionable_target) }
|
20
|
+
it { is_expected.not_to be_versionable }
|
23
21
|
end
|
24
22
|
context "when the datastream is versionable" do
|
25
|
-
subject {
|
23
|
+
subject { described_class.new("source", versionable_target) }
|
26
24
|
it { is_expected.to be_versionable }
|
27
25
|
context "but you want to override that" do
|
28
26
|
subject do
|
29
|
-
mover =
|
27
|
+
mover = described_class.new("source", versionable_target)
|
30
28
|
mover.versionable = false
|
31
29
|
return mover
|
32
30
|
end
|
33
|
-
it { is_expected.
|
31
|
+
it { is_expected.not_to be_versionable }
|
34
32
|
end
|
35
33
|
end
|
36
|
-
|
37
34
|
end
|
38
|
-
|
39
35
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FedoraMigrate::DatastreamVerification do
|
4
|
-
|
5
4
|
class TestSubject
|
6
5
|
include FedoraMigrate::DatastreamVerification
|
7
|
-
def initialize
|
6
|
+
def initialize(datastream)
|
8
7
|
@datastream = datastream
|
9
8
|
@source = datastream
|
10
9
|
end
|
@@ -17,24 +16,24 @@ describe FedoraMigrate::DatastreamVerification do
|
|
17
16
|
context "that match Fedora4's checksum" do
|
18
17
|
subject { TestSubject.new(good_binary_source) }
|
19
18
|
before { allow(subject).to receive(:target_checksum).once.and_return("foo") }
|
20
|
-
it { is_expected.to
|
19
|
+
it { is_expected.to be_matching_checksums }
|
21
20
|
it { is_expected.to be_valid }
|
22
21
|
end
|
23
22
|
context "that do not match Fedora4's checksum" do
|
24
23
|
subject { TestSubject.new(bad_binary_source) }
|
25
24
|
before { allow(subject).to receive(:target_checksum).twice.and_return("bar") }
|
26
|
-
it { is_expected.
|
25
|
+
it { is_expected.not_to be_valid }
|
27
26
|
end
|
28
27
|
context "when the checksum is missing" do
|
29
28
|
subject { TestSubject.new(missing_checksum) }
|
30
29
|
context "and a newly calculated checksum matches" do
|
31
30
|
before { allow(subject).to receive(:target_checksum).twice.and_return(Digest::SHA1.hexdigest("foo")) }
|
32
|
-
it { is_expected.to
|
31
|
+
it { is_expected.to be_matching_checksums }
|
33
32
|
it { is_expected.to be_valid }
|
34
33
|
end
|
35
34
|
context "and a newly calculated checksum does not match" do
|
36
35
|
before { expect_any_instance_of(TestSubject).to receive(:target_checksum).twice.and_return(Digest::SHA1.hexdigest("bar")) }
|
37
|
-
it { is_expected.
|
36
|
+
it { is_expected.not_to be_valid }
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
@@ -43,12 +42,11 @@ describe FedoraMigrate::DatastreamVerification do
|
|
43
42
|
subject { TestSubject.new(double("Datastream", checksum: "invalid", mimeType: "text/xml", content: "<bar></bar>")) }
|
44
43
|
context "when the datastream content is correctly altered upon migration" do
|
45
44
|
before { allow(subject).to receive(:target_content).once.and_return("<?xml version=\"1.0\"?>\n<bar></bar>") }
|
46
|
-
it { is_expected.to
|
45
|
+
it { is_expected.to be_matching_nokogiri_checksums }
|
47
46
|
end
|
48
47
|
context "when the datastream content is incorrectly altered upon migration" do
|
49
48
|
before { allow(subject).to receive(:target_content).once.and_return("<?xml version=\"1.0\"?>\n<baz></baz>") }
|
50
|
-
it { is_expected.
|
49
|
+
it { is_expected.not_to be_matching_nokogiri_checksums }
|
51
50
|
end
|
52
51
|
end
|
53
|
-
|
54
52
|
end
|
@@ -4,10 +4,9 @@ describe FedoraMigrate::DatesMover do
|
|
4
4
|
let(:target) { ExampleModel::RDFObject.new }
|
5
5
|
let(:source) { instance_double('Source', createdDate: 'yesterday', lastModifiedDate: 'today') }
|
6
6
|
|
7
|
-
subject {
|
7
|
+
subject { described_class.new(source, target) }
|
8
8
|
|
9
9
|
describe '#migrate' do
|
10
|
-
|
11
10
|
it 'migrates the create and mod dates' do
|
12
11
|
subject.migrate
|
13
12
|
expect(target.date_uploaded).to eq 'yesterday'
|
@@ -17,7 +16,7 @@ describe FedoraMigrate::DatesMover do
|
|
17
16
|
context "when the source methods don't exist" do
|
18
17
|
let(:source) { instance_double('Source with no date methods') }
|
19
18
|
it 'gracefully does nothing' do
|
20
|
-
expect{ subject.migrate }.
|
19
|
+
expect { subject.migrate }.not_to raise_error
|
21
20
|
expect(target.date_uploaded).to be_nil
|
22
21
|
expect(target.date_modified).to be_nil
|
23
22
|
end
|
@@ -26,7 +25,7 @@ describe FedoraMigrate::DatesMover do
|
|
26
25
|
context "when the target methods don't exist" do
|
27
26
|
let(:target) { instance_double('Target with no date methods') }
|
28
27
|
it 'gracefully does nothing' do
|
29
|
-
expect{ subject.migrate }.
|
28
|
+
expect { subject.migrate }.not_to raise_error
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
@@ -1,19 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FedoraMigrate do
|
4
|
-
|
5
4
|
describe "Fedora3 / " do
|
6
|
-
|
7
5
|
describe "configuration" do
|
8
|
-
subject {
|
6
|
+
subject { described_class.fedora_config }
|
9
7
|
it { is_expected.to be_kind_of ActiveFedora::Config }
|
10
8
|
end
|
11
9
|
|
12
10
|
describe "connection" do
|
13
|
-
subject {
|
11
|
+
subject { described_class.source }
|
14
12
|
it { is_expected.to be_kind_of FedoraMigrate::RubydoraConnection }
|
15
13
|
end
|
16
|
-
|
17
14
|
end
|
18
|
-
|
19
15
|
end
|
@@ -1,17 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FedoraMigrate::FileConfigurator do
|
4
|
-
|
5
4
|
subject { FedoraMigrate.configurator }
|
6
5
|
|
7
6
|
describe "#fedora3_config" do
|
8
|
-
|
9
|
-
|
10
|
-
expect(subject.fedora3_config[:
|
11
|
-
expect(subject.fedora3_config[:
|
12
|
-
expect(subject.fedora3_config[:url]).to eql "http://localhost:8983/fedora3"
|
7
|
+
it "uses the values from the yml file" do
|
8
|
+
expect(subject.fedora3_config[:user]).to eql "fedoraAdmin"
|
9
|
+
expect(subject.fedora3_config[:password]).to eql "fedoraAdmin"
|
10
|
+
expect(subject.fedora3_config[:url]).to eql "http://localhost:8983/fedora3"
|
13
11
|
end
|
14
|
-
|
15
12
|
end
|
16
|
-
|
17
13
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FedoraMigrate::MigrationOptions do
|
4
|
-
|
5
4
|
class TestCase
|
6
5
|
include FedoraMigrate::MigrationOptions
|
7
6
|
end
|
@@ -66,7 +65,7 @@ describe FedoraMigrate::MigrationOptions do
|
|
66
65
|
context "with a list of pids" do
|
67
66
|
let(:blacklist) { ["pid1, pid2"] }
|
68
67
|
subject do
|
69
|
-
TestCase.new.tap do |example|
|
68
|
+
TestCase.new.tap do |example|
|
70
69
|
example.options = { blacklist: blacklist }
|
71
70
|
end
|
72
71
|
end
|
@@ -75,5 +74,4 @@ describe FedoraMigrate::MigrationOptions do
|
|
75
74
|
end
|
76
75
|
end
|
77
76
|
end
|
78
|
-
|
79
77
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FedoraMigrate::MigrationReport do
|
4
|
-
|
5
4
|
let(:path) { "spec/fixtures/reports/sample" }
|
6
5
|
let(:default_path) { "migration_report" }
|
7
|
-
let(:existing_report) {
|
8
|
-
let(:new_report) {
|
6
|
+
let(:existing_report) { described_class.new(path) }
|
7
|
+
let(:new_report) { described_class.new }
|
9
8
|
|
10
9
|
context "with an existing report" do
|
11
10
|
subject { existing_report }
|
@@ -23,7 +22,7 @@ describe FedoraMigrate::MigrationReport do
|
|
23
22
|
it { is_expected.to include("scholarsphere:6395wb555", "scholarsphere:x346dm27k") }
|
24
23
|
end
|
25
24
|
describe "::failures" do
|
26
|
-
subject { existing_report.failures }
|
25
|
+
subject { existing_report.failures }
|
27
26
|
context "when the report contains failed migrations" do
|
28
27
|
it { is_expected.to eq 2 }
|
29
28
|
end
|
@@ -33,13 +32,13 @@ describe FedoraMigrate::MigrationReport do
|
|
33
32
|
it { is_expected.to eq 5 }
|
34
33
|
end
|
35
34
|
describe "::report_failures" do
|
36
|
-
subject { existing_report.report_failures }
|
35
|
+
subject { existing_report.report_failures }
|
37
36
|
it { is_expected.to be_kind_of(String) }
|
38
37
|
end
|
39
38
|
describe "::save" do
|
40
39
|
let(:individual_report) { Hash.new }
|
41
40
|
let(:pid) { "some:pid" }
|
42
|
-
it "
|
41
|
+
it "writes the report" do
|
43
42
|
expect(File).to receive(:write).with("migration_report/some_pid.json", "{\n}")
|
44
43
|
new_report.save(pid, individual_report)
|
45
44
|
end
|