libis-services 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,7 +22,7 @@ describe 'Rosetta Services' do
22
22
  expect {handler.producer(producer_id)}.to raise_error(Libis::Services::ServiceError)
23
23
  end
24
24
 
25
- let!(:credentials) {Libis::Tools::ConfigFile.new File.join(File.dirname(__FILE__), 'credentials-test.yml')}
25
+ let!(:credentials) {Libis::Tools::ConfigFile.new File.join(File.dirname(__FILE__), 'credentials-prod.yml')}
26
26
 
27
27
  # noinspection RubyResolve
28
28
  let(:admin) {credentials.admin}
@@ -34,6 +34,7 @@ describe 'Rosetta Services' do
34
34
  let(:admin_pwd) {admin.password}
35
35
  # noinspection RubyResolve
36
36
  let(:admin_ins) {admin.institute}
37
+ let(:admin_pds_ins) {admin.institute_pds}
37
38
 
38
39
  let(:bad_cred) { 'deadbeaf' }
39
40
 
@@ -99,7 +100,7 @@ describe 'Rosetta Services' do
99
100
  end
100
101
 
101
102
  describe 'with correct credentials' do
102
- let(:handle) {pds_handler.login(admin_usr, admin_pwd, admin_ins)}
103
+ let(:handle) {pds_handler.login(admin_usr, admin_pwd, admin_pds_ins)}
103
104
 
104
105
  it 'should login and return a handle' do
105
106
  expect(handle).to_not be_nil
@@ -109,7 +110,7 @@ describe 'Rosetta Services' do
109
110
  bor_info = pds_handler.user_info handle
110
111
  expect(bor_info[:bor_info][:id]).to eq admin_usr
111
112
  expect(bor_info[:bor_info][:name]).to eq admin_usr
112
- expect(bor_info[:bor_info][:institute]).to eq admin_ins
113
+ expect(bor_info[:bor_info][:institute]).to eq admin_pds_ins
113
114
 
114
115
  end
115
116
 
@@ -125,7 +126,7 @@ describe 'Rosetta Services' do
125
126
  end
126
127
 
127
128
  describe 'with wrong user name' do
128
- let(:handle) {pds_handler.login(bad_cred, admin_pwd, admin_ins)}
129
+ let(:handle) {pds_handler.login(bad_cred, admin_pwd, admin_pds_ins)}
129
130
 
130
131
  it 'should not login' do
131
132
  expect(handle).to be_nil
@@ -4,7 +4,6 @@ require_relative 'spec_helper'
4
4
  require 'libis/tools/config_file'
5
5
  require 'libis/tools/extend/hash'
6
6
 
7
- require 'libis/services/rosetta/pds_handler'
8
7
  require 'libis/services/rosetta/collection_handler'
9
8
 
10
9
  require 'rspec/matchers'
@@ -39,11 +38,6 @@ end
39
38
  describe 'Rosetta Collection Service' do
40
39
 
41
40
  let(:credentials) { Libis::Tools::ConfigFile.new File.join(File.dirname(__FILE__), 'credentials-test.yml') }
42
- let(:pds_handler) do
43
- # noinspection RubyResolve
44
- Libis::Services::Rosetta::PdsHandler.new(credentials.pds_url)
45
- end
46
-
47
41
  let(:handle) do
48
42
  # noinspection RubyResolve
