mead 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/test/helper.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'ruby-debug'
4
+ begin
5
+ Bundler.setup(:default, :development)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+ require 'test/unit'
12
+ require 'shoulda'
13
+ require 'fakeweb'
14
+ #require 'test_benchmark' # ruby 1.8.7 only?
15
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
17
+ require 'mead'
18
+
19
+ # disallow connections and then register all URIs used
20
+ FakeWeb.allow_net_connect = false
21
+ FakeWeb.register_uri(:get, 'http://www.lib.ncsu.edu/findingaids/ua023_031.xml',
22
+ :response => File.join('test', 'fixtures', 'ua023_031.xml'))
23
+ FakeWeb.register_uri(:get, 'http://www.lib.ncsu.edu/findingaids/mc00310.xml',
24
+ :response => File.join('test', 'fixtures', 'mc00310.xml'))
25
+
26
+ class Test::Unit::TestCase
27
+ end
28
+
29
+ # test cases should use stricter NCSU specific format validation
30
+ module Mead
31
+ class Identifier
32
+ def self.format_regexp
33
+ container_codes = Mead::CONTAINER_MAPPING.keys.join('|')
34
+ /^(ua\d{3}|mc\d{5})(_\d{3})?-\d{3}-(#{container_codes})\d{4}-\d{3}([A-Z])?-\d{3}(_\d{4})?$/
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,25 @@
1
+ require 'helper'
2
+
3
+ class TestBarcode < Test::Unit::TestCase
4
+ context 'barcode creator' do
5
+ setup do
6
+ mead_file = File.open('test/ead/ua023_031.xml')
7
+ @mead1 = Mead::Identifier.new('ua023_031-001-cb0003-005-001', mead_file).extract
8
+ @mead2 = Mead::Identifier.new('ua023_031-001-cb0013-019A-001', mead_file).extract
9
+ @barcode1 = Mead::Barcode.new(@mead1)
10
+ end
11
+ should 'hold an instance of a mead' do
12
+ assert_equal Mead::Identifier, @barcode1.mead.class
13
+ end
14
+ should 'create a barcode file' do
15
+ png_file_path = @barcode1.output_barcode(File.expand_path(File.join(File.dirname(__FILE__), '..')))
16
+ assert File.exists?(png_file_path)
17
+ File.delete(png_file_path)
18
+ end
19
+ should 'create a text file' do
20
+ text_file_path = @barcode1.output_label(File.expand_path(File.join(File.dirname(__FILE__), '..')))
21
+ assert File.exists?(text_file_path)
22
+ File.delete(text_file_path)
23
+ end
24
+ end
25
+ end
data/test/test_ead.rb ADDED
@@ -0,0 +1,193 @@
1
+ require 'helper'
2
+
3
+ class TestMead < Test::Unit::TestCase
4
+ context "Given an eadid mc00240" do
5
+
6
+ setup do
7
+ opts = {:eadid => 'mc00240', :file => File.open('test/ead/mc00240.xml')}
8
+ @ead = Mead::Ead.new(opts)
9
+ @containers = @ead.containers
10
+ end
11
+
12
+ should "create information for a stub record for the first container" do
13
+ expected = {:mead => 'mc00240-001-ff0181-000-001',
14
+ :title => 'Adams, J. H. - Barn, 1929 (1075)',
15
+ :series => 1,
16
+ :containers => ['flatfolder 181']
17
+ }
18
+ assert_equal expected, @containers[0]
19
+ end
20
+
21
+ should "create information for a stub record for the last container" do
22
+ expected = {:mead => 'mc00240-003-bx0069-000-001',
23
+ :title => 'Personnel Ledger, Pt. 2, 1956',
24
+ :series => 3,
25
+ :containers=>["Box 69"]
26
+ }
27
+ assert_equal expected, @containers.last
28
+ end
29
+
30
+ should "determine this to be an invalid ead not suitable for large scale digitization yet" do
31
+ assert_equal false, @ead.valid?
32
+ end
33
+ should "provide information on the containers with invalid (duplicate) mead identifiers" do
34
+ assert_equal 47, @ead.invalid.length
35
+ assert_equal 20, @ead.dups.length
36
+ expected = {:series=>1, :title=>"Breach, William- Residence",
37
+ :mead=>"mc00240-001-ff0298-000-001", :containers=>["flatfolder 298"]}
38
+ assert_equal expected, @ead.invalid.first
39
+ end
40
+
41
+ context "converted to csv" do
42
+ setup do
43
+ @csv = @ead.to_csv
44
+ @csv_lines = @csv.split("\n")
45
+ end
46
+ should "be able to create a csv file from the parsed ead" do
47
+ assert_equal 'mead,title,series,containers', @csv_lines[0]
48
+ end
49
+
50
+ should "be able to create good csv data from the parsed ead for the first container" do
51
+ expected = 'mc00240-001-ff0181-000-001,"Adams, J. H. - Barn, 1929 (1075)",1,flatfolder 181'
52
+ assert_equal expected, @csv_lines[1]
53
+ end
54
+
55
+ should "be able to create good csv data from the parsed ead for the last container" do
56
+ expected = 'mc00240-003-bx0069-000-001,"Personnel Ledger, Pt. 2, 1956",3,Box 69'
57
+ assert_equal expected, @csv_lines.last
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ context "Given an eadid of ua023_031" do
64
+ setup do
65
+ opts = {:eadid => 'ua023_031',:file => File.open('test/ead/ua023_031.xml')}
66
+ @ead = Mead::Ead.new(opts)
67
+ @containers = @ead.containers
68
+ end
69
+ should 'create information for a stub record for the first container' do
70
+ expected = {:title=>"Sules V-B on Apple [3] - Grape Study - Set #17",
71
+ :series=>1,
72
+ :mead=>"ua023_031-001-cb0006-031-001",
73
+ :containers => ["cardbox 6", "Envelope 31"]
74
+ }
75
+ assert_equal expected, @containers[0]
76
+ end
77
+
78
+ should 'create information for a stub record for the second container' do
79
+ expected = {
80
+ :containers=>["cardbox 10", "Envelope 10"],
81
+ :mead=>"ua023_031-001-cb0010-010-001",
82
+ :title=>
83
+ "(no. 13) Eastern Carolina, North Carolina - Diec - cabbage and treated - Hand Colored Slides, Numbered Series",
84
+ :series=>1}
85
+ assert_equal expected, @containers[1]
86
+ end
87
+
88
+ should 'create information for a stub record for the last container' do
89
+ expected = {:mead => 'ua023_031-010-cb0019-006-001',
90
+ :title => 'Examples of original storage envelopes',
91
+ :series => 10,
92
+ :containers=>["cardbox 19", "Envelope 6"]
93
+ }
94
+ assert_equal expected, @containers.last
95
+ end
96
+
97
+ end
98
+
99
+ context "Given an eadid of mc00310" do
100
+ setup do
101
+
102
+ opts = {:eadid => 'mc00310', :url => 'http://www.lib.ncsu.edu/findingaids/mc00310.xml'}
103
+ @ead = Mead::Ead.new( opts)
104
+ @containers = @ead.containers
105
+ end
106
+ should 'determine it to be a valid ead for large scale digitization' do
107
+ assert @ead.valid?
108
+ end
109
+ end
110
+
111
+ context "Given a baseurl and no filehandle for an Ead" do
112
+ setup do
113
+ opts = {:eadid => 'ua023_031', :baseurl => 'http://www.lib.ncsu.edu/findingaids'}
114
+ @ead = Mead::Ead.new(opts)
115
+ end
116
+ should 'save the baseurl as an instance variable' do
117
+ assert_equal 'http://www.lib.ncsu.edu/findingaids', @ead.baseurl
118
+ end
119
+ should 'create information for a stub record for the last container' do
120
+ containers = @ead.containers
121
+ expected = {:title=>"Sules V-B on Apple [3] - Grape Study - Set #17", :series=>1,
122
+ :mead=>"ua023_031-001-cb0006-031-001",
123
+ :containers => ["cardbox 6", "Envelope 31"]
124
+ }
125
+ assert_equal expected, containers.first
126
+ end
127
+ end
128
+
129
+ context "Given a url and no file or baseurl for an Ead" do
130
+ setup do
131
+ opts = {:eadid => 'ua023_031', :url => 'http://www.lib.ncsu.edu/findingaids/ua023_031.xml'}
132
+ @ead = Mead::Ead.new(opts)
133
+ end
134
+ should 'save the url to an instance variable' do
135
+ assert_equal 'http://www.lib.ncsu.edu/findingaids/ua023_031.xml', @ead.url
136
+ end
137
+ should 'create information for a stub record for the last container' do
138
+ containers = @ead.containers
139
+ expected = {:title=>"Sules V-B on Apple [3] - Grape Study - Set #17",
140
+ :series=>1, :mead=>"ua023_031-001-cb0006-031-001",
141
+ :containers => ["cardbox 6", "Envelope 31"]}
142
+ assert_equal expected, containers.first
143
+ end
144
+ end
145
+
146
+ context "Given a baseurl and no eadid" do
147
+ should 'raise an exception' do
148
+ opts = {:baseurl => 'http://www.lib.ncsu.edu/findingaids'}
149
+ assert_raise RuntimeError do
150
+ Mead::Ead.new(opts)
151
+ end
152
+ end
153
+ end
154
+
155
+
156
+ context 'missing an eadid' do
157
+ setup do
158
+ @expected = {:title=>"Sules V-B on Apple [3] - Grape Study - Set #17",
159
+ :series=>1,
160
+ :mead=>"ua023_031-001-cb0006-031-001",
161
+ :containers=>["cardbox 6", "Envelope 31"]
162
+ }
163
+ end
164
+ context 'Given a file' do
165
+ setup do
166
+ opts = {:file => File.open('test/ead/ua023_031.xml')}
167
+ @ead = Mead::Ead.new(opts)
168
+ end
169
+ should 'try to find the eadid in the EAD XML' do
170
+ assert_equal 'ua023_031', @ead.eadid
171
+ end
172
+ should 'get information for the first container' do
173
+ assert_equal @expected, @ead.containers.first
174
+ end
175
+ end
176
+
177
+ context 'Given a full URL' do
178
+ setup do
179
+ opts = {:url => 'http://www.lib.ncsu.edu/findingaids/ua023_031.xml'}
180
+ @ead = Mead::Ead.new(opts)
181
+ end
182
+ should 'try to find the eadid in the EAD XML' do
183
+ assert_equal 'ua023_031', @ead.eadid
184
+ end
185
+ should 'get information for the first container' do
186
+ assert_equal @expected, @ead.containers.first
187
+ end
188
+ end
189
+ end
190
+
191
+
192
+ end
193
+
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+
3
+ class TestEadValidator < Test::Unit::TestCase
4
+
5
+ context 'Given a directory of EAD XML validate them all' do
6
+ setup do
7
+ @eadv = Mead::EadValidator.new('test/ead/')
8
+ end
9
+ should 'store the directory path' do
10
+ assert_equal 'test/ead/', @eadv.directory
11
+ end
12
+ should 'return results' do
13
+ expected = {:valid=>["ua021_428", "ua023_006"],
14
+ :invalid=>["mc00145","mc00240", "ua015_010", "ua023_031", "ua110_041"]}
15
+ assert_equal expected, @eadv.validate!
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,83 @@
1
+ require 'helper'
2
+
3
+ class TestMeadExtractor < Test::Unit::TestCase
4
+ context "the mead ua023_031-008-cb0013-001-001" do
5
+ setup do
6
+
7
+ @identifier = 'ua023_031-008-cb0013-001-001'
8
+ @expected_1 = [
9
+ {:level=>"file",
10
+ :unitdate=>nil,
11
+ :unitid=>nil,
12
+ :unittitle=>
13
+ "Horticulture - students in greenhouse - for photograph see - Agriculture school - Horticulture - Hand Colored Slides, agriculture school",
14
+ :item_location => 'cardbox 13, Envelope 1',
15
+ :containers => [
16
+ Mead::Container.new(:type => 'cardbox', :label => "Mixed materials", :text => '13'),
17
+ Mead::Container.new(:type => 'Envelope', :text => '1')]
18
+ },
19
+ {:level=>"subseries", :unitdate=>nil, :unitid=>nil, :unittitle=>"Students"},
20
+ {:level=>"series", :unitdate=>nil, :series_number=>8, :unitid=>"Series 8", :unittitle=>"People"}]
21
+ end
22
+
23
+ should "produce a good extraction with a filehandle location for the Ead" do
24
+ fh = File.open('test/ead/ua023_031.xml')
25
+ mead = Mead::Identifier.new(@identifier, fh)
26
+ assert_equal @expected_1, Mead::Extractor.new(mead).extract
27
+ end
28
+
29
+ should "producde a good extraction with a remote location Ead containing no eadid" do
30
+ assert_equal @expected_1, Mead::Extractor.new(Mead::Identifier.new(@identifier, 'http://www.lib.ncsu.edu/findingaids')).extract
31
+ end
32
+ should 'produce a good extraction with a remote location Ead with a full URL' do
33
+ assert_equal @expected_1, Mead::Extractor.new(Mead::Identifier.new(@identifier, 'http://www.lib.ncsu.edu/findingaids/ua023_031.xml')).extract
34
+ end
35
+
36
+
37
+ context 'mc00240-001-ff0052-000-001' do
38
+ setup do
39
+ @expected_mc00240 = [{:unittitle=>"Friends Church",
40
+ :item_location=>"flatfolder 52",
41
+ :unitdate=>"1927",
42
+ :level=>"file",
43
+ :unitid=>"903",
44
+ :containers =>
45
+ [Mead::Container.new(:type => 'flatfolder', :label => 'Mixed materials', :text => '52')]},
46
+ {:series_number=>1,
47
+ :unittitle=>"Drawings",
48
+ :unitdate=>"1917-1980",
49
+ :level=>"series",
50
+ :unitid=>"MC 240 Series 1"}]
51
+ end
52
+ should 'handle empty folder properly' do
53
+ mead = Mead::Identifier.new('mc00240-001-ff0052-000-001', File.open('test/ead/mc00240.xml'))
54
+ assert_equal @expected_mc00240, Mead::Extractor.new(mead).extract
55
+ end
56
+
57
+ should 'cache the extraction within the Mead::Identifier' do
58
+ mead = Mead::Identifier.new('mc00240-001-ff0052-000-001', File.open('test/ead/mc00240.xml')).extract
59
+ assert_equal @expected_mc00240, mead.metadata
60
+ end
61
+ end
62
+
63
+ end
64
+
65
+ should "raise an exception if the extractor is given something other than a Mead::Identifier" do
66
+ assert_raise RuntimeError do
67
+ Mead::Extractor.new({})
68
+ end
69
+ end
70
+ should "raise an exception if the extractor tries to extract from a Mead::Identifier without an Ead location set" do
71
+ assert_raise RuntimeError do
72
+ Mead::Extractor.new(Mead::Identifier.new('mc00240-001-ff0052-000-001')).extract
73
+ end
74
+ end
75
+ should "raise an exception when a duplicate Mead::Identifier is found by matching too many nodes" do
76
+ assert_raise RuntimeError do
77
+ Mead::Extractor.new(Mead::Identifier.new('mc00240-003-bx0069-000-001', File.open('test/ead/mc00240.xml'))).extract
78
+ end
79
+ end
80
+
81
+
82
+ end
83
+
@@ -0,0 +1,19 @@
1
+ require 'helper'
2
+
3
+ class TestMc00145 < Test::Unit::TestCase
4
+ context "the ead mc00145" do
5
+ setup do
6
+ opts = {:eadid => 'mc00145', :file => File.open('test/ead/mc00145.xml')}
7
+ @ead = Mead::Ead.new(opts)
8
+ @containers = @ead.containers
9
+ end
10
+
11
+ should "create short meads for component parts with more than 2 containers" do
12
+ assert !@containers.empty?
13
+ end
14
+
15
+ should "create meads for EAD with no series" do
16
+ assert_equal 'mc00145-001-te0001-000-001', @containers.last[:mead]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,140 @@
1
+ require 'helper'
2
+
3
+ class TestMeadMC00240 < Test::Unit::TestCase
4
+
5
+ context "a legacy mead from mc00240" do
6
+ setup do
7
+ @mead_id = 'mc00240-001-ff0147-001-001_0001' #empty folder was given 001 rather than 000
8
+ @fh = File.open('test/ead/mc00240.xml')
9
+ @mead = Mead::Identifier.new(@mead_id, @fh)
10
+ end
11
+ should "retrieve the correct metadata" do
12
+ @mead.extract
13
+ expected = [{:unittitle=>"Moravian Chapel at Southside", :level=>"file",
14
+ :item_location=>"flatfolder 147", :unitdate=>"1928", :unitid=>"1034",
15
+ :containers =>
16
+ [Mead::Container.new(:type => 'flatfolder',
17
+ :label => "Mixed materials",
18
+ :text => '147')]
19
+ },
20
+ {:unittitle=>"Drawings", :series_number=>1,
21
+ :level=>"series", :unitdate=>"1917-1980", :unitid=>"MC 240 Series 1"}]
22
+ assert_equal expected, @mead.metadata
23
+ end
24
+ end
25
+
26
+
27
+ context "a mead from mc00240" do
28
+ setup do
29
+ @mead_id = 'mc00240-001-ff0042-000-001'
30
+ @fh = File.open('test/ead/mc00240.xml')
31
+ @mead = Mead::Identifier.new(@mead_id, @fh)
32
+ end
33
+
34
+ context "parsing a mead from mc00240" do
35
+
36
+ should "produce expected output of eadid" do
37
+ assert_equal @mead.eadid, 'mc00240'
38
+ end
39
+
40
+ should "produce the expected series" do
41
+ assert_equal @mead.series, '1'
42
+ end
43
+
44
+ should "produce the expected container" do
45
+ expected = {:type=> 'flatfolder', :number => '42'}
46
+ assert_equal expected, @mead.container
47
+ end
48
+
49
+ should "produce the expected folder" do
50
+ assert_equal @mead.folder, nil
51
+ end
52
+
53
+ should "produce the expected sequence" do
54
+ assert_equal @mead.sequence, '1'
55
+ end
56
+ end
57
+
58
+ context "extracting metadata from a mead" do
59
+ setup do
60
+ @extractor = Mead::Extractor.new(@mead)
61
+ #@file = File.open('test/ead/mc00240.xml')
62
+ end
63
+
64
+ should "be able to create an extractor" do
65
+ assert_equal @extractor.class, Mead::Extractor
66
+ end
67
+
68
+ should "convert a string to a mead object" do
69
+ assert_equal @extractor.mead.class, Mead::Identifier
70
+ end
71
+
72
+ context "should give back the metadata" do
73
+ setup do
74
+ @result = @extractor.extract
75
+ end
76
+
77
+ should "Cache the metadata in the Mead::Identifier" do
78
+ mead = Mead::Identifier.new(@mead_id, @fh).extract
79
+ assert_equal @result, mead.metadata
80
+ end
81
+
82
+ should "extract the item's unittitle" do
83
+ assert_equal 'Amos Hosiery Mill - Addition', @extractor.stack[0][:unittitle]
84
+ end
85
+
86
+ should "extract the item's unitdate" do
87
+ assert_equal '1953', @extractor.stack[0][:unitdate]
88
+ end
89
+
90
+ should "extract the item's level" do
91
+ assert_equal 'file', @extractor.stack[0][:level]
92
+ end
93
+
94
+ should "extract the item's unitid" do
95
+ assert_equal '1421', @extractor.stack[0][:unitid]
96
+ end
97
+
98
+ should "extract the item's containers" do
99
+ assert_equal @extractor.stack[0][:containers].first.class, Mead::Container
100
+ end
101
+
102
+ should "extract the parent unittitle" do
103
+ assert_equal "Drawings", @extractor.stack[1][:unittitle]
104
+ end
105
+
106
+ should "extract the parent unitdate" do
107
+ assert_equal "1917-1980", @extractor.stack[1][:unitdate]
108
+ end
109
+
110
+ should "extract the parent level" do
111
+ assert_equal "series", @extractor.stack[1][:level]
112
+ end
113
+
114
+ should "extract the parent unitid" do
115
+ assert_equal 'MC 240 Series 1', @extractor.stack[1][:unitid]
116
+ end
117
+
118
+ should "extract a series' series number" do
119
+ assert_equal 1, @extractor.stack[1][:series_number]
120
+ end
121
+
122
+ # should "only extract up to the series level" do
123
+ # assert_equal [
124
+ # {:unittitle=>"Amos Hosiery Mill - Addition", :unitdate=>"1953",
125
+ # :level => 'file', :unitid => '1421', :item_location => 'flatfolder 42'},
126
+ # {:unittitle=>"Drawings", :unitdate=>"1917-1980", :level => 'series',
127
+ # :unitid => 'MC 240 Series 1', :series_number => 1
128
+ # }
129
+ # ], @extractor.stack
130
+ # end
131
+
132
+ end
133
+
134
+ end
135
+
136
+
137
+
138
+ end
139
+
140
+ end
data/test/test_mead.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'helper'
2
+
3
+ class TestMead < Test::Unit::TestCase
4
+
5
+ end
@@ -0,0 +1,111 @@
1
+ require 'helper'
2
+
3
+ class TestMeadUA015_010 < Test::Unit::TestCase
4
+
5
+ context "a mead from ua015_010" do
6
+ setup do
7
+ @mead = 'ua015_010-004-bx0039-005-002'
8
+ end
9
+
10
+ context "parsing a mead from ua015_010" do
11
+ setup do
12
+ @result = Mead::Identifier.new(@mead, File.open('test/ead/ua015_010.xml')) #this is where processing
13
+ end
14
+
15
+ should "produce expected output of eadid" do
16
+ assert_equal @result.eadid, 'ua015_010'
17
+ end
18
+
19
+ should "produce the expected series" do
20
+ assert_equal @result.series, '4'
21
+ end
22
+
23
+ should "produce the expected container" do
24
+ expected = {:type=> 'box', :number => '39'}
25
+ assert_equal expected, @result.container
26
+ end
27
+
28
+ should "produce the expected folder" do
29
+ assert_equal @result.folder, {:type=> 'folder', :number => '5'}
30
+ end
31
+
32
+ should "produce the expected sequence" do
33
+ assert_equal @result.sequence, '2'
34
+ end
35
+ end
36
+
37
+ context "extracting metadata from a mead" do
38
+ setup do
39
+ @result = Mead::Identifier.new(@mead, File.open('test/ead/ua015_010.xml'))
40
+ @extractor = Mead::Extractor.new(@result)
41
+ end
42
+
43
+ should "be able to create an extractor" do
44
+ assert_equal @extractor.class, Mead::Extractor
45
+ end
46
+
47
+ should "convert a string to a mead object" do
48
+ assert_equal @extractor.mead.class, Mead::Identifier
49
+ end
50
+
51
+ context "should give back the metadata" do
52
+ setup do
53
+ @result = @extractor.extract
54
+ end
55
+
56
+ should "extract the item's unittitle" do
57
+ assert_equal 'Programs', @extractor.stack[0][:unittitle]
58
+ end
59
+
60
+ should "extract the item's unitdate" do
61
+ assert_equal '1949-1950', @extractor.stack[0][:unitdate]
62
+ end
63
+
64
+ should "extract the item level" do
65
+ assert_equal 'file', @extractor.stack[0][:level]
66
+ end
67
+
68
+ should "extract the item unitid" do
69
+ assert_nil @extractor.stack[0][:unitid]
70
+ end
71
+
72
+ should "extract the parent unittitle" do
73
+ assert_equal "Men's Basketball", @extractor.stack[1][:unittitle]
74
+ end
75
+
76
+ should "extract the parent unitdate" do
77
+ assert_equal "1911-2006", @extractor.stack[1][:unitdate]
78
+ end
79
+
80
+ should "extract the parent level" do
81
+ assert_equal 'series', @extractor.stack[1][:level]
82
+ end
83
+
84
+ should "extract the parent unitid" do
85
+ assert_equal 'Series 4', @extractor.stack[1][:unitid]
86
+ end
87
+
88
+ should "extract a series' series number" do
89
+ assert_equal 4, @extractor.stack[1][:series_number]
90
+ end
91
+
92
+ # should "only extract up to the series level" do
93
+ # assert_equal [
94
+ # {:unittitle=>"Programs", :unitdate=>"1949-1950",
95
+ # :level => 'file', :unitid => nil, :item_location => 'Box 39, Folder 5'},
96
+ # {:unittitle=>"Men's Basketball", :unitdate=>"1911-2006",
97
+ # :level => 'series', :unitid => 'Series 4',
98
+ # :series_number => 4
99
+ # }
100
+ # ], @extractor.stack
101
+ # end
102
+
103
+ end
104
+
105
+ end
106
+
107
+
108
+
109
+ end
110
+
111
+ end
@@ -0,0 +1,26 @@
1
+ require 'helper'
2
+
3
+ class TestMeadUA021_428 < Test::Unit::TestCase
4
+ context "extracting metadata from a mead" do
5
+ setup do
6
+ @mead = 'ua021_428-001-cb0007-000-001'
7
+ @result = Mead::Identifier.new(@mead, File.open('test/ead/ua021_428.xml'))
8
+ @extractor = Mead::Extractor.new(@result)
9
+ @extractor.extract
10
+ end
11
+
12
+ should "have metadata" do
13
+ assert !@extractor.stack.empty?
14
+ end
15
+
16
+ should 'show ua021_428-001-cb0007-000-001 to be a valid mead' do
17
+ mead = Mead::Identifier.new(@mead, File.open('test/ead/ua021_428.xml')).extract
18
+ assert mead.valid_format?
19
+ assert mead.valid?
20
+ end
21
+
22
+
23
+ end
24
+
25
+ end
26
+