oai 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/README.md +28 -23
  2. data/Rakefile +14 -40
  3. data/examples/providers/dublin_core.rb +63 -63
  4. data/lib/oai/client.rb +131 -97
  5. data/lib/oai/client/list_identifiers.rb +1 -0
  6. data/lib/oai/client/list_records.rb +6 -5
  7. data/lib/oai/client/list_sets.rb +6 -5
  8. data/lib/oai/client/record.rb +6 -7
  9. data/lib/oai/client/response.rb +7 -4
  10. data/lib/oai/client/resumable.rb +42 -0
  11. data/lib/oai/harvester/shell.rb +40 -41
  12. data/lib/oai/provider.rb +85 -67
  13. data/lib/oai/provider/metadata_format/oai_dc.rb +5 -6
  14. data/lib/oai/provider/model/activerecord_caching_wrapper.rb +23 -25
  15. data/lib/oai/provider/model/activerecord_wrapper.rb +99 -51
  16. data/lib/oai/provider/response.rb +33 -31
  17. data/lib/oai/provider/response/get_record.rb +7 -7
  18. data/lib/oai/provider/response/list_records.rb +5 -4
  19. data/lib/oai/provider/response/record_response.rb +14 -14
  20. data/test/activerecord_provider/config/connection.rb +8 -4
  21. data/test/activerecord_provider/database/{ar_migration.rb → 0001_oaipmh_tables.rb} +17 -12
  22. data/test/activerecord_provider/helpers/providers.rb +2 -3
  23. data/test/activerecord_provider/helpers/set_provider.rb +10 -22
  24. data/test/activerecord_provider/helpers/transactional_test_case.rb +34 -0
  25. data/test/activerecord_provider/models/dc_field.rb +4 -4
  26. data/test/activerecord_provider/models/dc_set.rb +3 -2
  27. data/test/activerecord_provider/models/exclusive_set_dc_field.rb +11 -0
  28. data/test/activerecord_provider/tc_ar_provider.rb +67 -28
  29. data/test/activerecord_provider/tc_ar_sets_provider.rb +104 -18
  30. data/test/activerecord_provider/tc_caching_paging_provider.rb +6 -10
  31. data/test/activerecord_provider/tc_simple_paging_provider.rb +7 -11
  32. data/test/activerecord_provider/test_helper.rb +10 -0
  33. data/test/client/helpers/provider.rb +44 -47
  34. data/test/client/helpers/test_wrapper.rb +4 -16
  35. data/test/client/tc_http_client.rb +90 -2
  36. data/test/client/tc_list_identifiers.rb +22 -3
  37. data/test/client/tc_list_records.rb +17 -4
  38. data/test/client/tc_list_sets.rb +17 -2
  39. data/test/provider/models.rb +32 -30
  40. data/test/provider/tc_exceptions.rb +30 -20
  41. data/test/provider/tc_functional_tokens.rb +11 -6
  42. data/test/provider/tc_provider.rb +58 -24
  43. data/test/provider/tc_resumption_tokens.rb +6 -6
  44. data/test/provider/tc_simple_provider.rb +51 -26
  45. data/test/provider/test_helper.rb +7 -0
  46. metadata +67 -128
  47. data/test/activerecord_provider/config/database.yml +0 -6
  48. data/test/activerecord_provider/database/oaipmhtest +0 -0
@@ -3,10 +3,10 @@ require 'test_helper'
3
3
  class ListIdentifiersTest < Test::Unit::TestCase
4
4
 
5
5
  def test_list_with_resumption_token
6
- client = OAI::Client.new 'http://localhost:3333/oai'
6
+ client = OAI::Client.new 'http://localhost:3333/oai'
7
7
 
8
8
  # get a list of identifier headers
9
- response = client.list_identifiers :metadata_prefix => 'oai_dc'
9
+ response = client.list_identifiers :metadata_prefix => 'oai_dc'
10
10
  assert_kind_of OAI::ListIdentifiersResponse, response