49
43
  pds_handler.login(
@@ -63,7 +57,6 @@ describe 'Rosetta Collection Service' do
63
57
  collection_service = Libis::Services::Rosetta::CollectionHandler.new credentials.rosetta_url,
64
58
  log: credentials.debug,
65
59
  log_level: credentials.debug_level
66
- # collection_service.pds_handle = handle
67
60
  collection_service
68
61
  end
69
62
 
@@ -196,13 +189,6 @@ describe 'Rosetta Collection Service' do
196
189
 
197
190
  context 'check errors' do
198
191
 
199
- it 'not authorized' do
200
- collection_service.pds_handle = 'foobar'
201
- expect do
202
- collection_service.create({name: 'foo'})
203
- end.to raise_error(Libis::Services::SoapError, /user_authorize_exception.*Invalid PDS Handle Number:foobar/)
204
- end
205
-
206
192
  it 'invalid collection info' do
207
193
  expect do
208
194
  collection_service.create({name: 'foo', parent_id: 0})
@@ -5,26 +5,13 @@ require 'awesome_print'
5
5
  require 'pp'
6
6
 
7
7
  require 'libis/tools/config_file'
8
- require 'libis/services/rosetta/pds_handler'
9
8
  require 'libis/services/rosetta/ie_handler'
10
9
 
11
10
  require_relative 'ie_data'
11
+
12
12
  describe 'Rosetta IE Service' do
13
13
 
14
14
  let(:credentials) { Libis::Tools::ConfigFile.new File.join(File.dirname(__FILE__), 'credentials-test.yml') }
15
- let(:pds_handler) do
16
- # noinspection RubyResolve
17
- Libis::Services::Rosetta::PdsHandler.new(credentials.pds_url)
18
- end
19
-
20
- let(:handle) do
21
- # noinspection RubyResolve
22
- pds_handler.login(
23
- credentials.admin.user,
24
- credentials.admin.password,
25
- credentials.admin.institute
26
- )
27
- end
28
15
 
29
16
  subject(:ie_handler) do
30
17
  # noinspection RubyResolve
@@ -34,14 +21,14 @@ describe 'Rosetta IE Service' do
34
21
  end
35
22
 
36
23
  before :each do
37
- ie_handler.pds_handle = handle
24
+ # noinspection RubyResolve
25
+ ie_handler.authenticate(credentials.admin.user, credentials.admin.password, credentials.admin.institute)
38
26
  end
39
27
 
40
28
  it 'should get IE info' do
41
29
 
42
30
  mets = ie_handler.get_mets('IE403595')
43
31
  expect(mets).not_to be_nil
44
- # ap mets
45
32
  expect(mets).to deep_include(expected_mets)
46
33
  # check_container expected_mets, mets
47
34
  end
@@ -50,7 +37,6 @@ describe 'Rosetta IE Service' do
50
37
 
51
38
  metadata = ie_handler.get_metadata('IE403595')
52
39
  expect(metadata).not_to be_nil
53
- # ap metadata
54
40
  expect(metadata).to deep_include(expected_ies)
55
41
  # check_container(expected_ies, metadata)
56
42
  end
@@ -2,6 +2,7 @@
2
2
  require_relative 'spec_helper'
3
3
 
4
4
  require 'libis/tools/config_file'
5
+ require 'libis/tools/extend/symbol'
5
6
  require 'libis/services/rosetta/oai_pmh'
6
7
 
7
8
  describe 'Rosetta OAI-PMH Service' do
@@ -13,42 +14,80 @@ describe 'Rosetta OAI-PMH Service' do
13
14
  Libis::Services::Rosetta::OaiPmh.new credentials.rosetta_url
14
15
  end
15
16
 
17
+ let(:expected_identify) {
18
+ {
19
+ repository_name: 'LIBIS Teneo Sandbox Repository',
20
+ base_url: "#{credentials.rosetta_url}/oaiprovider/request"
21
+ }
22
+ }
23
+
24
+ let(:expected_metadata_formats) {
25
+ [ 'oai_dc' ]
26
+ }
27
+
16
28
  let(:expected_sets) {
17
29
  [
18
- {name:'TESTINS-collections', spec: 'TESTINS-collections'}
30
+ 'TESTINS-collections',
31
+ 'INS00-collections'
19
32
  ]
20
33
  }
21
34
 
22
35
  let(:expected_collections) {
23
36
  [
24
- 'Kerk & Leven',
25
- 'Kerk en leven. Bisdom Antwerpen (0991).',
37
+ 'E-periodieken',
38
+ 'Parochiebladen',
39
+ 'Kerk en leven. Puurs (4635)',
26
40
  ]
27
41
  }
28
42
 
43
+ let(:expected_identifiers) {
44
+ [ 'oai:sandbox.teneo.libis.be:IE403595']
45
+ }
46
+
29
47
  let(:expected_records) {
30
48
  [
31
49
  {
32
- id: 'oai:d4I1-pubam:IE405650',
50
+ header: {identifier: 'oai:sandbox.teneo.libis.be:IE403595'},
51
+ metadata: {
52
+ 'metadata' => {
53
+ 'oai_dc:dc' => {
54
+ 'dc:title' => 'Denemarken 2015',
55
+ 'dcterms:spatial' => ['Denemarken', 'Fyn', 'Sinebjerg']
56
+ }
57
+ }
58
+ }
33
59
  }
34
60
  ]
35
61
  }
36
62
 
63
+ it 'should identify' do
64
+ id = oai_handler.identify
65
+ expect(id).to deep_include(expected_identify)
66
+ end
67
+
68
+ it 'should get metata formats' do
69
+ formats = oai_handler.metadata_formats
70
+ expect(formats[:entries].map(&:dig.(:prefix)).compact).to deep_include(expected_metadata_formats)
71
+ end
72
+
37
73
  it 'should get set list' do
38
74
  sets = oai_handler.sets
39
- expect(sets[:entries]).to deep_include(expected_sets)
75
+ expect(sets[:entries].map(&:dig.(:name)).compact).to deep_include(expected_sets)
40
76
  end
41
77
 
42
78
  it 'should get list of collections' do
43
- status = {}
44
- collections = oai_handler.collections('TESTINS', status)
45
- expect(collections).to deep_include(expected_collections)
79
+ collections = oai_handler.collections('KADOC')
80
+ expect(collections[:entries].map(&:dig.(:metadata, 'metadata', 'oai_dc:dc', 'dc:title')).compact).to deep_include(expected_collections)
81
+ end
82
+
83
+ it 'should get list of identifiers' do
84
+ ids = oai_handler.identifiers(set: 'test_data', from: '2020-01-01')
85
+ expect(ids[:entries].map(&:dig.(:identifier)).compact).to deep_include(expected_identifiers)
46
86
  end
47
87
 
48
88
  it 'should get list of records' do
49
- status = {}
50
- records = oai_handler.records('test_data', status)
51
- expect(records).to deep_include(expected_records)
89
+ records = oai_handler.records(set: 'test_data', from: '2020-01-01')
90
+ expect(records[:entries]).to deep_include(expected_records)
52
91
  end
53
92
 
54
93
  end
@@ -10,13 +10,13 @@ require 'libis/services/rosetta/deposit_handler'
10
10
 
11
11
  describe 'Rosetta PDS Service' do
12
12
 
13
- let!(:credentials) { Libis::Tools::ConfigFile.new File.join(File.dirname(__FILE__), 'credentials-test.yml') }
13
+ let!(:credentials) { Libis::Tools::ConfigFile.new File.join(File.dirname(__FILE__), 'credentials-prod.yml') }
14
14
  let!(:pds_handler) do
15
15
  # noinspection RubyResolve
16
16
  Libis::Services::Rosetta::PdsHandler.new(credentials.pds_url)
17
17
  end
18
18
 
19
- let(:handle) { pds_handler.login(admin_usr, admin_pwd, admin_ins) }
19
+ let(:handle) { pds_handler.login(admin_usr, admin_pwd, admin_pds_ins) }
20
20
 
21
21
  # noinspection RubyResolve
22
22
  let(:admin) { credentials.admin }
@@ -26,6 +26,7 @@ describe 'Rosetta PDS Service' do
26
26
  let(:admin_pwd) {admin.password}
27
27
  # noinspection RubyResolve
28
28
  let(:admin_ins) {admin.institute}
29
+ let(:admin_pds_ins) {admin.institute_pds}
29
30
 
30
31
  it 'should login and return a handle' do
31
32
  expect(handle).to_not be_nil
@@ -62,7 +63,7 @@ describe 'Rosetta PDS Service' do
62
63
  bor_info = pds_handler.user_info handle
63
64
  expect(bor_info[:bor_info][:id]).to eq admin_usr
64
65
  expect(bor_info[:bor_info][:name]).to eq admin_usr
65
- expect(bor_info[:bor_info][:institute]).to eq admin_ins
66
+ expect(bor_info[:bor_info][:institute]).to eq admin_pds_ins
66
67
 
67
68
  end
68
69
 
@@ -5,7 +5,6 @@ require 'awesome_print'
5
5
 
6
6
  require 'libis/tools/config_file'
7
7
 
8
- require 'libis/services/rosetta/pds_handler'
9
8
  require 'libis/services/rosetta/producer_handler'
10
9
 
11
10
  describe 'Rosetta Producer Service' do
@@ -22,25 +21,18 @@ describe 'Rosetta Producer Service' do
22
21
  # noinspection RubyResolve
23
22
  let(:admin_ins) {admin.institute}
24
23
 
25
- let(:pds_handler) do
26
- # noinspection RubyResolve
27
- Libis::Services::Rosetta::PdsHandler.new(credentials.pds_url)
28
- end
29
-
30
- let(:handle) {pds_handler.login(admin_usr, admin_pwd, admin_ins)}
31
-
32
24
  let(:contact_info) {{user_id: credentials.contact.user_id, name: 'Test User'}}
33
25
  # noinspection RubyResolve
34
26
  subject(:producer_handler) do
35
27
  handler = Libis::Services::Rosetta::ProducerHandler.new credentials.rosetta_url,
36
28
  log: credentials.debug,
37
29
  log_level: credentials.debug_level
38
- handler.pds_handle = handle
39
30
  handler
40
31
  end
41
32
 
42
33
  before :each do
43
- producer_handler.pds_handle = handle
34
+ # noinspection RubyResolve
35
+ producer_handler.authenticate(credentials.admin.user, credentials.admin.password, credentials.admin.institute)
44
36
  end
45
37
 
46
38
  context 'user info' do
@@ -99,7 +91,7 @@ describe 'Rosetta Producer Service' do
99
91
  it 'create producer' do
100
92
  result = producer_handler.new_producer(new_producer_info)
101
93
  expect(result).not_to be_nil
102
- expect(result).to match /^\d+$/
94
+ expect(result).to match(/^\d+$/)
103
95
  new_producer_id(result)
104
96
  end
105
97
 
@@ -164,7 +156,7 @@ describe 'Rosetta Producer Service' do
164
156
 
165
157
  def new_agent_id(val = nil)
166
158
  $new_agent_id = val.to_i if val
167
- "#{$new_agent_id}"
159
+ $new_agent_id
168
160
  end
169
161
 
170
162
  it 'get info' do
@@ -175,41 +167,43 @@ describe 'Rosetta Producer Service' do
175
167
  expect(result.to_hash).to match agent_data
176
168
  end
177
169
 
178
- it 'create' do
179
- result = producer_handler.new_agent new_agent
180
- expect(result).not_to be_nil
181
- expect(result).to match /^\d+$/
182
- new_agent_id result
183
- end
184
-
185
- it 'get info' do
186
- result = producer_handler.agent(new_agent_id)
187
- expect(result).not_to be_nil
188
- expect(result.to_hash).to match new_agent_data
189
- end
190
-
191
- it 'update info' do
192
- # update data
193
- updated_agent = new_agent_data.dup
194
- updated_agent[:email_address] = 'other@mail.com'
195
- result = producer_handler.agent(new_agent_id, updated_agent)
196
- expect(result).not_to be_nil
197
- expect(result).to eq new_agent_id
198
-
199
- # retrieve updated data
200
- result = producer_handler.agent(new_agent_id)
201
- expect(result).not_to be_nil
202
- expect(result.to_hash).to match updated_agent
203
- end
204
-
205
-
206
- it 'delete' do
207
- result = producer_handler.delete_agent new_agent_id
208
- expect(result).not_to be_nil
209
- expect(result).to eq new_agent_id
210
- result = producer_handler.agent(new_agent_id)
211
- expect(result).to be_nil
212
- end
170
+ # DISABLED: Rosetta API does noet work anymore as expected
171
+
172
+ # it 'create' do
173
+ # result = producer_handler.new_agent new_agent
174
+ # expect(result).not_to be_nil
175
+ # expect(result).to match(/^\d+$/)
176
+ # new_agent_id result
177
+ # end
178
+
179
+ # it 'get info' do
180
+ # result = producer_handler.agent(new_agent_id)
181
+ # expect(result).not_to be_nil
182
+ # expect(result.to_hash).to match new_agent_data
183
+ # end
184
+
185
+ # it 'update info' do
186
+ # # update data
187
+ # updated_agent = new_agent_data.dup
188
+ # updated_agent[:email_address] = 'other@mail.com'
189
+ # result = producer_handler.agent(new_agent_id, updated_agent)
190
+ # expect(result).not_to be_nil
191
+ # expect(result).to eq new_agent_id
192
+
193
+ # # retrieve updated data
194
+ # result = producer_handler.agent(new_agent_id)
195
+ # expect(result).not_to be_nil
196
+ # expect(result.to_hash).to match updated_agent
197
+ # end
198
+
199
+
200
+ # it 'delete' do
201
+ # result = producer_handler.delete_agent new_agent_id
202
+ # expect(result).not_to be_nil
203
+ # expect(result).to eq new_agent_id
204
+ # result = producer_handler.agent(new_agent_id)
205
+ # expect(result).to be_nil
206
+ # end
213
207
 
214
208
  it 'get producers' do
215
209
  result = producer_handler.agent_producers agent_id, agent_ins
@@ -256,7 +250,7 @@ describe 'Rosetta Producer Service' do
256
250
  it 'create' do
257
251
  result = producer_handler.new_contact new_contact
258
252
  expect(result).not_to be_nil
259
- expect(result).to match /^\d+$/
253
+ expect(result).to match(/^\d+$/)
260
254
  new_contact_id result
261
255
  end
262
256
 
@@ -18,7 +18,7 @@ describe 'Scope search service' do
18
18
  it 'by repcode' do
19
19
  data = {
20
20
  'dc:title' => 'Archief Sint-Vincentius a Paulogenootschap, Conferentie Onze-Lieve-Vrouw van de Rozenkrans Antwerpen',
21
- 'dc:identifier' => ['BE/942855/580 (ref.code)'],
21
+ 'dc:identifier' => ['BE/942855/580'],
22
22
  'dc:source' => ['BE/942855']
23
23
  }
24
24
  result = subject.query 'BE-942855-580', type: 'REPCODE'
@@ -29,7 +29,7 @@ describe 'Scope search service' do
29
29
  it 'by id' do
30
30
  data = {
31
31
  'dc:title' => 'Archief Constant Guillaume Van Crombrugghe',
32
- 'dc:identifier' => ['BE/942855/1569 (ref.code)'],
32
+ 'dc:identifier' => ['BE/942855/1569'],
33
33
  'dc:source' => ['BE/942855/1569']
34
34
  }
35
35
  result = subject.query '332785', type: 'ID'
data/spec/spec_helper.rb CHANGED
@@ -17,6 +17,7 @@ RSpec::Matchers.define :deep_include do
17
17
  match {|actual| deep_include?(actual, expected)}
18
18
 
19
19
  def deep_include?(actual, expected, path = [])
20
+
20
21
  return true if actual == expected
21
22
 
22
23
  @failing_actual = actual
@@ -25,45 +26,71 @@ RSpec::Matchers.define :deep_include do
25
26
 
26
27
  case expected
27
28
  when Array
28
- return false unless actual.is_a? Array
29
+ unless actual.is_a? Array
30
+ @failure ||= :not_an_array
31
+ return false
32
+ end
29
33
  expected.each_with_index do |expected_item, index|
30
34
  match_found = actual.any? do |actual_item|
31
35
  deep_include? actual_item, expected_item, path + [index]
32
36
  end
33
37
  unless match_found
34
- @failing_array = actual
35
- @failing_array_path = path + [index]
36
- @failing_expected_array_item = expected_item
38
+ @failure ||= :item_not_found
39
+ @failing_array_item = expected_item
37
40
  return false
38
41
  end
39
42
  end
40
43
  when Hash
41
- return false unless actual.is_a? Hash
44
+ unless actual.is_a? Hash
45
+ @failure ||= :not_a_hash
46
+ return false
47
+ end
42
48
  expected.all? do |key, expected_value|
43
- return false unless actual.has_key? key
44
- deep_include? actual[key], expected_value, path + [key]
49
+ unless actual.has_key? key
50
+ @failure ||= :key_not_found
51
+ @failing_key = key
52
+ return false
53
+ end
54
+ v = deep_include? actual[key], expected_value, path + [key]
55
+ v
45
56
  end
46
57
  else
58
+ @failure ||= :no_match
47
59
  false
48
60
  end
61
+
49
62
  end
50
63
 
51
64
  failure_message do |_actual|
52
- if @failing_array_path
53
- path = @failing_array_path.map {|p| "[#{p.inspect}]"}.join
54
- path = "root" if path.blank?
55
- message = "Actual array did not include value at #{path}: \n" +
56
- " expected #{@failing_expected_array_item.inspect}\n" +
57
- " but matching value not found in array: #{@failing_array}\n"
65
+ path = @failing_path.map {|p| "[#{p.inspect}]"}.join
66
+ path = "root" if path.blank?
67
+ case @failure
68
+ when :no_match
69
+ "Actual value did not match expected value at #{path}: \n" +
70
+ " expected #{@failing_expected.inspect}\n" +
71
+ " got #{@failing_actual.inspect}\n"
72
+ when :not_an_array
73
+ "Actual object is not an Array at #{path}: \n" +
74
+ " expected: #{@failing_expected.inspect}\n" +
75
+ " got: #{@failing_actual}"
76
+ when :not_a_hash
77
+ "Actual object is not a Hash at #{path}: \n" +
78
+ " expected: #{@failing_expected.inspect}\n" +
79
+ " got: #{@failing_actual}"
80
+ when :item_not_found
81
+ "Actual array did not include value at #{path}: \n" +
82
+ " expected #{@failing_array_item.inspect}\n" +
83
+ " but matching value not found in array: #{@failing_actual.inspect}\n"
84
+ when :key_not_found
85
+ "Actual hash did not include expected key at #{path}: \n" +
86
+ " key #{@failing_key}\n" +
87
+ " expected #{@failing_expected.inspect}\n" +
88
+ " got #{@failing_actual.inspect}\n"
58
89
  else
59
- path = @failing_path.map {|p| "[#{p.inspect}]"}.join
60
- path = "root" if path.blank?
61
- message = "Actual hash did not include expected value at #{path}: \n" +
62
- " expected #{@failing_expected.inspect}\n" +
63
- " got #{@failing_actual.inspect}\n"
90
+ "Mismatch at #{path}: \n" +
91
+ " expected #{@failing_expected.inspect}\n" +
92
+ " got #{@failing_actual.inspect}\n"
64
93
  end
65
-
66
- message
67
94
  end
68
95
  end
69
96