libis-services 1.0.5 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,10 +57,14 @@ 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
 
63
+ before :each do
64
+ # noinspection RubyResolve
65
+ collection_service.authenticate(credentials.admin.user, credentials.admin.password, credentials.admin.institute)
66
+ end
67
+
70
68
  context 'existing collections' do
71
69
 
72
70
  let(:collection_data) { {
@@ -108,7 +106,7 @@ describe 'Rosetta Collection Service' do
108
106
  context 'collections CRUD' do
109
107
 
110
108
  let(:collection_data) { {
111
- name: 'New test collection',
109
+ name: 'Test API collection',
112
110
  parent_id: parent_id,
113
111
  collection_order: 0,
114
112
  md_dc: {
@@ -126,9 +124,7 @@ describe 'Rosetta Collection Service' do
126
124
  },
127
125
  md_source: [],
128
126
  navigate: true,
129
- publish: false,
130
- external_id: '54321',
131
- external_system: 'Scope'
127
+ publish: false
132
128
  } }
133
129
 
134
130
  let(:new_collection) { collection_service.find(parent_name + '/' + collection_data[:name]) }
@@ -173,8 +169,8 @@ describe 'Rosetta Collection Service' do
173
169
  end
174
170
 
175
171
  it 'retrieve new collection' do
176
- puts new_collection.to_hash
177
- puts new_collection_data
172
+ # puts new_collection.to_hash
173
+ # puts new_collection_data
178
174
  expect(new_collection.to_hash).to match_collection(new_collection_data)
179
175
  end
180
176
 
@@ -193,13 +189,6 @@ describe 'Rosetta Collection Service' do
193
189
 
194
190
  context 'check errors' do
195
191
 
196
- it 'not authorized' do
197
- collection_service.pds_handle = 'foobar'
198
- expect do
199
- collection_service.create({name: 'foo'})
200
- end.to raise_error(Libis::Services::SoapError, /user_authorize_exception.*Invalid PDS Handle Number:foobar/)
201
- end
202
-
203
192
  it 'invalid collection info' do
204
193
  expect do
205
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
@@ -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
 
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
  require_relative 'spec_helper'
3
3
  require 'yaml'
4
+ require 'awesome_print'
4
5
 
5
6
  require 'libis/tools/config_file'
6
7
 
7
- require 'libis/services/rosetta/pds_handler'
8
8
  require 'libis/services/rosetta/producer_handler'
9
9
 
10
10
  describe 'Rosetta Producer Service' do
@@ -21,30 +21,25 @@ describe 'Rosetta Producer Service' do
21
21
  # noinspection RubyResolve
22
22
  let(:admin_ins) {admin.institute}
23
23
 
24
- let(:pds_handler) do
25
- # noinspection RubyResolve
26
- Libis::Services::Rosetta::PdsHandler.new(credentials.pds_url)
27
- end
28
-
29
- let(:handle) {pds_handler.login(admin_usr, admin_pwd, admin_ins)}
30
-
31
24
  let(:contact_info) {{user_id: credentials.contact.user_id, name: 'Test User'}}
32
25
  # noinspection RubyResolve
33
26
  subject(:producer_handler) do
34
27
  handler = Libis::Services::Rosetta::ProducerHandler.new credentials.rosetta_url,
35
28
  log: credentials.debug,
36
29
  log_level: credentials.debug_level
37
- handler.pds_handle = handle
38
30
  handler
39
31
  end
40
32
 
41
33
  before :each do
42
- producer_handler.pds_handle = handle
34
+ # noinspection RubyResolve
35
+ producer_handler.authenticate(credentials.admin.user, credentials.admin.password, credentials.admin.institute)
43
36
  end
44
37
 
45
38
  context 'user info' do
39
+ # noinspection RubyBlockToMethodReference
46
40
  let(:user_id) {admin_uid}
47
41
 
42
+ # noinspection RubyBlockToMethodReference
48
43
  let(:user_name) {admin_usr}
49
44
 
50
45
  it 'gets user id' do
@@ -69,6 +64,7 @@ describe 'Rosetta Producer Service' do
69
64
 
70
65
  let(:producer_id) {credentials.producer.id}
71
66
  let(:producer_data) {credentials.producer.data.to_hash}
67
+ # noinspection RubyArgCount
72
68
  let(:producer_info) {::Libis::Services::Rosetta::Producer.new(producer_data).to_hash}
73
69
  let(:updated_info) {{email: 'nomail@mail.com', telephone_2: '0032 16 32 22 22'}}
74
70
  let(:new_producer_info) {
@@ -86,6 +82,7 @@ describe 'Rosetta Producer Service' do
86
82
 
87
83
  it 'get producer' do
88
84
  result = producer_handler.producer(producer_id)
85
+ # ap result
89
86
  expect(result).not_to be_nil
90
87
  expect(result.to_hash).to match producer_data
91
88
  expect(producer_data).to match result.to_hash
@@ -94,7 +91,7 @@ describe 'Rosetta Producer Service' do
94
91
  it 'create producer' do
95
92
  result = producer_handler.new_producer(new_producer_info)
96
93
  expect(result).not_to be_nil
97
- expect(result).to match /^\d+$/
94
+ expect(result).to match(/^\d+$/)
98
95
  new_producer_id(result)
99
96
  end
100
97
 
@@ -136,19 +133,21 @@ describe 'Rosetta Producer Service' do
136
133
  email_address: 'test@mail.com',
137
134
  street: 'Willem de Croylaan 54',
138
135
  city: 'Heverlee',
139
- zip: 3001,
136
+ zip: '3001',
140
137
  country: 'Belgium',
141
138
  telephone_1: '0032 16 32 22 66',
142
139
  user_group: 'producer_agents'
143
140
  }}
144
141
  let(:new_agent) {
145
142
  data = new_agent_data.dup
146
- data[:password] = data[:password_verify] = 'abc123ABC'
147
- Libis::Services::Rosetta::User.new(data).to_hash
143
+ # data[:password] = data[:password_verify] = 'abc123ABC'
144
+ # noinspection RubyArgCount
145
+ Libis::Services::Rosetta::ProducerAgent.new(data).to_hash
148
146
  }
149
147
 
150
148
  # noinspection RubyResolve
151
149
  let(:agent_data) {credentials.producer_agent.data.to_hash}
150
+ # noinspection RubyArgCount
152
151
  let(:agent) {::Libis::Services::Rosetta::User.new(agent_data)}
153
152
  # noinspection RubyResolve
154
153
  let(:agent_id) {credentials.producer_agent.user_id}
@@ -157,54 +156,59 @@ describe 'Rosetta Producer Service' do
157
156
 
158
157
  def new_agent_id(val = nil)
159
158
  $new_agent_id = val.to_i if val
160
- "#{$new_agent_id}"
159
+ $new_agent_id
161
160
  end
162
161
 
163
162
  it 'get info' do
164
163
  result = producer_handler.agent(agent_id)
165
164
  expect(result).not_to be_nil
166
- expect(result.to_hash).to include agent_data
167
- end
168
-
169
- it 'create' do
170
- result = producer_handler.new_agent new_agent
171
- expect(result).not_to be_nil
172
- expect(result).to match /^\d+$/
173
- new_agent_id result
174
- end
175
-
176
- it 'get info' do
177
- result = producer_handler.agent(new_agent_id)
178
- expect(result).not_to be_nil
179
- expect(result.to_hash).to include new_agent_data
165
+ # ap result.to_hash
166
+ # ap agent_data
167
+ expect(result.to_hash).to match agent_data
180
168
  end
181
169
 
182
- it 'update info' do
183
- # update data
184
- updated_agent = new_agent_data.dup
185
- updated_agent[:email_address] = 'other@mail.com'
186
- result = producer_handler.agent(new_agent_id, updated_agent)
187
- expect(result).not_to be_nil
188
- expect(result).to eq new_agent_id
189
-
190
- # retrieve updated data
191
- result = producer_handler.agent(new_agent_id)
192
- expect(result).not_to be_nil
193
- expect(result.to_hash).to match updated_agent
194
- end
195
-
196
-
197
- it 'delete' do
198
- result = producer_handler.delete_agent new_agent_id
199
- expect(result).not_to be_nil
200
- expect(result).to eq new_agent_id
201
- result = producer_handler.agent(new_agent_id)
202
- expect(result).to be_nil
203
- 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
204
207
 
205
208
  it 'get producers' do
206
209
  result = producer_handler.agent_producers agent_id, agent_ins
207
210
  expect(result).not_to be_nil
211
+ # noinspection RubyResolve
208
212
  expect(result).to eq [{id: credentials.producer.id, description: credentials.producer.data.authoritative_name}]
209
213
  end
210
214
 
@@ -215,6 +219,7 @@ describe 'Rosetta Producer Service' do
215
219
  let(:contact_id) {credentials.contact.user_id}
216
220
  let(:contact_info) {credentials.contact.data.to_hash}
217
221
  let(:new_contact) {
222
+ # noinspection RubyArgCount
218
223
  ::Libis::Services::Rosetta::User.new(
219
224
  first_name: 'New',
220
225
  last_name: 'Contact',
@@ -245,7 +250,7 @@ describe 'Rosetta Producer Service' do
245
250
  it 'create' do
246
251
  result = producer_handler.new_contact new_contact
247
252
  expect(result).not_to be_nil
248
- expect(result).to match /^\d+$/
253
+ expect(result).to match(/^\d+$/)
249
254
  new_contact_id result
250
255
  end
251
256