11
11
  assert_kind_of OAI::Response, response
12
12
  assert response.entries.size > 0
@@ -27,6 +27,25 @@ class ListIdentifiersTest < Test::Unit::TestCase
27
27
  assert_not_equal response.entries[0].identifier, first_identifier
28
28
  end
29
29
 
30
+ def test_list_full
31
+ client = OAI::Client.new 'http://localhost:3333/oai'
32
+
33
+ # get a list of identifier headers
34
+ response = client.list_identifiers :metadata_prefix => 'oai_dc'
35
+ assert_kind_of OAI::ListIdentifiersResponse, response
36
+ assert_kind_of OAI::Response, response
37
+ assert response.respond_to?(:full), "Should expose :full"
38
+
39
+ # Check that it runs through the pages
40
+ assert_equal 1150, response.full.count
41
+ response.full.each do |header|
42
+ assert_kind_of OAI::Header, header
43
+ assert header.identifier
44
+ assert header.datestamp
45
+ assert header.set_spec
46
+ end
47
+ end
48
+
30
49
  def test_list_with_date_range
31
50
  client = OAI::Client.new 'http://localhost:3333/oai'
32
51
  from_date = Date.new(1998,1,1)
@@ -48,5 +67,5 @@ class ListIdentifiersTest < Test::Unit::TestCase
48
67
  client = OAI::Client.new 'http://localhost:3333/oai'
49
68
  assert_raise(OAI::ArgumentException) {client.list_identifiers :foo => 'bar'}
50
69
  end
51
-
70
+
52
71
  end
@@ -1,13 +1,26 @@
1
1
  require 'test_helper'
2
2
 
3
- class GetRecordsTest < Test::Unit::TestCase
3
+ class ListRecordsTest < Test::Unit::TestCase
4
4
 
5
- def test_get_records
5
+ def test_list
6
6
  client = OAI::Client.new 'http://localhost:3333/oai'
7
- response = client.list_records
7
+ response = client.list_records
8
8
  assert_kind_of OAI::ListRecordsResponse, response
9
9
  assert response.entries.size > 0
10
10
  assert_kind_of OAI::Record, response.entries[0]
11
11
  end
12
-
12
+
13
+ def test_list_full
14
+ client = OAI::Client.new 'http://localhost:3333/oai'
15
+
16
+ response = client.list_records
17
+ assert_kind_of OAI::ListRecordsResponse, response
18
+
19
+ # Check that it runs through the pages
20
+ assert_equal 1150, response.full.count
21
+ response.full.each do |record|
22
+ assert_kind_of OAI::Record, record
23
+ end
24
+ end
25
+
13
26
  end
@@ -8,12 +8,27 @@ class ListSetsTest < Test::Unit::TestCase
8
8
  assert_kind_of OAI::ListSetsResponse, response
9
9
  assert response.entries.size > 0
10
10
  assert_kind_of OAI::Set, response.entries[0]
11
-
11
+
12
12
  # test iterator
13
13
  for set in response
14
14
  assert_kind_of OAI::Set, set
15
15
  end
16
16
  end
17
-
17
+
18
+ def test_list_full
19
+ client = OAI::Client.new 'http://localhost:3333/oai'
20
+
21
+ response = client.list_sets
22
+ assert_kind_of OAI::ListSetsResponse, response
23
+ assert_kind_of OAI::Response, response
24
+ assert response.respond_to?(:full), "Should expose :full"
25
+
26
+ # This won't page, but it should work anyway
27
+ assert_equal 6, response.full.count
28
+ response.full.each do |set|
29
+ assert_kind_of OAI::Set, set
30
+ end
31
+ end
32
+
18
33
  end
19
34
 
@@ -1,14 +1,14 @@
1
1
  class Record
2
2
  attr_accessor :id, :titles, :creator, :tags, :sets, :updated_at, :deleted
