assembly-objectfile 1.7.1 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +22 -0
- data/.rubocop_todo.yml +132 -0
- data/Gemfile +1 -1
- data/Rakefile +9 -9
- data/assembly-objectfile.gemspec +11 -10
- data/lib/assembly-objectfile.rb +24 -22
- data/lib/assembly-objectfile/content_metadata.rb +225 -220
- data/lib/assembly-objectfile/object_file.rb +6 -9
- data/lib/assembly-objectfile/object_fileable.rb +131 -198
- data/lib/assembly-objectfile/version.rb +2 -4
- data/spec/content_metadata_spec.rb +455 -439
- data/spec/object_file_spec.rb +86 -83
- data/spec/spec_helper.rb +48 -45
- data/spec/test_data/input/someobject.obj +1 -0
- data/spec/test_data/input/someobject.ply +1 -0
- metadata +45 -12
@@ -1,528 +1,547 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Assembly::ContentMetadata do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:add_exif=>true,:add_file_attributes=>true,:objects=>objects)
|
4
|
+
it 'generates valid content metadata with exif for a single tif and jp2 of style=simple_image, adding file attributes' do
|
5
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)]
|
6
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, add_exif: true, add_file_attributes: true, objects: objects)
|
8
7
|
expect(result.class).to be String
|
9
8
|
xml = Nokogiri::XML(result)
|
10
9
|
expect(xml.errors.size).to be 0
|
11
|
-
expect(xml.xpath(
|
12
|
-
expect(xml.xpath(
|
13
|
-
expect(xml.xpath(
|
14
|
-
expect(xml.xpath(
|
15
|
-
expect(xml.xpath(
|
16
|
-
expect(xml.xpath(
|
17
|
-
expect(xml.xpath(
|
18
|
-
expect(xml.xpath(
|
19
|
-
expect(xml.xpath(
|
20
|
-
expect(xml.xpath(
|
21
|
-
expect(xml.xpath(
|
22
|
-
expect(xml.xpath(
|
23
|
-
expect(xml.xpath(
|
24
|
-
expect(xml.xpath(
|
25
|
-
expect(xml.xpath(
|
26
|
-
expect(xml.xpath(
|
27
|
-
expect(xml.xpath(
|
28
|
-
expect(xml.xpath(
|
29
|
-
expect(xml.xpath(
|
30
|
-
expect(xml.xpath(
|
31
|
-
expect(xml.xpath(
|
32
|
-
expect(xml.xpath(
|
33
|
-
expect(xml.xpath(
|
34
|
-
expect(xml.xpath(
|
35
|
-
expect(xml.xpath(
|
36
|
-
expect(xml.xpath(
|
37
|
-
expect(xml.xpath(
|
10
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
11
|
+
expect(xml.xpath('//resource').length).to be 2
|
12
|
+
expect(xml.xpath('//resource/file').length).to be 2
|
13
|
+
expect(xml.xpath('//resource/file/checksum').length).to be 4
|
14
|
+
expect(xml.xpath('//resource/file/checksum')[0].text).to eq('8d11fab63089a24c8b17063d29a4b0eac359fb41')
|
15
|
+
expect(xml.xpath('//resource/file/checksum')[1].text).to eq('a2400500acf21e43f5440d93be894101')
|
16
|
+
expect(xml.xpath('//resource/file/checksum')[2].text).to eq('b965b5787e0100ec2d43733144120feab327e88c')
|
17
|
+
expect(xml.xpath('//resource/file/checksum')[3].text).to eq('4eb54050d374291ece622d45e84f014d')
|
18
|
+
expect(xml.xpath('//label').length).to be 2
|
19
|
+
expect(xml.xpath('//label')[0].text).to match(/Image 1/)
|
20
|
+
expect(xml.xpath('//label')[1].text).to match(/Image 2/)
|
21
|
+
expect(xml.xpath('//resource')[0].attributes['type'].value).to eq('image')
|
22
|
+
expect(xml.xpath('//resource')[1].attributes['type'].value).to eq('image')
|
23
|
+
expect(xml.xpath('//resource/file')[0].attributes['size'].value).to eq('63542')
|
24
|
+
expect(xml.xpath('//resource/file')[0].attributes['mimetype'].value).to eq('image/tiff')
|
25
|
+
expect(xml.xpath('//resource/file')[0].attributes['publish'].value).to eq('no')
|
26
|
+
expect(xml.xpath('//resource/file')[0].attributes['preserve'].value).to eq('yes')
|
27
|
+
expect(xml.xpath('//resource/file')[0].attributes['shelve'].value).to eq('no')
|
28
|
+
expect(xml.xpath('//resource/file/imageData')[0].attributes['width'].value).to eq('100')
|
29
|
+
expect(xml.xpath('//resource/file/imageData')[0].attributes['height'].value).to eq('100')
|
30
|
+
expect(xml.xpath('//resource/file')[1].attributes['size'].value).to eq('306')
|
31
|
+
expect(xml.xpath('//resource/file')[1].attributes['mimetype'].value).to eq('image/jp2')
|
32
|
+
expect(xml.xpath('//resource/file')[1].attributes['publish'].value).to eq('yes')
|
33
|
+
expect(xml.xpath('//resource/file')[1].attributes['preserve'].value).to eq('no')
|
34
|
+
expect(xml.xpath('//resource/file')[1].attributes['shelve'].value).to eq('yes')
|
35
|
+
expect(xml.xpath('//resource/file/imageData')[1].attributes['width'].value).to eq('100')
|
36
|
+
expect(xml.xpath('//resource/file/imageData')[1].attributes['height'].value).to eq('100')
|
38
37
|
end
|
39
38
|
|
40
|
-
it
|
41
|
-
obj1=Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
|
42
|
-
obj2=Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)
|
43
|
-
obj3=Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)
|
44
|
-
obj1.file_attributes={:
|
45
|
-
obj2.file_attributes={:
|
46
|
-
objects=[obj1,obj2,obj3]
|
47
|
-
result =
|
39
|
+
it 'generates valid content metadata with no exif for a single tif and jp2 of style=simple_image, adding specific file attributes for 2 objects, and defaults for 1 object' do
|
40
|
+
obj1 = Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
|
41
|
+
obj2 = Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)
|
42
|
+
obj3 = Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)
|
43
|
+
obj1.file_attributes = { publish: 'no', preserve: 'no', shelve: 'no' }
|
44
|
+
obj2.file_attributes = { publish: 'yes', preserve: 'yes', shelve: 'yes' }
|
45
|
+
objects = [obj1, obj2, obj3]
|
46
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, add_exif: false, add_file_attributes: true, objects: objects)
|
48
47
|
expect(result.class).to be String
|
49
48
|
xml = Nokogiri::XML(result)
|
50
49
|
expect(xml.errors.size).to be 0
|
51
|
-
expect(xml.xpath(
|
52
|
-
expect(xml.xpath(
|
53
|
-
expect(xml.xpath(
|
54
|
-
expect(xml.xpath(
|
55
|
-
expect(xml.xpath(
|
56
|
-
expect(xml.xpath(
|
57
|
-
expect(xml.xpath(
|
58
|
-
expect(xml.xpath(
|
59
|
-
expect(xml.xpath(
|
60
|
-
expect(xml.xpath(
|
61
|
-
expect(xml.xpath(
|
62
|
-
expect(xml.xpath(
|
63
|
-
expect(xml.xpath(
|
64
|
-
expect(xml.xpath(
|
65
|
-
expect(xml.xpath(
|
66
|
-
expect(xml.xpath(
|
67
|
-
expect(xml.xpath(
|
68
|
-
expect(xml.xpath(
|
69
|
-
expect(xml.xpath(
|
70
|
-
expect(xml.xpath(
|
71
|
-
expect(xml.xpath(
|
50
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
51
|
+
expect(xml.xpath('//resource').length).to be 3
|
52
|
+
expect(xml.xpath('//resource/file').length).to be 3
|
53
|
+
expect(xml.xpath('//resource/file/checksum').length).to be 0
|
54
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
55
|
+
expect(xml.xpath('//label').length).to be 3
|
56
|
+
expect(xml.xpath('//label')[0].text).to match(/Image 1/)
|
57
|
+
expect(xml.xpath('//label')[1].text).to match(/Image 2/)
|
58
|
+
expect(xml.xpath('//label')[2].text).to match(/Image 3/)
|
59
|
+
expect(xml.xpath('//resource')[0].attributes['type'].value).to eq('image')
|
60
|
+
expect(xml.xpath('//resource')[1].attributes['type'].value).to eq('image')
|
61
|
+
expect(xml.xpath('//resource')[2].attributes['type'].value).to eq('image')
|
62
|
+
expect(xml.xpath('//resource/file')[0].attributes['publish'].value).to eq('no') # specificially set in object
|
63
|
+
expect(xml.xpath('//resource/file')[0].attributes['preserve'].value).to eq('no') # specificially set in object
|
64
|
+
expect(xml.xpath('//resource/file')[0].attributes['shelve'].value).to eq('no') # specificially set in object
|
65
|
+
expect(xml.xpath('//resource/file')[1].attributes['publish'].value).to eq('yes') # specificially set in object
|
66
|
+
expect(xml.xpath('//resource/file')[1].attributes['preserve'].value).to eq('yes') # specificially set in object
|
67
|
+
expect(xml.xpath('//resource/file')[1].attributes['shelve'].value).to eq('yes') # specificially set in object
|
68
|
+
expect(xml.xpath('//resource/file')[2].attributes['publish'].value).to eq('yes') # defaults by mimetype
|
69
|
+
expect(xml.xpath('//resource/file')[2].attributes['preserve'].value).to eq('no') # defaults by mimetype
|
70
|
+
expect(xml.xpath('//resource/file')[2].attributes['shelve'].value).to eq('yes') # defaults by mimetype
|
72
71
|
end
|
73
72
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:add_exif=>true,:add_file_attributes=>true,:objects=>objects)
|
73
|
+
it 'generates valid content metadata with exif for a single tif and jp2 of style=simple_image overriding file labels' do
|
74
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE, label: 'Sample tif label!'), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE, label: 'Sample jp2 label!')]
|
75
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, add_exif: true, add_file_attributes: true, objects: objects)
|
78
76
|
expect(result.class).to be String
|
79
77
|
xml = Nokogiri::XML(result)
|
80
78
|
expect(xml.errors.size).to be 0
|
81
|
-
expect(xml.xpath(
|
82
|
-
expect(xml.xpath(
|
83
|
-
expect(xml.xpath(
|
84
|
-
expect(xml.xpath(
|
85
|
-
expect(xml.xpath(
|
86
|
-
expect(xml.xpath(
|
87
|
-
expect(xml.xpath(
|
88
|
-
expect(xml.xpath(
|
89
|
-
expect(xml.xpath(
|
90
|
-
expect(xml.xpath(
|
91
|
-
expect(xml.xpath(
|
92
|
-
expect(xml.xpath(
|
93
|
-
expect(xml.xpath(
|
94
|
-
expect(xml.xpath(
|
95
|
-
expect(xml.xpath(
|
96
|
-
expect(xml.xpath(
|
97
|
-
expect(xml.xpath(
|
98
|
-
expect(xml.xpath(
|
99
|
-
expect(xml.xpath(
|
100
|
-
expect(xml.xpath(
|
101
|
-
expect(xml.xpath(
|
102
|
-
expect(xml.xpath(
|
103
|
-
expect(xml.xpath(
|
104
|
-
expect(xml.xpath(
|
105
|
-
expect(xml.xpath(
|
106
|
-
expect(xml.xpath(
|
107
|
-
expect(xml.xpath(
|
79
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
80
|
+
expect(xml.xpath('//resource').length).to be 2
|
81
|
+
expect(xml.xpath('//resource/file').length).to be 2
|
82
|
+
expect(xml.xpath('//resource/file/checksum').length).to be 4
|
83
|
+
expect(xml.xpath('//resource/file/checksum')[0].text).to eq('8d11fab63089a24c8b17063d29a4b0eac359fb41')
|
84
|
+
expect(xml.xpath('//resource/file/checksum')[1].text).to eq('a2400500acf21e43f5440d93be894101')
|
85
|
+
expect(xml.xpath('//resource/file/checksum')[2].text).to eq('b965b5787e0100ec2d43733144120feab327e88c')
|
86
|
+
expect(xml.xpath('//resource/file/checksum')[3].text).to eq('4eb54050d374291ece622d45e84f014d')
|
87
|
+
expect(xml.xpath('//label').length).to be 2
|
88
|
+
expect(xml.xpath('//label')[0].text).to match(/Sample tif label!/)
|
89
|
+
expect(xml.xpath('//label')[1].text).to match(/Sample jp2 label!/)
|
90
|
+
expect(xml.xpath('//resource')[0].attributes['type'].value).to eq('image')
|
91
|
+
expect(xml.xpath('//resource')[1].attributes['type'].value).to eq('image')
|
92
|
+
expect(xml.xpath('//resource/file')[0].attributes['size'].value).to eq('63542')
|
93
|
+
expect(xml.xpath('//resource/file')[0].attributes['mimetype'].value).to eq('image/tiff')
|
94
|
+
expect(xml.xpath('//resource/file')[0].attributes['publish'].value).to eq('no')
|
95
|
+
expect(xml.xpath('//resource/file')[0].attributes['preserve'].value).to eq('yes')
|
96
|
+
expect(xml.xpath('//resource/file')[0].attributes['shelve'].value).to eq('no')
|
97
|
+
expect(xml.xpath('//resource/file/imageData')[0].attributes['width'].value).to eq('100')
|
98
|
+
expect(xml.xpath('//resource/file/imageData')[0].attributes['height'].value).to eq('100')
|
99
|
+
expect(xml.xpath('//resource/file')[1].attributes['size'].value).to eq('306')
|
100
|
+
expect(xml.xpath('//resource/file')[1].attributes['mimetype'].value).to eq('image/jp2')
|
101
|
+
expect(xml.xpath('//resource/file')[1].attributes['publish'].value).to eq('yes')
|
102
|
+
expect(xml.xpath('//resource/file')[1].attributes['preserve'].value).to eq('no')
|
103
|
+
expect(xml.xpath('//resource/file')[1].attributes['shelve'].value).to eq('yes')
|
104
|
+
expect(xml.xpath('//resource/file/imageData')[1].attributes['width'].value).to eq('100')
|
105
|
+
expect(xml.xpath('//resource/file/imageData')[1].attributes['height'].value).to eq('100')
|
108
106
|
end
|
109
107
|
|
110
|
-
it
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
108
|
+
it 'generates valid content metadata with exif for a single tif and jp2 of style=simple_image overriding file labels for one, and skipping auto labels for the others or for where the label is set but is blank' do
|
109
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE, label: 'Sample tif label!'), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE, label: '')]
|
110
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, auto_labels: false, add_file_attributes: true, objects: objects)
|
111
|
+
expect(result.class).to be String
|
112
|
+
xml = Nokogiri::XML(result)
|
113
|
+
expect(xml.errors.size).to be 0
|
114
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
115
|
+
expect(xml.xpath('//resource').length).to be 3
|
116
|
+
expect(xml.xpath('//resource/file').length).to be 3
|
117
|
+
expect(xml.xpath('//label').length).to be 1
|
118
|
+
expect(xml.xpath('//label')[0].text).to match(/Sample tif label!/)
|
121
119
|
end
|
122
120
|
|
123
|
-
it
|
124
|
-
objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)]
|
125
|
-
result =
|
121
|
+
it 'generates valid content metadata for a single tif and jp2 of style=simple_image with overriding file attributes and no exif data' do
|
122
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)]
|
123
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, add_file_attributes: true, file_attributes: { 'image/tiff' => { publish: 'no', preserve: 'no', shelve: 'no' }, 'image/jp2' => { publish: 'yes', preserve: 'yes', shelve: 'yes' } }, objects: objects)
|
126
124
|
expect(result.class).to be String
|
127
125
|
xml = Nokogiri::XML(result)
|
128
126
|
expect(xml.errors.size).to be 0
|
129
|
-
expect(xml.xpath(
|
130
|
-
expect(xml.xpath(
|
131
|
-
expect(xml.xpath(
|
132
|
-
expect(xml.xpath(
|
133
|
-
expect(xml.xpath(
|
134
|
-
expect(xml.xpath(
|
135
|
-
expect(xml.xpath(
|
136
|
-
expect(xml.xpath(
|
137
|
-
expect(xml.xpath(
|
138
|
-
expect(xml.xpath(
|
139
|
-
expect(xml.xpath(
|
140
|
-
expect(xml.xpath(
|
141
|
-
expect(xml.xpath(
|
142
|
-
expect(xml.xpath(
|
143
|
-
expect(xml.xpath(
|
144
|
-
expect(xml.xpath(
|
145
|
-
expect(xml.xpath(
|
146
|
-
expect(xml.xpath(
|
147
|
-
expect(xml.xpath(
|
148
|
-
expect(xml.xpath(
|
149
|
-
expect(xml.xpath(
|
127
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
128
|
+
expect(xml.xpath('//resource').length).to be 2
|
129
|
+
expect(xml.xpath('//resource/file').length).to be 2
|
130
|
+
expect(xml.xpath('//label').length).to be 2
|
131
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
132
|
+
expect(xml.xpath('//label')[0].text).to match(/Image 1/)
|
133
|
+
expect(xml.xpath('//label')[1].text).to match(/Image 2/)
|
134
|
+
expect(xml.xpath('//resource')[0].attributes['type'].value).to eq('image')
|
135
|
+
expect(xml.xpath('//resource')[1].attributes['type'].value).to eq('image')
|
136
|
+
expect(xml.xpath('//resource/file')[0].attributes['size']).to be nil
|
137
|
+
expect(xml.xpath('//resource/file')[0].attributes['mimetype']).to be nil
|
138
|
+
expect(xml.xpath('//resource/file')[0].attributes['role']).to be nil
|
139
|
+
expect(xml.xpath('//resource/file')[0].attributes['publish'].value).to eq('no')
|
140
|
+
expect(xml.xpath('//resource/file')[0].attributes['preserve'].value).to eq('no')
|
141
|
+
expect(xml.xpath('//resource/file')[0].attributes['shelve'].value).to eq('no')
|
142
|
+
expect(xml.xpath('//resource/file')[1].attributes['size']).to be nil
|
143
|
+
expect(xml.xpath('//resource/file')[1].attributes['mimetype']).to be nil
|
144
|
+
expect(xml.xpath('//resource/file')[1].attributes['role']).to be nil
|
145
|
+
expect(xml.xpath('//resource/file')[1].attributes['publish'].value).to eq('yes')
|
146
|
+
expect(xml.xpath('//resource/file')[1].attributes['preserve'].value).to eq('yes')
|
147
|
+
expect(xml.xpath('//resource/file')[1].attributes['shelve'].value).to eq('yes')
|
150
148
|
end
|
151
149
|
|
152
|
-
it
|
153
|
-
objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)]
|
154
|
-
result =
|
150
|
+
it 'generates valid content metadata for a single tif and jp2 of style=simple_image with overriding file attributes, including a default value, and no exif data' do
|
151
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)]
|
152
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, add_file_attributes: true, file_attributes: { 'default' => { publish: 'yes', preserve: 'no', shelve: 'no' }, 'image/jp2' => { publish: 'yes', preserve: 'yes', shelve: 'yes' } }, objects: objects)
|
155
153
|
expect(result.class).to be String
|
156
154
|
xml = Nokogiri::XML(result)
|
157
155
|
expect(xml.errors.size).to be 0
|
158
|
-
expect(xml.xpath(
|
159
|
-
expect(xml.xpath(
|
160
|
-
expect(xml.xpath(
|
161
|
-
expect(xml.xpath(
|
162
|
-
expect(xml.xpath(
|
163
|
-
expect(xml.xpath(
|
164
|
-
expect(xml.xpath(
|
165
|
-
expect(xml.xpath(
|
166
|
-
expect(xml.xpath(
|
167
|
-
expect(xml.xpath(
|
168
|
-
|
169
|
-
expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 1
|
170
|
-
expect(xml.xpath(
|
171
|
-
expect(xml.xpath(
|
172
|
-
end
|
156
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
157
|
+
expect(xml.xpath('//resource/file').length).to be 2
|
158
|
+
expect(xml.xpath('//resource/file')[0].attributes['mimetype']).to be nil
|
159
|
+
expect(xml.xpath('//resource/file')[0].attributes['publish'].value).to eq('yes')
|
160
|
+
expect(xml.xpath('//resource/file')[0].attributes['preserve'].value).to eq('no')
|
161
|
+
expect(xml.xpath('//resource/file')[0].attributes['shelve'].value).to eq('no')
|
162
|
+
expect(xml.xpath('//resource/file')[1].attributes['mimetype']).to be nil
|
163
|
+
expect(xml.xpath('//resource/file')[1].attributes['publish'].value).to eq('yes')
|
164
|
+
expect(xml.xpath('//resource/file')[1].attributes['preserve'].value).to eq('yes')
|
165
|
+
expect(xml.xpath('//resource/file')[1].attributes['shelve'].value).to eq('yes')
|
166
|
+
(0..1).each do |i|
|
167
|
+
expect(xml.xpath("//resource[@sequence='#{i + 1}']/file").length).to be 1
|
168
|
+
expect(xml.xpath('//label')[i].text).to eq("Image #{i + 1}")
|
169
|
+
expect(xml.xpath('//resource')[i].attributes['type'].value).to eq('image')
|
170
|
+
end
|
173
171
|
end
|
174
172
|
|
175
|
-
it
|
176
|
-
objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)]
|
177
|
-
result =
|
173
|
+
it 'generates valid content metadata for a single tif and jp2 of style=map with overriding file attributes, including a default value, and no exif data' do
|
174
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)]
|
175
|
+
result = described_class.create_content_metadata(style: :map, druid: TEST_DRUID, add_file_attributes: true, file_attributes: { 'default' => { publish: 'yes', preserve: 'no', shelve: 'no' }, 'image/jp2' => { publish: 'yes', preserve: 'yes', shelve: 'yes' } }, objects: objects)
|
178
176
|
expect(result.class).to be String
|
179
177
|
xml = Nokogiri::XML(result)
|
180
178
|
expect(xml.errors.size).to be 0
|
181
|
-
expect(xml.xpath(
|
182
|
-
expect(xml.xpath(
|
183
|
-
expect(xml.xpath(
|
184
|
-
expect(xml.xpath(
|
185
|
-
expect(xml.xpath(
|
186
|
-
expect(xml.xpath(
|
187
|
-
expect(xml.xpath(
|
188
|
-
expect(xml.xpath(
|
189
|
-
expect(xml.xpath(
|
190
|
-
expect(xml.xpath(
|
191
|
-
|
192
|
-
expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 1
|
193
|
-
expect(xml.xpath(
|
194
|
-
expect(xml.xpath(
|
179
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('map')
|
180
|
+
expect(xml.xpath('//resource/file').length).to be 2
|
181
|
+
expect(xml.xpath('//resource/file')[0].attributes['mimetype']).to be nil
|
182
|
+
expect(xml.xpath('//resource/file')[0].attributes['publish'].value).to eq('yes')
|
183
|
+
expect(xml.xpath('//resource/file')[0].attributes['preserve'].value).to eq('no')
|
184
|
+
expect(xml.xpath('//resource/file')[0].attributes['shelve'].value).to eq('no')
|
185
|
+
expect(xml.xpath('//resource/file')[1].attributes['mimetype']).to be nil
|
186
|
+
expect(xml.xpath('//resource/file')[1].attributes['publish'].value).to eq('yes')
|
187
|
+
expect(xml.xpath('//resource/file')[1].attributes['preserve'].value).to eq('yes')
|
188
|
+
expect(xml.xpath('//resource/file')[1].attributes['shelve'].value).to eq('yes')
|
189
|
+
(0..1).each do |i|
|
190
|
+
expect(xml.xpath("//resource[@sequence='#{i + 1}']/file").length).to be 1
|
191
|
+
expect(xml.xpath('//label')[i].text).to eq("Image #{i + 1}")
|
192
|
+
expect(xml.xpath('//resource')[i].attributes['type'].value).to eq('image')
|
195
193
|
end
|
196
194
|
end
|
197
195
|
|
198
|
-
it
|
199
|
-
objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)]
|
200
|
-
result =
|
196
|
+
it 'generates valid content metadata for two tifs two associated jp2s of style=simple_image using bundle=filename and no exif data' do
|
197
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE), Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)]
|
198
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, bundle: :filename, objects: objects)
|
201
199
|
expect(result.class).to be String
|
202
200
|
xml = Nokogiri::XML(result)
|
203
201
|
expect(xml.errors.size).to be 0
|
204
|
-
expect(xml.xpath(
|
205
|
-
expect(xml.xpath(
|
206
|
-
expect(xml.xpath(
|
202
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
203
|
+
expect(xml.xpath('//resource').length).to be 2
|
204
|
+
expect(xml.xpath('//resource/file').length).to be 4
|
207
205
|
expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq('test.tif')
|
208
206
|
expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq('test.jp2')
|
209
207
|
expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq('test2.tif')
|
210
208
|
expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq('test2.jp2')
|
211
|
-
expect(xml.xpath(
|
212
|
-
expect(xml.xpath(
|
213
|
-
|
214
|
-
expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 2
|
215
|
-
expect(xml.xpath(
|
216
|
-
expect(xml.xpath(
|
209
|
+
expect(xml.xpath('//label').length).to be 2
|
210
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
211
|
+
(0..1).each do |i|
|
212
|
+
expect(xml.xpath("//resource[@sequence='#{i + 1}']/file").length).to be 2
|
213
|
+
expect(xml.xpath('//label')[i].text).to eq("Image #{i + 1}")
|
214
|
+
expect(xml.xpath('//resource')[i].attributes['type'].value).to eq('image')
|
217
215
|
end
|
218
216
|
end
|
219
217
|
|
220
|
-
it
|
221
|
-
objects=[Assembly::ObjectFile.new(TEST_DPG_TIF),Assembly::ObjectFile.new(TEST_DPG_JP),Assembly::ObjectFile.new(TEST_DPG_TIF2),Assembly::ObjectFile.new(TEST_DPG_JP2)]
|
222
|
-
test_druid=
|
223
|
-
result =
|
218
|
+
it 'generates valid content metadata for two tifs two associated jp2s of style=simple_image using bundle=dpg and no exif data and no root xml node' do
|
219
|
+
objects = [Assembly::ObjectFile.new(TEST_DPG_TIF), Assembly::ObjectFile.new(TEST_DPG_JP), Assembly::ObjectFile.new(TEST_DPG_TIF2), Assembly::ObjectFile.new(TEST_DPG_JP2)]
|
220
|
+
test_druid = TEST_DRUID.to_s
|
221
|
+
result = described_class.create_content_metadata(druid: test_druid, bundle: :dpg, objects: objects, include_root_xml: false)
|
224
222
|
expect(result.class).to be String
|
225
|
-
expect(result.include?('<?xml')).to be false
|
223
|
+
expect(result.include?('<?xml')).to be false
|
226
224
|
xml = Nokogiri::XML(result)
|
227
225
|
expect(xml.errors.size).to be 0
|
228
|
-
expect(xml.xpath(
|
226
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
229
227
|
expect(test_druid).to eq(TEST_DRUID)
|
230
|
-
expect(xml.xpath(
|
231
|
-
expect(xml.xpath(
|
232
|
-
expect(xml.xpath(
|
233
|
-
expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq(
|
234
|
-
expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq(
|
235
|
-
expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq(
|
236
|
-
expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq(
|
237
|
-
expect(xml.xpath(
|
238
|
-
expect(xml.xpath(
|
239
|
-
|
240
|
-
expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 2
|
241
|
-
expect(xml.xpath(
|
242
|
-
expect(xml.xpath(
|
228
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['objectId'].value).to eq(TEST_DRUID.to_s)
|
229
|
+
expect(xml.xpath('//resource').length).to be 2
|
230
|
+
expect(xml.xpath('//resource/file').length).to be 4
|
231
|
+
expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq('00/oo000oo0001_00_001.tif')
|
232
|
+
expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq('05/oo000oo0001_05_001.jp2')
|
233
|
+
expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq('00/oo000oo0001_00_002.tif')
|
234
|
+
expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq('05/oo000oo0001_05_002.jp2')
|
235
|
+
expect(xml.xpath('//label').length).to be 2
|
236
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
237
|
+
(0..1).each do |i|
|
238
|
+
expect(xml.xpath("//resource[@sequence='#{i + 1}']/file").length).to be 2
|
239
|
+
expect(xml.xpath('//label')[i].text).to eq("Image #{i + 1}")
|
240
|
+
expect(xml.xpath('//resource')[i].attributes['type'].value).to eq('image')
|
243
241
|
end
|
244
242
|
end
|
245
243
|
|
246
|
-
it
|
247
|
-
objects=[Assembly::ObjectFile.new(TEST_DPG_SPECIAL_PDF2),Assembly::ObjectFile.new(TEST_DPG_SPECIAL_TIF),Assembly::ObjectFile.new(TEST_DPG_TIF),Assembly::ObjectFile.new(TEST_DPG_JP),Assembly::ObjectFile.new(TEST_DPG_TIF2),Assembly::ObjectFile.new(TEST_DPG_JP2)]
|
248
|
-
result =
|
244
|
+
it 'generates valid content metadata for two tifs, two associated jp2s, one combined pdf and one special tif of style=simple_book using bundle=dpg and no exif data and no root xml node, flattening folder structure' do
|
245
|
+
objects = [Assembly::ObjectFile.new(TEST_DPG_SPECIAL_PDF2), Assembly::ObjectFile.new(TEST_DPG_SPECIAL_TIF), Assembly::ObjectFile.new(TEST_DPG_TIF), Assembly::ObjectFile.new(TEST_DPG_JP), Assembly::ObjectFile.new(TEST_DPG_TIF2), Assembly::ObjectFile.new(TEST_DPG_JP2)]
|
246
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, style: :simple_book, bundle: :dpg, objects: objects, include_root_xml: false, flatten_folder_structure: true)
|
249
247
|
expect(result.class).to be String
|
250
|
-
expect(result.include?('<?xml')).to be false
|
248
|
+
expect(result.include?('<?xml')).to be false
|
251
249
|
xml = Nokogiri::XML(result)
|
252
250
|
expect(xml.errors.size).to be 0
|
253
|
-
expect(xml.xpath(
|
254
|
-
expect(xml.xpath(
|
255
|
-
expect(xml.xpath(
|
256
|
-
expect(xml.xpath(
|
257
|
-
expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq(
|
258
|
-
expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq(
|
259
|
-
expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq(
|
260
|
-
expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq(
|
261
|
-
expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq(
|
262
|
-
expect(xml.xpath("//resource[@sequence='4']/file")[0].attributes['id'].value).to eq(
|
263
|
-
expect(xml.xpath(
|
264
|
-
expect(xml.xpath(
|
265
|
-
|
266
|
-
expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 2
|
267
|
-
expect(xml.xpath(
|
268
|
-
expect(xml.xpath(
|
251
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('book')
|
252
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['objectId'].value).to eq(TEST_DRUID.to_s)
|
253
|
+
expect(xml.xpath('//resource').length).to be 4
|
254
|
+
expect(xml.xpath('//resource/file').length).to be 6
|
255
|
+
expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq('oo000oo0001_00_001.tif')
|
256
|
+
expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq('oo000oo0001_05_001.jp2')
|
257
|
+
expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq('oo000oo0001_00_002.tif')
|
258
|
+
expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq('oo000oo0001_05_002.jp2')
|
259
|
+
expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq('oo000oo0001_31_001.pdf')
|
260
|
+
expect(xml.xpath("//resource[@sequence='4']/file")[0].attributes['id'].value).to eq('oo000oo0001_50_001.tif')
|
261
|
+
expect(xml.xpath('//label').length).to be 4
|
262
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
263
|
+
(0..1).each do |i|
|
264
|
+
expect(xml.xpath("//resource[@sequence='#{i + 1}']/file").length).to be 2
|
265
|
+
expect(xml.xpath('//label')[i].text).to eq("Page #{i + 1}")
|
266
|
+
expect(xml.xpath('//resource')[i].attributes['type'].value).to eq('page')
|
269
267
|
end
|
270
268
|
expect(xml.xpath("//resource[@sequence='3']/file").length).to be 1
|
271
|
-
expect(xml.xpath(
|
272
|
-
expect(xml.xpath(
|
269
|
+
expect(xml.xpath('//label')[2].text).to eq('Object 1')
|
270
|
+
expect(xml.xpath('//resource')[2].attributes['type'].value).to eq('object')
|
273
271
|
expect(xml.xpath("//resource[@sequence='4']/file").length).to be 1
|
274
|
-
expect(xml.xpath(
|
275
|
-
expect(xml.xpath(
|
272
|
+
expect(xml.xpath('//label')[3].text).to eq('Object 2')
|
273
|
+
expect(xml.xpath('//resource')[3].attributes['type'].value).to eq('object')
|
276
274
|
end
|
277
|
-
|
278
|
-
it "
|
279
|
-
objects=[Assembly::ObjectFile.new(TEST_DPG_TIF),Assembly::ObjectFile.new(TEST_DPG_JP),Assembly::ObjectFile.new(TEST_DPG_PDF),Assembly::ObjectFile.new(TEST_DPG_TIF2),Assembly::ObjectFile.new(TEST_DPG_JP2),Assembly::ObjectFile.new(TEST_DPG_PDF2),Assembly::ObjectFile.new(TEST_DPG_SPECIAL_PDF1)]
|
280
|
-
test_druid="druid:#{TEST_DRUID}"
|
281
|
-
result =
|
275
|
+
|
276
|
+
it "generates valid content metadata with item having a 'druid:' prefix for two tifs,two associated jp2s,two associated pdfs, and one lingering PDF of style=simple_book using bundle=dpg, flattening folder structure" do
|
277
|
+
objects = [Assembly::ObjectFile.new(TEST_DPG_TIF), Assembly::ObjectFile.new(TEST_DPG_JP), Assembly::ObjectFile.new(TEST_DPG_PDF), Assembly::ObjectFile.new(TEST_DPG_TIF2), Assembly::ObjectFile.new(TEST_DPG_JP2), Assembly::ObjectFile.new(TEST_DPG_PDF2), Assembly::ObjectFile.new(TEST_DPG_SPECIAL_PDF1)]
|
278
|
+
test_druid = "druid:#{TEST_DRUID}"
|
279
|
+
result = described_class.create_content_metadata(druid: test_druid, bundle: :dpg, objects: objects, style: :simple_book, flatten_folder_structure: true)
|
282
280
|
expect(result.class).to be String
|
283
281
|
expect(result.include?('<?xml')).to be true
|
284
282
|
xml = Nokogiri::XML(result)
|
285
283
|
expect(xml.errors.size).to be 0
|
286
|
-
expect(xml.xpath(
|
287
|
-
expect(xml.xpath(
|
284
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('book')
|
285
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['objectId'].value).to eq(test_druid)
|
288
286
|
expect(test_druid).to eq("druid:#{TEST_DRUID}")
|
289
|
-
expect(xml.xpath(
|
290
|
-
expect(xml.xpath(
|
291
|
-
|
292
|
-
expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq(
|
293
|
-
expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq(
|
294
|
-
expect(xml.xpath("//resource[@sequence='1']/file")[2].attributes['id'].value).to eq(
|
295
|
-
expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq(
|
296
|
-
expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq(
|
297
|
-
expect(xml.xpath("//resource[@sequence='2']/file")[2].attributes['id'].value).to eq(
|
298
|
-
expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq(
|
299
|
-
expect(xml.xpath(
|
300
|
-
expect(xml.xpath(
|
301
|
-
|
302
|
-
expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 3
|
303
|
-
expect(xml.xpath(
|
304
|
-
expect(xml.xpath(
|
287
|
+
expect(xml.xpath('//resource').length).to be 3
|
288
|
+
expect(xml.xpath('//resource/file').length).to be 7
|
289
|
+
|
290
|
+
expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq('oo000oo0001_00_001.tif')
|
291
|
+
expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq('oo000oo0001_05_001.jp2')
|
292
|
+
expect(xml.xpath("//resource[@sequence='1']/file")[2].attributes['id'].value).to eq('oo000oo0001_15_001.pdf')
|
293
|
+
expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq('oo000oo0001_00_002.tif')
|
294
|
+
expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq('oo000oo0001_05_002.jp2')
|
295
|
+
expect(xml.xpath("//resource[@sequence='2']/file")[2].attributes['id'].value).to eq('oo000oo0001_15_002.pdf')
|
296
|
+
expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq('oo000oo0001_book.pdf')
|
297
|
+
expect(xml.xpath('//label').length).to be 3
|
298
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
299
|
+
(0..1).each do |i|
|
300
|
+
expect(xml.xpath("//resource[@sequence='#{i + 1}']/file").length).to be 3
|
301
|
+
expect(xml.xpath('//label')[i].text).to eq("Page #{i + 1}")
|
302
|
+
expect(xml.xpath('//resource')[i].attributes['type'].value).to eq('page')
|
305
303
|
end
|
306
304
|
expect(xml.xpath("//resource[@sequence='3']/file").length).to be 1
|
307
|
-
expect(xml.xpath(
|
308
|
-
expect(xml.xpath(
|
305
|
+
expect(xml.xpath('//label')[2].text).to eq('Object 1')
|
306
|
+
expect(xml.xpath('//resource')[2].attributes['type'].value).to eq('object')
|
309
307
|
end
|
310
308
|
|
311
|
-
it
|
312
|
-
objects=[Assembly::ObjectFile.new(TEST_DPG_TIF),Assembly::ObjectFile.new(TEST_DPG_JP),Assembly::ObjectFile.new(TEST_DPG_PDF),Assembly::ObjectFile.new(TEST_DPG_TIF2),Assembly::ObjectFile.new(TEST_DPG_JP2),Assembly::ObjectFile.new(TEST_DPG_SPECIAL_PDF1)]
|
313
|
-
result =
|
309
|
+
it 'generates valid content metadata for two tifs,two associated jp2s,two associated pdfs, and one lingering PDF of style=book_with_pdf using bundle=dpg' do
|
310
|
+
objects = [Assembly::ObjectFile.new(TEST_DPG_TIF), Assembly::ObjectFile.new(TEST_DPG_JP), Assembly::ObjectFile.new(TEST_DPG_PDF), Assembly::ObjectFile.new(TEST_DPG_TIF2), Assembly::ObjectFile.new(TEST_DPG_JP2), Assembly::ObjectFile.new(TEST_DPG_SPECIAL_PDF1)]
|
311
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, bundle: :dpg, objects: objects, style: :book_with_pdf)
|
314
312
|
expect(result.class).to be String
|
315
313
|
xml = Nokogiri::XML(result)
|
316
314
|
expect(xml.errors.size).to be 0
|
317
|
-
expect(xml.xpath(
|
318
|
-
expect(xml.xpath(
|
319
|
-
expect(xml.xpath(
|
320
|
-
expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq(
|
321
|
-
expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq(
|
322
|
-
expect(xml.xpath("//resource[@sequence='1']/file")[2].attributes['id'].value).to eq(
|
323
|
-
expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq(
|
324
|
-
expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq(
|
325
|
-
expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq(
|
326
|
-
expect(xml.xpath(
|
327
|
-
expect(xml.xpath(
|
315
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('book')
|
316
|
+
expect(xml.xpath('//resource').length).to be 3
|
317
|
+
expect(xml.xpath('//resource/file').length).to be 6
|
318
|
+
expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq('00/oo000oo0001_00_001.tif')
|
319
|
+
expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq('05/oo000oo0001_05_001.jp2')
|
320
|
+
expect(xml.xpath("//resource[@sequence='1']/file")[2].attributes['id'].value).to eq('15/oo000oo0001_15_001.pdf')
|
321
|
+
expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq('00/oo000oo0001_00_002.tif')
|
322
|
+
expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq('05/oo000oo0001_05_002.jp2')
|
323
|
+
expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq('oo000oo0001_book.pdf')
|
324
|
+
expect(xml.xpath('//label').length).to be 3
|
325
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
328
326
|
expect(xml.xpath("//resource[@sequence='1']/file").length).to be 3
|
329
|
-
expect(xml.xpath(
|
330
|
-
expect(xml.xpath(
|
327
|
+
expect(xml.xpath('//label')[0].text).to eq('Object 1')
|
328
|
+
expect(xml.xpath('//resource')[0].attributes['type'].value).to eq('object')
|
331
329
|
expect(xml.xpath("//resource[@sequence='2']/file").length).to be 2
|
332
|
-
expect(xml.xpath(
|
333
|
-
expect(xml.xpath(
|
330
|
+
expect(xml.xpath('//label')[1].text).to eq('Page 1')
|
331
|
+
expect(xml.xpath('//resource')[1].attributes['type'].value).to eq('page')
|
334
332
|
expect(xml.xpath("//resource[@sequence='3']/file").length).to be 1
|
335
|
-
expect(xml.xpath(
|
336
|
-
expect(xml.xpath(
|
333
|
+
expect(xml.xpath('//label')[2].text).to eq('Object 2')
|
334
|
+
expect(xml.xpath('//resource')[2].attributes['type'].value).to eq('object')
|
337
335
|
end
|
338
|
-
|
339
|
-
it
|
340
|
-
objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)]
|
341
|
-
result =
|
336
|
+
|
337
|
+
it 'generates valid content metadata for two tifs two associated jp2s of style=simple_image using bundle=default and no exif data' do
|
338
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE), Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)]
|
339
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, bundle: :default, objects: objects)
|
342
340
|
expect(result.class).to be String
|
343
341
|
xml = Nokogiri::XML(result)
|
344
342
|
expect(xml.errors.size).to be 0
|
345
|
-
expect(xml.xpath(
|
346
|
-
expect(xml.xpath(
|
347
|
-
expect(xml.xpath(
|
348
|
-
expect(xml.xpath(
|
349
|
-
expect(xml.xpath(
|
350
|
-
expect(xml.xpath(
|
351
|
-
expect(xml.xpath(
|
352
|
-
expect(xml.xpath(
|
353
|
-
expect(xml.xpath(
|
354
|
-
|
355
|
-
expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 1
|
356
|
-
expect(xml.xpath(
|
357
|
-
expect(xml.xpath(
|
343
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
344
|
+
expect(xml.xpath('//resource').length).to be 4
|
345
|
+
expect(xml.xpath('//resource/file').length).to be 4
|
346
|
+
expect(xml.xpath('//resource/file')[0].attributes['id'].value).to eq('test.tif')
|
347
|
+
expect(xml.xpath('//resource/file')[1].attributes['id'].value).to eq('test.jp2')
|
348
|
+
expect(xml.xpath('//resource/file')[2].attributes['id'].value).to eq('test2.tif')
|
349
|
+
expect(xml.xpath('//resource/file')[3].attributes['id'].value).to eq('test2.jp2')
|
350
|
+
expect(xml.xpath('//label').length).to be 4
|
351
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
352
|
+
(0..3).each do |i|
|
353
|
+
expect(xml.xpath("//resource[@sequence='#{i + 1}']/file").length).to be 1
|
354
|
+
expect(xml.xpath('//label')[i].text).to eq("Image #{i + 1}")
|
355
|
+
expect(xml.xpath('//resource')[i].attributes['type'].value).to eq('image')
|
358
356
|
end
|
359
357
|
end
|
360
358
|
|
361
|
-
it
|
362
|
-
objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)]
|
363
|
-
result =
|
359
|
+
it 'generates valid content metadata for two tifs two associated jp2s of style=simple_image using bundle=default and no exif data, preserving full paths' do
|
360
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE), Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)]
|
361
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, bundle: :default, objects: objects, preserve_common_paths: true)
|
364
362
|
expect(result.class).to be String
|
365
363
|
xml = Nokogiri::XML(result)
|
366
364
|
expect(xml.errors.size).to be 0
|
367
|
-
expect(xml.xpath(
|
368
|
-
expect(xml.xpath(
|
369
|
-
expect(xml.xpath(
|
365
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
366
|
+
expect(xml.xpath('//resource').length).to be 4
|
367
|
+
expect(xml.xpath('//resource/file').length).to be 4
|
370
368
|
expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq(TEST_TIF_INPUT_FILE)
|
371
369
|
expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq(TEST_JP2_INPUT_FILE)
|
372
370
|
expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq(TEST_TIF_INPUT_FILE2)
|
373
|
-
expect(xml.xpath("//resource[@sequence='4']/file")[0].attributes['id'].value).to eq(TEST_JP2_INPUT_FILE2)
|
374
|
-
expect(xml.xpath(
|
375
|
-
expect(xml.xpath(
|
376
|
-
|
377
|
-
expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 1
|
378
|
-
expect(xml.xpath(
|
379
|
-
expect(xml.xpath(
|
371
|
+
expect(xml.xpath("//resource[@sequence='4']/file")[0].attributes['id'].value).to eq(TEST_JP2_INPUT_FILE2)
|
372
|
+
expect(xml.xpath('//label').length).to be 4
|
373
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
374
|
+
(0..3).each do |i|
|
375
|
+
expect(xml.xpath("//resource[@sequence='#{i + 1}']/file").length).to be 1
|
376
|
+
expect(xml.xpath('//label')[i].text).to eq("Image #{i + 1}")
|
377
|
+
expect(xml.xpath('//resource')[i].attributes['type'].value).to eq('image')
|
380
378
|
end
|
381
379
|
end
|
382
|
-
|
383
|
-
it
|
384
|
-
objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)]
|
385
|
-
objects[0].relative_path='input/test.tif'
|
386
|
-
objects[1].relative_path='input/test.jp2'
|
387
|
-
objects[2].relative_path='input/test2.tif'
|
388
|
-
objects[3].relative_path='input/test2.jp2'
|
389
|
-
result =
|
380
|
+
|
381
|
+
it 'generates valid content metadata for two tifs two associated jp2s of style=file using specific content metadata paths' do
|
382
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE), Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2), Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)]
|
383
|
+
objects[0].relative_path = 'input/test.tif'
|
384
|
+
objects[1].relative_path = 'input/test.jp2'
|
385
|
+
objects[2].relative_path = 'input/test2.tif'
|
386
|
+
objects[3].relative_path = 'input/test2.jp2'
|
387
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, style: :file, objects: objects)
|
390
388
|
expect(result.class).to be String
|
391
389
|
xml = Nokogiri::XML(result)
|
392
390
|
expect(xml.errors.size).to be 0
|
393
|
-
expect(xml.xpath(
|
394
|
-
expect(xml.xpath(
|
395
|
-
expect(xml.xpath(
|
396
|
-
expect(xml.xpath(
|
397
|
-
expect(xml.xpath(
|
398
|
-
expect(xml.xpath(
|
399
|
-
expect(xml.xpath(
|
400
|
-
expect(xml.xpath(
|
401
|
-
|
402
|
-
expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 1
|
403
|
-
expect(xml.xpath(
|
404
|
-
expect(xml.xpath(
|
391
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('file')
|
392
|
+
expect(xml.xpath('//resource').length).to be 4
|
393
|
+
expect(xml.xpath('//resource/file').length).to be 4
|
394
|
+
expect(xml.xpath('//label').length).to be 4
|
395
|
+
expect(xml.xpath('//resource/file')[0].attributes['id'].value).to eq('input/test.tif')
|
396
|
+
expect(xml.xpath('//resource/file')[1].attributes['id'].value).to eq('input/test.jp2')
|
397
|
+
expect(xml.xpath('//resource/file')[2].attributes['id'].value).to eq('input/test2.tif')
|
398
|
+
expect(xml.xpath('//resource/file')[3].attributes['id'].value).to eq('input/test2.jp2')
|
399
|
+
(0..3).each do |i|
|
400
|
+
expect(xml.xpath("//resource[@sequence='#{i + 1}']/file").length).to be 1
|
401
|
+
expect(xml.xpath('//label')[i].text).to eq("File #{i + 1}")
|
402
|
+
expect(xml.xpath('//resource')[i].attributes['type'].value).to eq('file')
|
405
403
|
end
|
406
404
|
end
|
407
|
-
|
408
|
-
it
|
409
|
-
objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2)]
|
410
|
-
result =
|
405
|
+
|
406
|
+
it 'generates valid content metadata for two tifs of style=simple_book' do
|
407
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2)]
|
408
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, style: :simple_book, objects: objects)
|
411
409
|
expect(result.class).to be String
|
412
410
|
xml = Nokogiri::XML(result)
|
413
411
|
expect(xml.errors.size).to be 0
|
414
|
-
expect(xml.xpath(
|
415
|
-
expect(xml.xpath(
|
416
|
-
expect(xml.xpath(
|
417
|
-
expect(xml.xpath(
|
418
|
-
expect(xml.xpath(
|
419
|
-
expect(xml.xpath(
|
420
|
-
expect(xml.xpath(
|
421
|
-
|
422
|
-
expect(xml.xpath(
|
423
|
-
expect(xml.xpath(
|
424
|
-
expect(xml.xpath(
|
425
|
-
expect(xml.xpath(
|
426
|
-
expect(xml.xpath(
|
412
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('book')
|
413
|
+
expect(xml.xpath('//resource').length).to be 2
|
414
|
+
expect(xml.xpath('//resource/file').length).to be 2
|
415
|
+
expect(xml.xpath('//label').length).to be 2
|
416
|
+
expect(xml.xpath('//label')[0].text).to match(/Page 1/)
|
417
|
+
expect(xml.xpath('//label')[1].text).to match(/Page 2/)
|
418
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
419
|
+
(0..1).each do |i|
|
420
|
+
expect(xml.xpath('//resource/file')[i].attributes['size']).to be nil
|
421
|
+
expect(xml.xpath('//resource/file')[i].attributes['mimetype']).to be nil
|
422
|
+
expect(xml.xpath('//resource/file')[i].attributes['publish']).to be nil
|
423
|
+
expect(xml.xpath('//resource/file')[i].attributes['preserve']).to be nil
|
424
|
+
expect(xml.xpath('//resource/file')[i].attributes['shelve']).to be nil
|
427
425
|
end
|
428
|
-
expect(xml.xpath(
|
429
|
-
expect(xml.xpath(
|
426
|
+
expect(xml.xpath('//resource')[0].attributes['type'].value).to eq('page')
|
427
|
+
expect(xml.xpath('//resource')[1].attributes['type'].value).to eq('page')
|
430
428
|
end
|
431
429
|
|
432
|
-
it
|
433
|
-
objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2),Assembly::ObjectFile.new(TEST_PDF_FILE)]
|
434
|
-
result =
|
430
|
+
it 'generates valid content metadata for two tifs and one pdf of style=book_with_pdf' do
|
431
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2), Assembly::ObjectFile.new(TEST_PDF_FILE)]
|
432
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, style: :book_with_pdf, objects: objects)
|
435
433
|
expect(result.class).to be String
|
436
434
|
xml = Nokogiri::XML(result)
|
437
435
|
expect(xml.errors.size).to be 0
|
438
|
-
expect(xml.xpath(
|
439
|
-
expect(xml.xpath(
|
440
|
-
expect(xml.xpath(
|
441
|
-
expect(xml.xpath(
|
442
|
-
expect(xml.xpath(
|
443
|
-
expect(xml.xpath(
|
444
|
-
expect(xml.xpath(
|
445
|
-
expect(xml.xpath(
|
446
|
-
expect(xml.xpath(
|
447
|
-
expect(xml.xpath(
|
448
|
-
expect(xml.xpath(
|
436
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('book')
|
437
|
+
expect(xml.xpath('//resource').length).to be 3
|
438
|
+
expect(xml.xpath('//resource/file').length).to be 3
|
439
|
+
expect(xml.xpath('//label').length).to be 3
|
440
|
+
expect(xml.xpath('//label')[0].text).to match(/Page 1/)
|
441
|
+
expect(xml.xpath('//label')[1].text).to match(/Page 2/)
|
442
|
+
expect(xml.xpath('//label')[2].text).to match(/Object 1/)
|
443
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
444
|
+
expect(xml.xpath('//resource')[0].attributes['type'].value).to eq('page')
|
445
|
+
expect(xml.xpath('//resource')[1].attributes['type'].value).to eq('page')
|
446
|
+
expect(xml.xpath('//resource')[2].attributes['type'].value).to eq('object')
|
449
447
|
end
|
450
|
-
|
451
|
-
it "should generate valid content metadata for two tifs of style=book_as_image" do
|
452
|
-
objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2)]
|
453
|
-
result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:style=>:book_as_image,:objects=>objects)
|
454
|
-
expect(result.class).to be String
|
455
|
-
xml = Nokogiri::XML(result)
|
456
|
-
expect(xml.errors.size).to be 0
|
457
|
-
expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("book")
|
458
|
-
expect(xml.xpath("//resource").length).to be 2
|
459
|
-
expect(xml.xpath("//resource/file").length).to be 2
|
460
|
-
expect(xml.xpath("//label").length).to be 2
|
461
|
-
expect(xml.xpath("//label")[0].text).to match(/Image 1/)
|
462
|
-
expect(xml.xpath("//label")[1].text).to match(/Image 2/)
|
463
|
-
expect(xml.xpath("//resource/file/imageData").length).to be 0
|
464
|
-
for i in 0..1 do
|
465
|
-
expect(xml.xpath("//resource/file")[i].attributes['size']).to be nil
|
466
|
-
expect(xml.xpath("//resource/file")[i].attributes['mimetype']).to be nil
|
467
|
-
expect(xml.xpath("//resource/file")[i].attributes['publish']).to be nil
|
468
|
-
expect(xml.xpath("//resource/file")[i].attributes['preserve']).to be nil
|
469
|
-
expect(xml.xpath("//resource/file")[i].attributes['shelve']).to be nil
|
470
|
-
end
|
471
|
-
expect(xml.xpath("//resource")[0].attributes['type'].value).to eq("image")
|
472
|
-
expect(xml.xpath("//resource")[1].attributes['type'].value).to eq("image")
|
473
|
-
end
|
474
448
|
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
for i in 0..1 do
|
498
|
-
expect(xml.xpath("//resource/file")[i].attributes['size']).to be nil
|
499
|
-
expect(xml.xpath("//resource/file")[i].attributes['mimetype']).to be nil
|
500
|
-
expect(xml.xpath("//resource/file")[i].attributes['publish']).to be nil
|
501
|
-
expect(xml.xpath("//resource/file")[i].attributes['preserve']).to be nil
|
502
|
-
expect(xml.xpath("//resource/file")[i].attributes['shelve']).to be nil
|
503
|
-
end
|
504
|
-
expect(xml.xpath("//resource")[0].attributes['type'].value).to eq("page")
|
505
|
-
expect(xml.xpath("//resource")[1].attributes['type'].value).to eq("page")
|
506
|
-
end
|
507
|
-
|
508
|
-
it "should not generate valid content metadata if not all input files exist" do
|
509
|
-
expect(File.exists?(TEST_TIF_INPUT_FILE)).to be true
|
510
|
-
junk_file='/tmp/flim_flam_floom.jp2'
|
511
|
-
expect(File.exists?(junk_file)).to be false
|
512
|
-
objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(junk_file)]
|
513
|
-
expect {Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:objects=>objects)}.to raise_error(RuntimeError,"File '#{junk_file}' not found")
|
449
|
+
it 'generates valid content metadata for two tifs of style=book_as_image' do
|
450
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2)]
|
451
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, style: :book_as_image, objects: objects)
|
452
|
+
expect(result.class).to be String
|
453
|
+
xml = Nokogiri::XML(result)
|
454
|
+
expect(xml.errors.size).to be 0
|
455
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('book')
|
456
|
+
expect(xml.xpath('//resource').length).to be 2
|
457
|
+
expect(xml.xpath('//resource/file').length).to be 2
|
458
|
+
expect(xml.xpath('//label').length).to be 2
|
459
|
+
expect(xml.xpath('//label')[0].text).to match(/Image 1/)
|
460
|
+
expect(xml.xpath('//label')[1].text).to match(/Image 2/)
|
461
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
462
|
+
(0..1).each do |i|
|
463
|
+
expect(xml.xpath('//resource/file')[i].attributes['size']).to be nil
|
464
|
+
expect(xml.xpath('//resource/file')[i].attributes['mimetype']).to be nil
|
465
|
+
expect(xml.xpath('//resource/file')[i].attributes['publish']).to be nil
|
466
|
+
expect(xml.xpath('//resource/file')[i].attributes['preserve']).to be nil
|
467
|
+
expect(xml.xpath('//resource/file')[i].attributes['shelve']).to be nil
|
468
|
+
end
|
469
|
+
expect(xml.xpath('//resource')[0].attributes['type'].value).to eq('image')
|
470
|
+
expect(xml.xpath('//resource')[1].attributes['type'].value).to eq('image')
|
514
471
|
end
|
515
472
|
|
516
|
-
it
|
517
|
-
|
518
|
-
|
519
|
-
|
473
|
+
it 'generates valid content metadata with no exif but with user supplied checksums for two tifs of style=simple_book' do
|
474
|
+
obj1 = Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
|
475
|
+
obj1.provider_md5 = '123456789'
|
476
|
+
obj1.provider_sha1 = 'abcdefgh'
|
477
|
+
obj2 = Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2)
|
478
|
+
obj2.provider_md5 = 'qwerty'
|
479
|
+
objects = [obj1, obj2]
|
480
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, style: :simple_book, objects: objects)
|
520
481
|
expect(result.class).to be String
|
521
482
|
xml = Nokogiri::XML(result)
|
522
483
|
expect(xml.errors.size).to be 0
|
523
|
-
expect(xml.xpath(
|
524
|
-
expect(xml.xpath(
|
525
|
-
expect(xml.xpath(
|
484
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('book')
|
485
|
+
expect(xml.xpath('//resource').length).to be 2
|
486
|
+
expect(xml.xpath('//resource/file').length).to be 2
|
487
|
+
expect(xml.xpath('//resource/file/checksum').length).to be 3
|
488
|
+
expect(xml.xpath('//label').length).to be 2
|
489
|
+
expect(xml.xpath('//label')[0].text).to match(/Page 1/)
|
490
|
+
expect(xml.xpath('//label')[1].text).to match(/Page 2/)
|
491
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
492
|
+
expect(xml.xpath('//resource/file/checksum')[0].text).to eq('abcdefgh')
|
493
|
+
expect(xml.xpath('//resource/file/checksum')[1].text).to eq('123456789')
|
494
|
+
expect(xml.xpath('//resource/file/checksum')[2].text).to eq('qwerty')
|
495
|
+
(0..1).each do |i|
|
496
|
+
expect(xml.xpath('//resource/file')[i].attributes['size']).to be nil
|
497
|
+
expect(xml.xpath('//resource/file')[i].attributes['mimetype']).to be nil
|
498
|
+
expect(xml.xpath('//resource/file')[i].attributes['publish']).to be nil
|
499
|
+
expect(xml.xpath('//resource/file')[i].attributes['preserve']).to be nil
|
500
|
+
expect(xml.xpath('//resource/file')[i].attributes['shelve']).to be nil
|
501
|
+
end
|
502
|
+
expect(xml.xpath('//resource')[0].attributes['type'].value).to eq('page')
|
503
|
+
expect(xml.xpath('//resource')[1].attributes['type'].value).to eq('page')
|
504
|
+
end
|
505
|
+
|
506
|
+
it 'does not generate valid content metadata if not all input files exist' do
|
507
|
+
expect(File.exist?(TEST_TIF_INPUT_FILE)).to be true
|
508
|
+
junk_file = '/tmp/flim_flam_floom.jp2'
|
509
|
+
expect(File.exist?(junk_file)).to be false
|
510
|
+
objects = [Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE), Assembly::ObjectFile.new(junk_file)]
|
511
|
+
expect { described_class.create_content_metadata(druid: TEST_DRUID, objects: objects) }.to raise_error(RuntimeError, "File '#{junk_file}' not found")
|
512
|
+
end
|
513
|
+
|
514
|
+
it 'generates valid content metadata for a 3d object with two 3d type files and two other supporting files' do
|
515
|
+
objects=[Assembly::ObjectFile.new(TEST_OBJ_FILE),Assembly::ObjectFile.new(TEST_PLY_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_PDF_FILE)]
|
516
|
+
result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:style=>:'3d',:objects=>objects)
|
517
|
+
expect(result.class).to be String
|
518
|
+
xml = Nokogiri::XML(result)
|
519
|
+
expect(xml.errors.size).to be 0
|
520
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('3d')
|
521
|
+
expect(xml.xpath('//resource').length).to be 4
|
522
|
+
expect(xml.xpath('//resource/file').length).to be 4
|
523
|
+
expect(xml.xpath('//label').length).to be 4
|
524
|
+
expect(xml.xpath('//label')[0].text).to match(/3d 1/)
|
525
|
+
expect(xml.xpath('//label')[1].text).to match(/3d 2/)
|
526
|
+
expect(xml.xpath('//label')[2].text).to match(/File 1/)
|
527
|
+
expect(xml.xpath('//label')[3].text).to match(/File 2/)
|
528
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
529
|
+
expect(xml.xpath('//resource')[0].attributes['type'].value).to eq('3d')
|
530
|
+
expect(xml.xpath('//resource')[1].attributes['type'].value).to eq('3d')
|
531
|
+
expect(xml.xpath('//resource')[2].attributes['type'].value).to eq('file')
|
532
|
+
expect(xml.xpath('//resource')[3].attributes['type'].value).to eq('file')
|
533
|
+
end
|
534
|
+
|
535
|
+
it 'generates valid content metadata for images and associated text files, of style=simple_image using bundle=prebundled, and no exif data' do
|
536
|
+
files = [[TEST_RES1_TIF1, TEST_RES1_JP1, TEST_RES1_TIF2, TEST_RES1_JP2, TEST_RES1_TEI, TEST_RES1_TEXT, TEST_RES1_PDF], [TEST_RES2_TIF1, TEST_RES2_JP1, TEST_RES2_TIF2, TEST_RES2_JP2, TEST_RES2_TEI, TEST_RES2_TEXT], [TEST_RES3_TIF1, TEST_RES3_JP1, TEST_RES3_TEI]]
|
537
|
+
objects = files.collect { |resource| resource.collect { |file| Assembly::ObjectFile.new(file) } }
|
538
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, bundle: :prebundled, style: :simple_image, objects: objects)
|
539
|
+
expect(result.class).to be String
|
540
|
+
xml = Nokogiri::XML(result)
|
541
|
+
expect(xml.errors.size).to be 0
|
542
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
543
|
+
expect(xml.xpath('//resource').length).to be 3
|
544
|
+
expect(xml.xpath('//resource/file').length).to be 16
|
526
545
|
expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq('res1_image1.tif')
|
527
546
|
expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq('res1_image1.jp2')
|
528
547
|
expect(xml.xpath("//resource[@sequence='1']/file")[2].attributes['id'].value).to eq('res1_image2.tif')
|
@@ -531,7 +550,7 @@ describe Assembly::ContentMetadata do
|
|
531
550
|
expect(xml.xpath("//resource[@sequence='1']/file")[5].attributes['id'].value).to eq('res1_textfile.txt')
|
532
551
|
expect(xml.xpath("//resource[@sequence='1']/file")[6].attributes['id'].value).to eq('res1_transcript.pdf')
|
533
552
|
expect(xml.xpath("//resource[@sequence='1']/file").length).to be 7
|
534
|
-
|
553
|
+
|
535
554
|
expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq('res2_image1.tif')
|
536
555
|
expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq('res2_image1.jp2')
|
537
556
|
expect(xml.xpath("//resource[@sequence='2']/file")[2].attributes['id'].value).to eq('res2_image2.tif')
|
@@ -545,40 +564,37 @@ describe Assembly::ContentMetadata do
|
|
545
564
|
expect(xml.xpath("//resource[@sequence='3']/file")[2].attributes['id'].value).to eq('res3_teifile.txt')
|
546
565
|
expect(xml.xpath("//resource[@sequence='3']/file").length).to be 3
|
547
566
|
|
548
|
-
expect(xml.xpath(
|
549
|
-
expect(xml.xpath(
|
550
|
-
|
551
|
-
expect(xml.xpath(
|
552
|
-
expect(xml.xpath(
|
567
|
+
expect(xml.xpath('//label').length).to be 3
|
568
|
+
expect(xml.xpath('//resource/file/imageData').length).to be 0
|
569
|
+
(0..2).each do |i|
|
570
|
+
expect(xml.xpath('//label')[i].text).to eq("Image #{i + 1}")
|
571
|
+
expect(xml.xpath('//resource')[i].attributes['type'].value).to eq('image')
|
553
572
|
end
|
554
573
|
end
|
555
574
|
|
556
|
-
it
|
557
|
-
obj1=Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
|
558
|
-
obj1.file_attributes={:
|
559
|
-
objects=[obj1]
|
560
|
-
result =
|
575
|
+
it 'generates role attributes for content metadata for a tif' do
|
576
|
+
obj1 = Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
|
577
|
+
obj1.file_attributes = { publish: 'no', preserve: 'no', shelve: 'no', role: 'master-role' }
|
578
|
+
objects = [obj1]
|
579
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, add_exif: false, add_file_attributes: true, objects: objects)
|
561
580
|
expect(result.class).to be String
|
562
581
|
xml = Nokogiri::XML(result)
|
563
582
|
expect(xml.errors.size).to be 0
|
564
|
-
expect(xml.xpath(
|
565
|
-
expect(xml.xpath(
|
566
|
-
expect(xml.xpath(
|
567
|
-
expect(xml.xpath(
|
568
|
-
expect(xml.xpath(
|
583
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('image')
|
584
|
+
expect(xml.xpath('//resource').length).to be 1
|
585
|
+
expect(xml.xpath('//resource/file').length).to be 1
|
586
|
+
expect(xml.xpath('//resource/file').length).to be 1
|
587
|
+
expect(xml.xpath('//resource/file')[0].attributes['role'].value).to eq('master-role')
|
569
588
|
end
|
570
589
|
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
objects=[]
|
575
|
-
result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:bundle=>:prebundled,:style=>:file,:objects=>objects)
|
590
|
+
it 'generates content metadata even when no objects are passed in' do
|
591
|
+
objects = []
|
592
|
+
result = described_class.create_content_metadata(druid: TEST_DRUID, bundle: :prebundled, style: :file, objects: objects)
|
576
593
|
expect(result.class).to be String
|
577
594
|
xml = Nokogiri::XML(result)
|
578
595
|
expect(xml.errors.size).to be 0
|
579
|
-
expect(xml.xpath(
|
580
|
-
expect(xml.xpath(
|
581
|
-
expect(xml.xpath(
|
596
|
+
expect(xml.xpath('//contentMetadata')[0].attributes['type'].value).to eq('file')
|
597
|
+
expect(xml.xpath('//resource').length).to be 0
|
598
|
+
expect(xml.xpath('//resource/file').length).to be 0
|
582
599
|
end
|
583
|
-
|
584
600
|
end
|