fedora-migrate 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +6 -8
  4. data/README.md +3 -1
  5. data/fedora-migrate.gemspec +2 -2
  6. data/lib/fedora_migrate/file_configurator.rb +1 -1
  7. data/lib/fedora_migrate/migration_options.rb +5 -0
  8. data/lib/fedora_migrate/migration_report.rb +32 -6
  9. data/lib/fedora_migrate/repository_migrator.rb +53 -30
  10. data/lib/fedora_migrate/version.rb +1 -1
  11. data/spec/fixtures/reports/failed/sufia_5m60qr94g.json +7 -0
  12. data/spec/fixtures/reports/failed/sufia_5m60qr95r.json +58 -0
  13. data/spec/fixtures/reports/failed/sufia_5m60qr961.json +58 -0
  14. data/spec/fixtures/reports/failed/sufia_5m60qr979.json +34 -0
  15. data/spec/fixtures/reports/failed/sufia_rb68xc089.json +7 -0
  16. data/spec/fixtures/reports/failed/sufia_rb68xc09k.json +21 -0
  17. data/spec/fixtures/reports/failed/sufia_rb68xc10b.json +49 -0
  18. data/spec/fixtures/reports/failed/sufia_rb68xc11m.json +49 -0
  19. data/spec/fixtures/reports/failed/sufia_xp68km39w.json +54 -0
  20. data/spec/fixtures/reports/sample/scholarsphere_000000000.json +26 -0
  21. data/spec/fixtures/reports/sample/scholarsphere_000000018.json +102 -0
  22. data/spec/fixtures/reports/sample/scholarsphere_05741r698.json +26 -0
  23. data/spec/fixtures/reports/sample/scholarsphere_6395wb555.json +5 -0
  24. data/spec/fixtures/reports/sample/scholarsphere_x346dm27k.json +5 -0
  25. data/spec/integration/repository_migration_spec.rb +21 -10
  26. data/spec/integration/versions_spec.rb +1 -0
  27. data/spec/spec_helper.rb +1 -0
  28. data/spec/support/example_model.rb +8 -1
  29. data/spec/unit/migration_options_spec.rb +18 -0
  30. data/spec/unit/migration_report_spec.rb +16 -13
  31. data/spec/unit/repository_migrator_spec.rb +2 -8
  32. metadata +35 -11
  33. data/spec/fixtures/failed-report.json +0 -339
  34. data/spec/fixtures/sample-report.json +0 -166
@@ -58,4 +58,22 @@ describe FedoraMigrate::MigrationOptions do
58
58
  end
59
59
  end
60
60
 
61
+ describe "#blacklist" do
62
+ context "by default" do
63
+ subject { TestCase.new.blacklist }
64
+ it { is_expected.to be_empty }
65
+ end
66
+ context "with a list of pids" do
67
+ let(:blacklist) { ["pid1, pid2"] }
68
+ subject do
69
+ TestCase.new.tap do |example|
70
+ example.options = { blacklist: blacklist }
71
+ end
72
+ end
73
+ it "returns the list of pids" do
74
+ expect(subject.blacklist).to eql blacklist
75
+ end
76
+ end
77
+ end
78
+
61
79
  end
@@ -2,7 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  describe FedoraMigrate::MigrationReport do
4
4
 
5
- let(:existing_report) { FedoraMigrate::MigrationReport.new("spec/fixtures/sample-report.json") }
5
+ let(:path) { "spec/fixtures/reports/sample" }
6
+ let(:default_path) { "migration_report" }
7
+ let(:existing_report) { FedoraMigrate::MigrationReport.new(path) }
6
8
  let(:new_report) { FedoraMigrate::MigrationReport.new }
7
9
 
8
10
  context "with an existing report" do
@@ -12,6 +14,10 @@ describe FedoraMigrate::MigrationReport do
12
14
  subject { existing_report.results }
13
15
  it { is_expected.to be_kind_of(Hash) }
14
16
  end
17
+ describe "::path" do
18
+ subject { existing_report.path }
19
+ it { is_expected.to eql path }
20
+ end
15
21
  describe "::failed_objects" do
16
22
  subject { existing_report.failed_objects }
17
23
  it { is_expected.to include("scholarsphere:6395wb555", "scholarsphere:x346dm27k") }
@@ -31,17 +37,11 @@ describe FedoraMigrate::MigrationReport do
31
37
  it { is_expected.to be_kind_of(String) }