3
-
4
- def initialize(id,
5
- titles = 'title',
6
- creator = 'creator',
7
- tags = 'tag',
8
- sets = nil,
3
+
4
+ def initialize(id,
5
+ titles = 'title',
6
+ creator = 'creator',
7
+ tags = 'tag',
8
+ sets = nil,
9
9
  deleted = false,
10
10
  updated_at = Time.now.utc.xmlschema)
11
-
11
+
12
12
  @id = id
13
13
  @titles = titles
14
14
  @creator = creator
@@ -17,12 +17,12 @@ class Record
17
17
  @deleted = deleted
18
18
  @updated_at = updated_at
19
19
  end
20
-
20
+
21
21
  # Override Object.id
22
22
  def id
23
23
  @id
24
24
  end
25
-
25
+
26
26
  def in_set(spec)
27
27
  if @sets.respond_to?(:each)
28
28
  @sets.each { |set| return true if set.spec == spec }
@@ -35,18 +35,18 @@ end
35
35
 
36
36
  class TestModel < OAI::Provider::Model
37
37
  include OAI::Provider
38
-
38
+
39
39
  def initialize(limit = nil)
40
40
  super(limit)
41
41
  @records = []
42
42
  @sets = []
43
43
  @earliest = Time.now.utc.xmlschema
44
44
  end
45
-
45
+
46
46
  def earliest
47
47
  (@records.min {|a,b| a.updated_at <=> b.updated_at }).updated_at.utc.xmlschema
48
48
  end
49
-
49
+
50
50
  def latest
51
51
  @records.max {|a,b| a.updated_at <=> b.updated_at }.updated_at.utc.xmlschema
52
52
  end
@@ -54,7 +54,7 @@ class TestModel < OAI::Provider::Model
54
54
  def sets
55
55
  @sets
56
56
  end
57
-
57
+
58
58
  def find(selector, opts={})
59
59
  return nil unless selector
60
60
 
@@ -79,7 +79,7 @@ class TestModel < OAI::Provider::Model
79
79
  (opts[:from].nil? || rec.updated_at >= opts[:from]) &&
80
80
  (opts[:until].nil? || rec.updated_at <= opts[:until]))
81
81
  #else
82
- # ((opts[:set].nil? || rec.in_set(opts[:set])) &&
82
+ # ((opts[:set].nil? || rec.in_set(opts[:set])) &&
83
83
  # (opts[:from].nil? || rec.updated_at >= opts[:from]) &&
84
84
  # (opts[:until].nil? || rec.updated_at <= opts[:until]))
85
85
  #end
@@ -87,7 +87,7 @@ class TestModel < OAI::Provider::Model
87
87
 
88
88
  if @limit && records.size > @limit
89
89
  @groups = generate_chunks(records, @limit)
90
- return PartialResult.new(@groups[0],
90
+ return PartialResult.new(@groups[0],
91
91
  ResumptionToken.new(opts.merge({:last => 1})))
92
92
  end
93
93
  return records
@@ -102,7 +102,7 @@ class TestModel < OAI::Provider::Model
102
102
  nil
103
103
  end
104
104
  end
105
-
105
+
106
106
  def generate_chunks(records, limit)
107
107
  groups = []
108
108
  records.each_slice(limit) do |group|
@@ -110,17 +110,17 @@ class TestModel < OAI::Provider::Model
110
110
  end
111
111
  groups
112
112
  end
113
-
113
+
114
114
  def generate_records(number, timestamp = Time.now.utc.xmlschema, sets = [], deleted = false)
115
115
  @earliest = timestamp.dup if @earliest.nil? || timestamp.to_s < @earliest.to_s
116
116
  @earliest = timestamp.dup if @earliest.nil?
117
-
117
+
118
118
  # Add any sets we don't already have
119
119
  sets = [sets] unless sets.respond_to?(:each)
120
120
  sets.each do |set|
121
121
  @sets << set unless @sets.include?(set)
122
- end
123
-
122
+ end
123
+
124
124
  # Generate some records
125
125
  number.times do |id|
126
126
  rec = Record.new(@records.size, "title_#{id}", "creator_#{id}", "tag_#{id}")
@@ -130,11 +130,11 @@ class TestModel < OAI::Provider::Model
130
130
  @records << rec
131
131
  end
132
132
  end
133
-
133
+
134
134
  end
135
135
 
136
136
  class SimpleModel < TestModel
137
-
137
+
138
138
  def initialize
139
139
  super
140
140
  # Create a couple of sets
@@ -156,7 +156,7 @@ class SimpleModel < TestModel
156
156
  end
157
157
 
158
158
  class BigModel < TestModel
159
-
159
+
160
160
  def initialize(limit = nil)
161
161
  super(limit)
162
162
  generate_records(100, Time.parse("October 2 2000"))
@@ -165,7 +165,7 @@ class BigModel < TestModel
165
165
  generate_records(100, Time.parse("January 2 2001"))
166
166
  generate_records(100, Time.parse("February 2 2001"))
167
167
  end
168
-
168
+
169
169
  end
170
170
 
171
171
  class MappedModel < TestModel
@@ -179,7 +179,7 @@ class MappedModel < TestModel
179
179
 
180
180
  generate_records(5, Time.parse("dec 1 2006"), set_one)
181
181
  end
182
-
182
+
183
183
  def map_oai_dc
184
184
  {:title => :creator, :creator => :titles, :subject => :tags}
185
185
  end
@@ -187,7 +187,7 @@ class MappedModel < TestModel
187
187
  end
188
188
 
189
189
  class ComplexModel < TestModel
190
-
190
+
191
191
  def initialize(limit = nil)
192
192
  super(limit)
193
193
  # Create a couple of sets
@@ -225,20 +225,22 @@ class ComplexModel < TestModel
225
225
  generate_records(50, Time.parse("June 2 1998"), [set_one, set_one_two], true)
226
226
  generate_records(50, Time.parse("October 10 1998"), [set_three, set_three_four], true)
227
227
  generate_records(250, Time.parse("July 2 2002"), [set_two, set_one_two])
228
-
228
+
229
229
  generate_records(250, Time.parse("September 15 2004"), [set_three, set_three_four])
230
230
  generate_records(50, Time.parse("October 10 2004"), [set_three, set_three_four], true)
231
231
  generate_records(250, Time.parse("December 25 2005"), [set_four, set_three_four])
232
232
  end
233
-
233
+
234
234
  def about record
235
- <<-eos
236
- <oai_dc:dc
235
+ xml = <<-eos
236
+ <oai_dc:dc
237
237
  xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
238
238
  xmlns:dc="http://purl.org/dc/elements/1.1/">
239
239
  <dc:publisher>Ruby OAI test data</dc:publisher>
240
240
  </oai_dc:dc>
241
241
  eos
242
+ # Removes new-lines and formatting, which is a problem with Ruby 1.8.x
243
+ xml.gsub(/\s+/, ' ')
242
244
  end
243
245
  end
244
246
 
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ProviderExceptions < Test::Unit::TestCase
4
-
4
+
5
5
  def setup
6
6
  @provider = ComplexProvider.new
7
7
  end
@@ -9,7 +9,7 @@ class ProviderExceptions < Test::Unit::TestCase
9
9
  def test_argument_exception
10
10
  assert_raise(OAI::ArgumentException) do
11
11
  @provider.identify(:identifier => 'invalid_arg')
12
- end
12
+ end
13
13
  end
14
14
 
15
15
  def test_resumption_token_exception
@@ -26,44 +26,54 @@ class ProviderExceptions < Test::Unit::TestCase
26
26
  @provider.list_identifiers(:resumption_token => '\:\\:\/$%^&*!@#!:1')
27
27
  end
28
28
  end
29
-
29
+
30
30
  def test_bad_verb_raises_exception
31
31
  assert @provider.process_request(:verb => 'BadVerb') =~ /badVerb/
32
32
  assert @provider.process_request(:verb => '\a$#^%!@') =~ /badVerb/
33
33
  assert @provider.process_request(:verb => 'identity') =~ /badVerb/
34
34
  assert @provider.process_request(:verb => '!!\\$\$\.+') =~ /badVerb/
35
35
  end
36
-
36
+
37
37
  def test_bad_format_raises_exception
38
38
  assert_raise(OAI::FormatException) do
39
39
  @provider.get_record(:identifier => 'oai:test/1', :metadata_prefix => 'html')
40
40
  end
41
41
  end
42
-
43
- def test_bad_id_raises_exception
44
- assert_raise(OAI::IdException) do
45
- @provider.get_record(:identifier => 'oai:test/5000')
46
- end
47
- assert_raise(OAI::IdException) do
48
- @provider.get_record(:identifier => 'oai:test/-1')
42
+
43
+ def test_missing_format_raises_exception
44
+ assert_raise(OAI::ArgumentException) do
45
+ @provider.list_records()
49
46
  end
50
- assert_raise(OAI::IdException) do
51
- @provider.get_record(:identifier => 'oai:test/one')
47
+ assert_raise(OAI::ArgumentException) do
48
+ @provider.get_record(:identifier => 'oai:test/1')
52
49
  end
53
- assert_raise(OAI::IdException) do
54
- @provider.get_record(:identifier => 'oai:test/\\$1\1!')
50
+ end
51
+
52
+ def test_bad_id_raises_exception
53
+ badIdentifiers = [
54
+ 'oai:test/5000',
55
+ 'oai:test/-1',
56
+ 'oai:test/one',
57
+ 'oai:test/\\$1\1!']
58
+ badIdentifiers.each do |id|
59
+ assert_raise(OAI::IdException) do
60
+ @provider.get_record(:identifier => id, :metadata_prefix => 'oai_dc')
61
+ end
55
62
  end
56
63
  end
57
-
64
+
58
65
  def test_no_records_match_dates_that_are_out_of_range
59
66
  assert_raise(OAI::NoMatchException) do
60
- @provider.list_records(:from => Time.parse("November 2 2000"),
67
+ @provider.list_records(:metadata_prefix => 'oai_dc',
68
+ :from => Time.parse("November 2 2000"),
61
69
  :until => Time.parse("November 1 2000"))
62
70
  end
63
71
  end
64
-
72
+
65
73
  def test_no_records_match_bad_set
66
- assert_raise(OAI::NoMatchException) { @provider.list_records(:set => 'unknown') }
74
+ assert_raise(OAI::NoMatchException) do
75
+ @provider.list_records(:metadata_prefix => 'oai_dc', :set => 'unknown')
76
+ end
67
77
  end
68
-
78
+
69
79
  end
@@ -2,14 +2,16 @@ require 'test_helper'
2
2
 
3
3
  class ResumptionTokenFunctionalTest < Test::Unit::TestCase
4
4
  include REXML
5
-
5
+
6
6
  def setup
7
7
  @provider = ComplexProvider.new
8
8
  end
9
9
 
10
10
  def test_resumption_tokens
11
- assert_nothing_raised { Document.new(@provider.list_records) }
12
- doc = Document.new(@provider.list_records)
11
+ assert_nothing_raised do
12
+ Document.new(@provider.list_records(:metadata_prefix => 'oai_dc'))
13
+ end
14
+ doc = Document.new(@provider.list_records(:metadata_prefix => 'oai_dc'))
13
15
  assert_not_nil doc.elements["/OAI-PMH/ListRecords/resumptionToken"]
14
16
  assert_equal 101, doc.elements["/OAI-PMH/ListRecords"].to_a.size
15
17
  token = doc.elements["/OAI-PMH/ListRecords/resumptionToken"].text
@@ -20,15 +22,18 @@ class ResumptionTokenFunctionalTest < Test::Unit::TestCase
20
22
 
21
23
  def test_from_and_until_with_resumption_tokens
22
24
  # Should return 300 records broken into 3 groups of 100.
23
- assert_nothing_raised { Document.new(@provider.list_records) }
25
+ assert_nothing_raised do
26
+ Document.new(@provider.list_records(:metadata_prefix => 'oai_dc'))
27
+ end
24
28
  doc = Document.new(
25
29
  @provider.list_records(
30
+ :metadata_prefix => 'oai_dc',
26
31
  :from => Time.parse("September 1 2004"),
27
32
  :until => Time.parse("November 30 2004"))
28
33
  )
29
34
  assert_equal 101, doc.elements["/OAI-PMH/ListRecords"].to_a.size
30
35
  token = doc.elements["/OAI-PMH/ListRecords/resumptionToken"].text
31
-
36
+
32
37
  doc = Document.new(@provider.list_records(:resumption_token => token))
33
38
  assert_not_nil doc.elements["/OAI-PMH/ListRecords/resumptionToken"]
34
39
  assert_equal 101, doc.elements["/OAI-PMH/ListRecords"].to_a.size
@@ -38,5 +43,5 @@ class ResumptionTokenFunctionalTest < Test::Unit::TestCase
38
43
  assert_nil doc.elements["/OAI-PMH/ListRecords/resumptionToken"]
39
44
  assert_equal 100, doc.elements["/OAI-PMH/ListRecords"].to_a.size
40
45
  end
41
-
46
+
42
47
  end
@@ -13,64 +13,98 @@ class OaiTest < Test::Unit::TestCase
13
13
  assert_equal "oai:test:13900", doc.elements['OAI-PMH/Identify/description/oai-identifier/sampleIdentifier'].text
14
14
  assert_not_nil doc.elements['OAI-PMH/Identify/my_custom_xml']
15
15
  end
16
-
16
+
17
17
  def test_list_identifiers_for_correct_xml
18
18
  doc = REXML::Document.new(@mapped_provider.list_identifiers)
19
+ assert_not_nil doc.elements['OAI-PMH/request']
20
+ assert_not_nil doc.elements['OAI-PMH/request/@verb']
19
21
  assert_not_nil doc.elements['OAI-PMH/ListIdentifiers']
20
22
  assert_not_nil doc.elements['OAI-PMH/ListIdentifiers/header']
21
23
  assert_not_nil doc.elements['OAI-PMH/ListIdentifiers/header/identifier']
22
24
  assert_not_nil doc.elements['OAI-PMH/ListIdentifiers/header/datestamp']
23
25
  assert_not_nil doc.elements['OAI-PMH/ListIdentifiers/header/setSpec']
24
26
  end
25
-
27
+
26
28
  def test_list_records_for_correct_xml
27
- doc = REXML::Document.new(@mapped_provider.list_records)
29
+ doc = REXML::Document.new(
30
+ @mapped_provider.list_records(:metadata_prefix => 'oai_dc'))
31
+ assert_not_nil doc.elements['OAI-PMH/request']
32
+ assert_not_nil doc.elements['OAI-PMH/request/@verb']
33
+ assert_not_nil doc.elements['OAI-PMH/request/@metadata_prefix']
28
34
  assert_not_nil doc.elements['OAI-PMH/ListRecords/record/header']
29
35
  assert_not_nil doc.elements['OAI-PMH/ListRecords/record/metadata']
30
36
  end
31
-
37
+
32
38
  def test_mapped_source
33
- assert_nothing_raised { REXML::Document.new(@mapped_provider.list_records) }
34
- doc = REXML::Document.new(@mapped_provider.list_records)
39
+ assert_nothing_raised do
40
+ REXML::Document.new(
41
+ @mapped_provider.list_records(:metadata_prefix => 'oai_dc'))
42
+ end
43
+ doc = REXML::Document.new(
44
+ @mapped_provider.list_records(:metadata_prefix => 'oai_dc'))
35
45
  assert_equal "title_0", doc.elements['OAI-PMH/ListRecords/record/metadata/oai_dc:dc/dc:creator'].text
36
46
  assert_equal "creator_0", doc.elements['OAI-PMH/ListRecords/record/metadata/oai_dc:dc/dc:title'].text
37
47
  assert_equal "tag_0", doc.elements['OAI-PMH/ListRecords/record/metadata/oai_dc:dc/dc:subject'].text
38
48
  end
39
-
49
+
40
50
  def test_from
41
- assert_nothing_raised { REXML::Document.new(@big_provider.list_records) }
51
+ assert_nothing_raised do
52
+ REXML::Document.new(
53
+ @big_provider.list_records(:metadata_prefix => 'oai_dc'))
54
+ end
42
55
  doc = REXML::Document.new(
43
- @big_provider.list_records(:from => Time.parse("February 1 2001"))
44
- )
56
+ @big_provider.list_records(
57
+ :metadata_prefix => 'oai_dc',
58
+ :from => Time.parse("February 1 2001"))
59
+ )
45
60
  assert_equal 100, doc.elements['OAI-PMH/ListRecords'].to_a.size
46
61
 
47
62
  doc = REXML::Document.new(
48
- @big_provider.list_records(:from => Time.parse("January 1 2001"))
49
- )
63
+ @big_provider.list_records(
64
+ :metadata_prefix => 'oai_dc',
65
+ :from => Time.parse("January 1 2001"))
66
+ )
50
67
  assert_equal 200, doc.elements['OAI-PMH/ListRecords'].to_a.size