32
38
  end
33
39
  describe "::save" do
34
- context "with the default path" do
35
- it "should write the report" do
36
- expect(File).to receive(:write).with("report.json", "{\n}")
37
- new_report.save
38
- end
39
- end
40
- context "with a user-provided path" do
41
- it "should write the report" do
42
- expect(File).to receive(:write).with("foo/path/report.json", "{\n}")
43
- new_report.save("foo/path")
44
- end
40
+ let(:individual_report) { Hash.new }
41
+ let(:pid) { "some:pid" }
42
+ it "should write the report" do
43
+ expect(File).to receive(:write).with("migration_report/some_pid.json", "{\n}")
44
+ new_report.save(pid, individual_report)
45
45
  end
46
46
  end
47
47
  end
@@ -53,6 +53,9 @@ describe FedoraMigrate::MigrationReport do
53
53
  subject { new_report.results }
54
54
  it { is_expected.to be_kind_of(Hash) }
55
55
  end
56
+ describe "::path" do
57
+ subject { new_report.path }
58
+ it { is_expected.to eql default_path }
59
+ end
56
60
  end
57
-
58
61
  end
@@ -8,16 +8,10 @@ describe FedoraMigrate::RepositoryMigrator do
8
8
  it { is_expected.to respond_to(:report) }
9
9
  it { is_expected.to respond_to(:namespace) }
10
10
 
11
- def mock_report content
12
- report = FedoraMigrate::MigrationReport.new
13
- report.results = JSON.parse(content.to_json)
14
- report
15
- end
16
-
17
11
  describe "#failures" do
18
12
  context "when objects have failed to migrate" do
19
13
  let(:failing_report) { { "sufia:rb68xc089" => FedoraMigrate::RepositoryMigrator::SingleObjectReport.new(false, "objects", "relationships") } }
20
- before { allow_any_instance_of(FedoraMigrate::RepositoryMigrator).to receive(:report).and_return(mock_report(failing_report)) }
14
+ before { allow_any_instance_of(FedoraMigrate::MigrationReport).to receive(:results).and_return(failing_report) }
21
15
  subject do
22
16
  migrator = FedoraMigrate::RepositoryMigrator.new(namespace)
23
17
  migrator.failures
@@ -26,7 +20,7 @@ describe FedoraMigrate::RepositoryMigrator do
26
20
  end
27
21
  context "when all objects have migrated" do
28
22
  let(:passing_report) { { "sufia:rb68xc089" => FedoraMigrate::RepositoryMigrator::SingleObjectReport.new(true, "objects", "relationships") } }
29
- before { allow_any_instance_of(FedoraMigrate::RepositoryMigrator).to receive(:report).and_return(mock_report(passing_report)) }
23
+ before { allow_any_instance_of(FedoraMigrate::MigrationReport).to receive(:results).and_return(passing_report) }
30
24
  subject do
31
25
  migrator = FedoraMigrate::RepositoryMigrator.new(namespace)
32
26
  migrator.failures
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fedora-migrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Wead
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-24 00:00:00.000000000 Z
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hydra-head
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '9.0'
19
+ version: '9.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '9.0'
26
+ version: '9.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubydora
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '4.0'
89
+ version: '5.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '4.0'
96
+ version: '5.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: jettywrapper
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +180,6 @@ files:
180
180
  - lib/fedora_migrate/version.rb
181
181
  - lib/tasks/fedora-migrate.rake
182
182
  - spec/fixtures/datastreams/sufia-rb68xc089-characterization.xml
183
- - spec/fixtures/failed-report.json
184
183
  - spec/fixtures/objects/f3-migration-a.xml
185
184
  - spec/fixtures/objects/gf-versioned-content.xml
186
185
  - spec/fixtures/objects/scholarsphere_5712mc568.xml
@@ -196,7 +195,20 @@ files:
196
195
  - spec/fixtures/objects/sufia_5m60qr95r.xml
197
196
  - spec/fixtures/objects/sufia_5m60qr961.xml
198
197
  - spec/fixtures/objects/sufia_5m60qr979.xml
199
- - spec/fixtures/sample-report.json
198
+ - spec/fixtures/reports/failed/sufia_5m60qr94g.json
199
+ - spec/fixtures/reports/failed/sufia_5m60qr95r.json
200
+ - spec/fixtures/reports/failed/sufia_5m60qr961.json
201
+ - spec/fixtures/reports/failed/sufia_5m60qr979.json
202
+ - spec/fixtures/reports/failed/sufia_rb68xc089.json
203
+ - spec/fixtures/reports/failed/sufia_rb68xc09k.json
204
+ - spec/fixtures/reports/failed/sufia_rb68xc10b.json
205
+ - spec/fixtures/reports/failed/sufia_rb68xc11m.json
206
+ - spec/fixtures/reports/failed/sufia_xp68km39w.json
207
+ - spec/fixtures/reports/sample/scholarsphere_000000000.json
208
+ - spec/fixtures/reports/sample/scholarsphere_000000018.json
209
+ - spec/fixtures/reports/sample/scholarsphere_05741r698.json
210
+ - spec/fixtures/reports/sample/scholarsphere_6395wb555.json
211
+ - spec/fixtures/reports/sample/scholarsphere_x346dm27k.json
200
212
  - spec/integration/content_versions_spec.rb
201
213
  - spec/integration/fedora3_interface_spec.rb
202
214
  - spec/integration/missing_relationships_spec.rb
@@ -244,13 +256,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
256
  version: '0'
245
257
  requirements: []
246
258
  rubyforge_project:
247
- rubygems_version: 2.4.6
259
+ rubygems_version: 2.4.3
248
260
  signing_key:
249
261
  specification_version: 4
250
262
  summary: Migrate Hydra-based repository data from Fedora3 to Fedora4
251
263
  test_files:
252
264
  - spec/fixtures/datastreams/sufia-rb68xc089-characterization.xml
253
- - spec/fixtures/failed-report.json
254
265
  - spec/fixtures/objects/f3-migration-a.xml
255
266
  - spec/fixtures/objects/gf-versioned-content.xml
256
267
  - spec/fixtures/objects/scholarsphere_5712mc568.xml
@@ -266,7 +277,20 @@ test_files:
266
277
  - spec/fixtures/objects/sufia_5m60qr95r.xml
267
278
  - spec/fixtures/objects/sufia_5m60qr961.xml
268
279
  - spec/fixtures/objects/sufia_5m60qr979.xml
269
- - spec/fixtures/sample-report.json
280
+ - spec/fixtures/reports/failed/sufia_5m60qr94g.json
281
+ - spec/fixtures/reports/failed/sufia_5m60qr95r.json
282
+ - spec/fixtures/reports/failed/sufia_5m60qr961.json
283
+ - spec/fixtures/reports/failed/sufia_5m60qr979.json
284
+ - spec/fixtures/reports/failed/sufia_rb68xc089.json
285
+ - spec/fixtures/reports/failed/sufia_rb68xc09k.json
286
+ - spec/fixtures/reports/failed/sufia_rb68xc10b.json
287
+ - spec/fixtures/reports/failed/sufia_rb68xc11m.json
288
+ - spec/fixtures/reports/failed/sufia_xp68km39w.json
289
+ - spec/fixtures/reports/sample/scholarsphere_000000000.json
290
+ - spec/fixtures/reports/sample/scholarsphere_000000018.json
291
+ - spec/fixtures/reports/sample/scholarsphere_05741r698.json
292
+ - spec/fixtures/reports/sample/scholarsphere_6395wb555.json
293
+ - spec/fixtures/reports/sample/scholarsphere_x346dm27k.json
270
294
  - spec/integration/content_versions_spec.rb
271
295
  - spec/integration/fedora3_interface_spec.rb
272
296
  - spec/integration/missing_relationships_spec.rb