51
68
  end
52
-
69
+
53
70
  def test_until
54
- assert_nothing_raised { REXML::Document.new(@big_provider.list_records) }
71
+ assert_nothing_raised do
72
+ REXML::Document.new(
73
+ @big_provider.list_records(:metadata_prefix => 'oai_dc'))
74
+ end
55
75
  doc = REXML::Document.new(
56
- @big_provider.list_records(:until => Time.parse("November 1 2000"))
57
- )
76
+ @big_provider.list_records(
77
+ :metadata_prefix => 'oai_dc', :until => Time.parse("November 1 2000"))
78
+ )
58
79
  assert_equal 100, doc.elements['OAI-PMH/ListRecords'].to_a.size
59
80
  end
60
-
81
+
61
82
  def test_from_and_until
62
- assert_nothing_raised { REXML::Document.new(@big_provider.list_records) }
83
+ assert_nothing_raised do
84
+ REXML::Document.new(
85
+ @big_provider.list_records(:metadata_prefix => 'oai_dc'))
86
+ end
63
87
  doc = REXML::Document.new(
64
- @big_provider.list_records(:from => Time.parse("November 1 2000"),
88
+ @big_provider.list_records(
89
+ :metadata_prefix => 'oai_dc',
90
+ :from => Time.parse("November 1 2000"),
65
91
  :until => Time.parse("November 30 2000"))
66
- )
92
+ )
93
+
94
+ assert_not_nil doc.elements['OAI-PMH/request']
95
+ assert_not_nil doc.elements['OAI-PMH/request/@verb']
96
+ assert_not_nil doc.elements['OAI-PMH/request/@from']
97
+ assert_not_nil doc.elements['OAI-PMH/request/@until']
98
+
67
99
  assert_equal 100, doc.elements['OAI-PMH/ListRecords'].to_a.size
68
100
 
69
101
  doc = REXML::Document.new(
70
- @big_provider.list_records(:from => Time.parse("December 1 2000"),
71
- :until => Time.parse("December 31 2000"))
72
- )
102
+ @big_provider.list_records(
103
+ :metadata_prefix => 'oai_dc',
104
+ :from => Time.parse("December 1 2000"),
105
+ :until => Time.parse("December 31 2000"))
106
+ )
73
107
  assert_equal 100, doc.elements['OAI-PMH/ListRecords'].to_a.size
74
108
  end
75
-
109
+
76
110
  end