@@ -1,339 +0,0 @@
1
- {
2
- "sufia:5m60qr94g": {
3
- "status": false,
4
- "object": "Sample object migration failure",
5
- "relationships": [
6
-
7
- ]
8
- },
9
- "sufia:5m60qr95r": {
10
- "status": true,
11
- "object": {
12
- "id": "5m60qr95r",
13
- "class": "GenericFile",
14
- "content_datastreams": [
15
- {
16
- "ds": "content",
17
- "versions": [
18
- {
19
- "name": "file2.txt",
20
- "mime_type": "text/plain",
21
- "original_date": "2015-01-19T21:32:47Z"
22
- }
23
- ]
24
- },
25
- {
26
- "ds": "thumbnail",
27
- "versions": [
28
- {
29
- "error": "Nil source -- it's probably defined in the target but not present in the source"
30
- }
31
- ]
32
- },
33
- {
34
- "ds": "characterization",
35
- "versions": [
36
- {
37
- "error": "Nil source -- it's probably defined in the target but not present in the source"
38
- }
39
- ]
40
- }
41
- ],
42
- "rdf_datastreams": [
43
- {
44
- "ds": "descMetadata",
45
- "status": [
46
-
47
- ]
48
- }
49
- ],
50
- "permissions": [
51
- "read_groups = []",
52
- "edit_groups = []",
53
- "discover_groups = []",
54
- "read_users = []",
55
- "edit_users = [\"awead@psu.edu\"]",
56
- "discover_users = []"
57
- ],
58
- "dates": {
59
- "uploaded": null,
60
- "modified": null
61
- }
62
- },
63
- "relationships": [
64
- "http://localhost:8983/fedora/rest/test/5m60qr95r--info:fedora/fedora-system:def/relations-external#isPartOf--http://localhost:8983/fedora/rest/test/5m60qr94g"
65
- ]
66
- },
67
- "sufia:5m60qr961": {
68
- "status": true,
69
- "object": {
70
- "id": "5m60qr961",
71
- "class": "GenericFile",
72
- "content_datastreams": [
73
- {
74
- "ds": "content",
75
- "versions": [
76
- {
77
- "name": "file1.txt",
78
- "mime_type": "text/plain",
79
- "original_date": "2015-01-19T21:32:49Z"
80
- }
81
- ]
82
- },
83
- {
84
- "ds": "thumbnail",
85
- "versions": [
86
- {
87
- "error": "Nil source -- it's probably defined in the target but not present in the source"
88
- }
89
- ]
90
- },
91
- {
92
- "ds": "characterization",
93
- "versions": [
94
- {
95
- "error": "Nil source -- it's probably defined in the target but not present in the source"
96
- }
97
- ]
98
- }
99
- ],
100
- "rdf_datastreams": [
101
- {
102
- "ds": "descMetadata",
103
- "status": [
104
-
105
- ]
106
- }
107
- ],
108
- "permissions": [
109
- "read_groups = []",
110
- "edit_groups = []",
111
- "discover_groups = []",
112
- "read_users = []",
113
- "edit_users = [\"awead@psu.edu\"]",
114
- "discover_users = []"
115
- ],
116
- "dates": {
117
- "uploaded": null,
118
- "modified": null
119
- }
120
- },
121
- "relationships": [
122
- "http://localhost:8983/fedora/rest/test/5m60qr961--info:fedora/fedora-system:def/relations-external#isPartOf--http://localhost:8983/fedora/rest/test/5m60qr94g"
123
- ]
124
- },
125
- "sufia:5m60qr979": {
126
- "status": true,
127
- "object": {
128
- "id": "5m60qr979",
129
- "class": "Collection",
130
- "content_datastreams": [
131
-
132
- ],
133
- "rdf_datastreams": [
134
- {
135
- "ds": "descMetadata",
136
- "status": [
137
-
138
- ]
139
- }
140
- ],
141
- "permissions": [
142
- "read_groups = [\"public\"]",
143
- "edit_groups = []",
144
- "discover_groups = []",
145
- "read_users = []",
146
- "edit_users = [\"awead@psu.edu\"]",
147
- "discover_users = []"
148
- ],
149
- "dates": {
150
- "uploaded": "2015-01-19T21:34:23.805Z",
151
- "modified": "2015-03-03T18:48:51.16Z"
152
- }
153
- },
154
- "relationships": [
155
- "http://localhost:8983/fedora/rest/test/5m60qr979--info:fedora/fedora-system:def/relations-external#hasCollectionMember--http://localhost:8983/fedora/rest/test/5m60qr95r",
156
- "http://localhost:8983/fedora/rest/test/5m60qr979--info:fedora/fedora-system:def/relations-external#hasCollectionMember--http://localhost:8983/fedora/rest/test/5m60qr961"
157
- ]
158
- },
159
- "sufia:rb68xc089": {
160
- "status": false,
161
- "object": "Sample object migration failure",
162
- "relationships": [
163
-
164
- ]
165
- },
166
- "sufia:rb68xc09k": {
167
- "status": true,
168
- "object": {
169
- "id": "rb68xc09k",
170
- "class": "Batch",
171
- "content_datastreams": [
172
-
173
- ],
174
- "rdf_datastreams": [
175
-
176
- ],
177
- "permissions": null,
178
- "dates": {
179
- "uploaded": null,
180
- "modified": null
181
- }
182
- },
183
- "relationships": [
184
-
185
- ]
186
- },
187
- "sufia:rb68xc10b": {
188
- "status": true,
189
- "object": {
190
- "id": "rb68xc10b",
191
- "class": "GenericFile",
192
- "content_datastreams": [
193
- {
194
- "ds": "content",
195
- "versions": [
196
-
197
- ]
198
- },
199
- {
200
- "ds": "thumbnail",
201
- "versions": [
202
- {
203
- "error": "Nil source -- it's probably defined in the target but not present in the source"
204
- }
205
- ]
206
- },
207
- {
208
- "ds": "characterization",
209
- "versions": [
210
- {
211
- "error": "Nil source -- it's probably defined in the target but not present in the source"
212
- }
213
- ]
214
- }
215
- ],
216
- "rdf_datastreams": [
217
-
218
- ],
219
- "permissions": [
220
- "read_groups = []",
221
- "edit_groups = []",
222
- "discover_groups = []",
223
- "read_users = []",
224
- "edit_users = [\"jilluser@example.com\"]",
225
- "discover_users = []"
226
- ],
227
- "dates": {
228
- "uploaded": null,
229
- "modified": null
230
- }
231
- },
232
- "relationships": [
233
- "http://localhost:8983/fedora/rest/test/rb68xc10b--info:fedora/fedora-system:def/relations-external#isPartOf--http://localhost:8983/fedora/rest/test/rb68xc09k"
234
- ]
235
- },
236
- "sufia:rb68xc11m": {
237
- "status": true,
238
- "object": {
239
- "id": "rb68xc11m",
240
- "class": "GenericFile",
241
- "content_datastreams": [
242
- {
243
- "ds": "content",
244
- "versions": [
245
-
246
- ]
247
- },
248
- {
249
- "ds": "thumbnail",
250
- "versions": [
251
- {
252
- "error": "Nil source -- it's probably defined in the target but not present in the source"
253
- }
254
- ]
255
- },
256
- {
257
- "ds": "characterization",
258
- "versions": [
259
- {
260
- "error": "Nil source -- it's probably defined in the target but not present in the source"
261
- }
262
- ]
263
- }
264
- ],
265
- "rdf_datastreams": [
266
-
267
- ],
268
- "permissions": [
269
- "read_groups = []",
270
- "edit_groups = []",
271
- "discover_groups = []",
272
- "read_users = []",
273
- "edit_users = [\"otherUser\"]",
274
- "discover_users = []"
275
- ],
276
- "dates": {
277
- "uploaded": null,
278
- "modified": null
279
- }
280
- },
281
- "relationships": [
282
- "http://localhost:8983/fedora/rest/test/rb68xc11m--info:fedora/fedora-system:def/relations-external#isPartOf--http://localhost:8983/fedora/rest/test/rb68xc09k"
283
- ]
284
- },
285
- "sufia:xp68km39w": {
286
- "status": true,
287
- "object": {
288
- "id": "xp68km39w",
289
- "class": "GenericFile",
290
- "content_datastreams": [
291
- {
292
- "ds": "content",
293
- "versions": [
294
-
295
- ]
296
- },
297
- {
298
- "ds": "thumbnail",
299
- "versions": [
300
- {
301
- "error": "Nil source -- it's probably defined in the target but not present in the source"
302
- }
303
- ]
304
- },
305
- {
306
- "ds": "characterization",
307
- "versions": [
308
- {
309
- "error": "Nil source -- it's probably defined in the target but not present in the source"
310
- }
311
- ]
312
- }
313
- ],
314
- "rdf_datastreams": [
315
- {
316
- "ds": "descMetadata",
317
- "status": [
318
-
319
- ]
320
- }
321
- ],
322
- "permissions": [
323
- "read_groups = []",
324
- "edit_groups = []",
325
- "discover_groups = []",
326
- "read_users = []",
327
- "edit_users = [\"awead@psu.edu\"]",
328
- "discover_users = []"
329
- ],
330
- "dates": {
331
- "uploaded": null,
332
- "modified": null
333
- }
334
- },
335
- "relationships": [
336
-
337
- ]
338
- }
339
- }