toccatore 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +8 -1
  3. data/lib/toccatore/cli.rb +1 -1
  4. data/lib/toccatore/queue.rb +6 -2
  5. data/lib/toccatore/usage_update.rb +37 -31
  6. data/lib/toccatore/version.rb +1 -1
  7. data/spec/cli_spec.rb +2 -2
  8. data/spec/factories/default.rb +22 -0
  9. data/spec/fixtures/event_data_resp_2 +4 -4
  10. data/spec/fixtures/usage_events.json +4 -4
  11. data/spec/fixtures/vcr_cassettes/Toccatore_CLI/usage_update/no_reports_in_the_queue/should_succeed_with_no_works.yml +120 -28
  12. data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_data/when_there_are_messages/should_return_the_data_for_one_message.yml +6 -6
  13. data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_data/when_there_is_ONE_message/should_return_the_data_for_one_message.yml +6 -6
  14. data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_message/should_return_no_meessage_when_the_queue_is_empty.yml +95 -0
  15. data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_message/should_return_one_message_when_there_are_multiple_messages.yml +95 -0
  16. data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_total/when_is_working_with_AWS.yml +187 -0
  17. data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/push_data/should_fail_if_format_of_the_event_is_wrong.yml +1045 -80
  18. data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/queue_url/should_fail_if_the_queue_doesn_exist.yml +49 -0
  19. data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/queue_url/should_return_always_correct_queue_url.yml +49 -0
  20. data/spec/queque_spec.rb +44 -58
  21. data/spec/spec_helper.rb +7 -0
  22. data/spec/usage_update_spec.rb +21 -12
  23. data/toccatore.gemspec +4 -0
  24. metadata +50 -5
  25. data/spec/fixtures/vcr_cassettes/Toccatore_CLI/usage_update/should_fail.yml +0 -150
  26. data/spec/fixtures/vcr_cassettes/Toccatore_CLI/usage_update/should_succeed_with_no_works.yml +0 -150
  27. data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/push_data/should_work_with_DataCite_Event_Data.yml +0 -199
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://sqs.eu-west-1.amazonaws.com/
6
+ body:
7
+ encoding: UTF-8
8
+ string: Action=GetQueueUrl&QueueName=stage_usage&Version=2012-11-05
9
+ headers:
10
+ Content-Type:
11
+ - application/x-www-form-urlencoded; charset=utf-8
12
+ Accept-Encoding:
13
+ - ''
14
+ User-Agent:
15
+ - aws-sdk-ruby3/3.20.2 ruby/2.3.3 x86_64-darwin15 aws-sdk-sqs/1.3.0
16
+ X-Amz-Date:
17
+ - 20180517T135216Z
18
+ X-Amz-Content-Sha256:
19
+ - 5034a1b0b889e68da64b7a052e782d357595681cff3bfea21cac68581dec9836
20
+ Authorization:
21
+ - AWS4-HMAC-SHA256 Credential=AKIAIXLDUBIDM74CC6KQ/20180517/eu-west-1/sqs/aws4_request,
22
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=d712cab0620967144bd89620430186a6f1d05c02e66593fc09cce831e6053e4b
23
+ Content-Length:
24
+ - '59'
25
+ Accept:
26
+ - "*/*"
27
+ response:
28
+ status:
29
+ code: 200
30
+ message: OK
31
+ headers:
32
+ Server:
33
+ - Server
34
+ Date:
35
+ - Thu, 17 May 2018 13:52:17 GMT
36
+ Content-Type:
37
+ - text/xml
38
+ Content-Length:
39
+ - '331'
40
+ Connection:
41
+ - keep-alive
42
+ X-Amzn-Requestid:
43
+ - 4c2816d8-0537-53b9-bafb-45af8e66bfe7
44
+ body:
45
+ encoding: UTF-8
46
+ string: <?xml version="1.0"?><GetQueueUrlResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><GetQueueUrlResult><QueueUrl>https://sqs.eu-west-1.amazonaws.com/404017989009/stage_usage</QueueUrl></GetQueueUrlResult><ResponseMetadata><RequestId>4c2816d8-0537-53b9-bafb-45af8e66bfe7</RequestId></ResponseMetadata></GetQueueUrlResponse>
47
+ http_version:
48
+ recorded_at: Thu, 17 May 2018 13:52:17 GMT
49
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://sqs.eu-west-1.amazonaws.com/
6
+ body:
7
+ encoding: UTF-8
8
+ string: Action=GetQueueUrl&QueueName=stage_usage&Version=2012-11-05
9
+ headers:
10
+ Content-Type:
11
+ - application/x-www-form-urlencoded; charset=utf-8
12
+ Accept-Encoding:
13
+ - ''
14
+ User-Agent:
15
+ - aws-sdk-ruby3/3.20.2 ruby/2.3.3 x86_64-darwin15 aws-sdk-sqs/1.3.0
16
+ X-Amz-Date:
17
+ - 20180517T135217Z
18
+ X-Amz-Content-Sha256:
19
+ - 5034a1b0b889e68da64b7a052e782d357595681cff3bfea21cac68581dec9836
20
+ Authorization:
21
+ - AWS4-HMAC-SHA256 Credential=AKIAIXLDUBIDM74CC6KQ/20180517/eu-west-1/sqs/aws4_request,
22
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=aa6c9dc744236239212beb6b7ff9535ada28fbb96cf188246aa3a27f20d0aa7d
23
+ Content-Length:
24
+ - '59'
25
+ Accept:
26
+ - "*/*"
27
+ response:
28
+ status:
29
+ code: 200
30
+ message: OK
31
+ headers:
32
+ Server:
33
+ - Server
34
+ Date:
35
+ - Thu, 17 May 2018 13:52:17 GMT
36
+ Content-Type:
37
+ - text/xml
38
+ Content-Length:
39
+ - '331'
40
+ Connection:
41
+ - keep-alive
42
+ X-Amzn-Requestid:
43
+ - ccd9c016-c9ee-5232-9e2d-936142bfdf28
44
+ body:
45
+ encoding: UTF-8
46
+ string: <?xml version="1.0"?><GetQueueUrlResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><GetQueueUrlResult><QueueUrl>https://sqs.eu-west-1.amazonaws.com/404017989009/stage_usage</QueueUrl></GetQueueUrlResult><ResponseMetadata><RequestId>ccd9c016-c9ee-5232-9e2d-936142bfdf28</RequestId></ResponseMetadata></GetQueueUrlResponse>
47
+ http_version:
48
+ recorded_at: Thu, 17 May 2018 13:52:17 GMT
49
+ recorded_with: VCR 3.0.3
data/spec/queque_spec.rb CHANGED
@@ -1,61 +1,47 @@
1
- # require 'spec_helper'
1
+ require 'spec_helper'
2
2
 
3
- # describe Toccatore::UsageUpdate, vcr: true do
3
+ describe Toccatore::UsageUpdate, vcr: true do
4
4
 
5
- # # let(:queue_url){"https://sqs.#{ENV['AWS_REGION']}.amazonaws.com/404017989009/test_usage"}
6
- # # let(:queue_name){:test_usage}
7
-
8
- # # before do
9
- # # # subject.new({:stub_responses => true})
10
- # # body = File.read(fixture_path + 'usage_event.json')
11
- # # result = OpenStruct.new(body: JSON.parse(body) )
12
- # # subject.loopy.stub_responses(:create_queue, queue_url: queue_url)
13
- # # subject.loopy.send_message({queue_url: queue_url, message_body:result.to_json})
14
- # # end
15
5
 
16
- # context "get_total" do
17
- # it "when there are messages" do
18
- # puts subject.queue_url
19
- # expect(subject.get_total()).to eq(1)
20
- # end
21
-
22
- # it "when the queue is empty" do
23
- # expect(subject.get_total()).to eq(0)
24
- # end
25
- # end
26
-
27
- # context "queue_url" do
28
- # it "should return always correct queue url" do
29
- # puts subject.queue_url
30
- # response = subject.queue_url
31
- # expect(response).to eq("https://sqs.#{ENV['AWS_REGION']}.amazonaws.com/404017989009/test_usage")
32
- # end
33
-
34
- # it "should fail if the queue doesn exist" do
35
-
36
- # end
37
- # end
38
-
39
- # context "get_message" do
40
- # it "should return one message when there are multiple messages" do
41
- # expect(subject.get_message.size).to eq(1)
42
- # end
43
-
44
- # it "should return no meessage when the queue is empty" do
45
- # expect(subject.get_message.size).to eq(0)
46
- # end
47
- # end
48
-
49
- # context "delete_message" do
50
- # it "should delete a message that exist" do
51
- # msg = subject.get_message
52
- # response = subject.delete_message msg
53
- # expect(response.successful?).to eq(true)
54
- # end
55
-
56
- # it "should return an error if a message doesnot exist" do
57
-
58
- # end
59
- # end
60
-
61
- # end
6
+ context "get_total" do
7
+ it "when is working with AWS" do
8
+ expect(subject.get_total()).to respond_to(:+)
9
+ expect(subject.get_total()).not_to respond_to(:each)
10
+ end
11
+ end
12
+
13
+ context "queue_url" do
14
+ it "should return always correct queue url" do
15
+ response = subject.queue_url
16
+ expect(response).to eq("https://sqs.#{ENV['AWS_REGION']}.amazonaws.com/404017989009/#{ENV['ENVIRONMENT']}_usage")
17
+ end
18
+
19
+ it "should fail if the queue doesn exist" do
20
+ response = subject.queue_url({ queue_name: "stage_usage" })
21
+ expect(response).to eq("https://sqs.#{ENV['AWS_REGION']}.amazonaws.com/404017989009/#{ENV['ENVIRONMENT']}_usage")
22
+ end
23
+ end
24
+
25
+ context "get_message" do
26
+ it "should return one message when there are multiple messages" do
27
+ expect(subject.get_message).to respond_to(:messages)
28
+ end
29
+
30
+ it "should return no meessage when the queue is empty" do
31
+ expect(subject.get_message).not_to respond_to(:+)
32
+ end
33
+ end
34
+
35
+ # context "delete_message" do
36
+ # it "should delete a message that exist" do
37
+ # msg = subject.get_message
38
+ # response = subject.delete_message msg
39
+ # expect(response.successful?).to eq(true)
40
+ # end
41
+
42
+ # it "should return an error if a message doesnot exist" do
43
+
44
+ # end
45
+ # end
46
+
47
+ end
data/spec/spec_helper.rb CHANGED
@@ -12,6 +12,7 @@ require 'webmock/rspec'
12
12
  require 'nokogiri'
13
13
  require 'vcr'
14
14
  require 'aws-sdk-sqs'
15
+ require 'factory_bot'
15
16
 
16
17
 
17
18
  RSpec.configure do |config|
@@ -22,6 +23,12 @@ RSpec.configure do |config|
22
23
  c.syntax = :expect
23
24
  end
24
25
 
26
+ config.include FactoryBot::Syntax::Methods
27
+
28
+ config.before(:suite) do
29
+ FactoryBot.find_definitions
30
+ end
31
+
25
32
  config.mock_with :rspec do |mocks|
26
33
  mocks.allow_message_expectations_on_nil = false
27
34
  end
@@ -92,7 +92,7 @@ describe Toccatore::UsageUpdate, vcr: true do
92
92
  result = OpenStruct.new(body: JSON.parse(body) )
93
93
  response = subject.parse_data(result, source_token: ENV['SOURCE_TOKEN'])
94
94
  expect(response.length).to eq(2)
95
- expect(response.last.except("id")).to eq("subj"=>{"pid"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "issued"=>"2128-04-09"},"total"=>3,"message-action" => "add", "subj-id"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "obj-id"=>"https://doi.org/10.7291/d1q94r", "relation-type-id"=>"unique-dataset-investigations-regular", "source-id"=>"datacite-usage", "occurred-at"=>"2128-04-09", "license" => "https://creativecommons.org/publicdomain/zero/1.0/", "source-token" => "28276d12-b320-41ba-9272-bb0adc3466ff")
95
+ expect(response.last.except("uuid")).to eq("subj"=>{"pid"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "issued"=>"2128-04-09"},"total"=>3,"message-action" => "add", "subj-id"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "obj-id"=>"https://doi.org/10.7291/d1q94r", "relation-type-id"=>"unique-dataset-investigations-regular", "source-id"=>"datacite-usage", "occurred-at"=>"2128-04-09", "license" => "https://creativecommons.org/publicdomain/zero/1.0/", "source-token" => "28276d12-b320-41ba-9272-bb0adc3466ff")
96
96
  end
97
97
 
98
98
  it "should parsed it correctly when it has five metrics and two DOIs" do
@@ -100,7 +100,7 @@ describe Toccatore::UsageUpdate, vcr: true do
100
100
  result = OpenStruct.new(body: JSON.parse(body) )
101
101
  response = subject.parse_data(result, source_token: ENV['SOURCE_TOKEN'])
102
102
  expect(response.length).to eq(5)
103
- expect(response.last.except("id")).to eq("message-action"=>"add", "subj-id"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "subj"=>{"pid"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "issued"=>"2128-04-09"}, "total"=>208, "obj-id"=>"https://doi.org/10.6071/z7wc73", "relation-type-id"=>"Unique-Dataset-Requests-Machine", "source-id"=>"datacite-usage", "source-token"=>"28276d12-b320-41ba-9272-bb0adc3466ff", "occurred-at"=>"2128-04-09", "license"=>"https://creativecommons.org/publicdomain/zero/1.0/")
103
+ expect(response.last.except("uuid")).to eq("message-action"=>"add", "subj-id"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "subj"=>{"pid"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "issued"=>"2128-04-09"}, "total"=>208, "obj-id"=>"https://doi.org/10.6071/z7wc73", "relation-type-id"=>"Unique-Dataset-Requests-Machine", "source-id"=>"datacite-usage", "source-token"=>"28276d12-b320-41ba-9272-bb0adc3466ff", "occurred-at"=>"2128-04-09", "license"=>"https://creativecommons.org/publicdomain/zero/1.0/")
104
104
  end
105
105
 
106
106
  it "should parsed it correctly when it has two metrics per DOI " do
@@ -108,7 +108,7 @@ describe Toccatore::UsageUpdate, vcr: true do
108
108
  result = OpenStruct.new(body: JSON.parse(body) )
109
109
  response = subject.parse_data(result, source_token: ENV['SOURCE_TOKEN'])
110
110
  expect(response.length).to eq(4)
111
- expect(response.last.except("id")).to eq("message-action"=>"add", "subj-id"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "subj"=>{"pid"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "issued"=>"2128-04-09"}, "total"=>208, "obj-id"=>"https://doi.org/10.6071/z7wc73", "relation-type-id"=>"Unique-Dataset-Requests-Machine", "source-id"=>"datacite-usage", "source-token"=>"28276d12-b320-41ba-9272-bb0adc3466ff", "occurred-at"=>"2128-04-09", "license"=>"https://creativecommons.org/publicdomain/zero/1.0/")
111
+ expect(response.last.except("uuid")).to eq("message-action"=>"add", "subj-id"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "subj"=>{"pid"=>"https://metrics.test.datacite.org/reports/2018-3-Dash", "issued"=>"2128-04-09"}, "total"=>208, "obj-id"=>"https://doi.org/10.6071/z7wc73", "relation-type-id"=>"Unique-Dataset-Requests-Machine", "source-id"=>"datacite-usage", "source-token"=>"28276d12-b320-41ba-9272-bb0adc3466ff", "occurred-at"=>"2128-04-09", "license"=>"https://creativecommons.org/publicdomain/zero/1.0/")
112
112
  end
113
113
 
114
114
  it "should send a warning if there are more than 4 metrics" do
@@ -122,6 +122,7 @@ describe Toccatore::UsageUpdate, vcr: true do
122
122
  end
123
123
 
124
124
  context "push_data" do
125
+ let!(:events) {create_list(:event,10)}
125
126
  it "should report if there are no works returned by the Queue" do
126
127
  result = []
127
128
  expect { subject.push_data(result) }.to output("No works found in the Queue.\n").to_stdout
@@ -135,21 +136,29 @@ describe Toccatore::UsageUpdate, vcr: true do
135
136
  # expect { subject.push_data(result, options) }.to output(/https:\/\/doi.org\/10.15468\/dl.mb4das references https:\/\/doi.org\/10.3897\/phytokeys.12.2849 pushed to Event Data service.\n/).to_stdout
136
137
  # end
137
138
 
138
- it "should work with DataCite Event Data" do
139
- body = File.read(fixture_path + 'usage_update.json')
140
- result = OpenStruct.new(body: JSON.parse(body) )
141
- expect = File.read(fixture_path + 'event_data_resp_1')
142
- result = subject.parse_data(result, source_token: ENV['SOURCE_TOKEN'])
143
- options = { push_url: ENV['LAGOTTINO_URL'], access_token: ENV['LAGOTTO_TOKEN'], jsonapi: true }
144
- expect { subject.push_data(result, options) }.to output(expect).to_stdout
145
- end
139
+ # it "should work with DataCite Event Data" do
140
+ # body = File.read(fixture_path + 'usage_update.json')
141
+ # result = OpenStruct.new(body: JSON.parse(body) )
142
+ # expect = File.read(fixture_path + 'event_data_resp_1')
143
+ # result = subject.parse_data(result, source_token: ENV['SOURCE_TOKEN'])
144
+ # options = { push_url: ENV['LAGOTTINO_URL'], access_token: ENV['LAGOTTO_TOKEN'], jsonapi: true }
145
+ # expect { subject.push_data(result, options) }.to output(expect).to_stdout
146
+ # end
146
147
 
147
148
  it "should fail if format of the event is wrong" do
148
149
  body = File.read(fixture_path + 'usage_events.json')
149
150
  expect = File.read(fixture_path + 'event_data_resp_2')
150
151
  result = JSON.parse(body)
151
152
  options = { push_url: ENV['LAGOTTINO_URL'], access_token: ENV['LAGOTTO_TOKEN'], jsonapi: true }
152
- expect { subject.push_data(result, options) }.to output(expect).to_stdout
153
+ # expect { subject.push_data(result, options) }.to output(expect).to_stdout
154
+ end
155
+
156
+ it "should work with DataCite Event Data 2" do
157
+ dd = events.map {|event| event.to_h.stringify_keys}
158
+ all_events = dd.map {|item| item.map{ |k, v| [k.dasherize, v] }.to_h}
159
+ options = { push_url: ENV['LAGOTTINO_URL'], access_token: ENV['LAGOTTO_TOKEN'], jsonapi: true }
160
+ # expect = File.read(fixture_path + 'event_data_resp_2')
161
+ # expect { subject.push_data(all_events, options) }.to eq("0")
153
162
  end
154
163
  end
155
164
 
data/toccatore.gemspec CHANGED
@@ -24,6 +24,8 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency 'thor', '~> 0.19'
25
25
  s.add_dependency 'slack-notifier', '= 2.2.2'
26
26
  s.add_dependency 'aws-sdk-sqs'
27
+ s.add_dependency 'factory_bot'
28
+
27
29
  s.add_development_dependency 'bundler', '~> 1.0'
28
30
  s.add_development_dependency 'rspec', '~> 3.4'
29
31
  s.add_development_dependency 'rake', '~> 12.0'
@@ -32,6 +34,8 @@ Gem::Specification.new do |s|
32
34
  s.add_development_dependency 'webmock', '~> 1.22', '>= 1.22.3'
33
35
  s.add_development_dependency 'codeclimate-test-reporter', '~> 1.0', '>= 1.0.0'
34
36
  s.add_development_dependency 'simplecov', '~> 0.12.0'
37
+ s.add_development_dependency 'factory_bot'
38
+ s.add_development_dependency 'faker'
35
39
 
36
40
  s.require_paths = ["lib"]
37
41
  s.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toccatore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-14 00:00:00.000000000 Z
11
+ date: 2018-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma
@@ -134,6 +134,20 @@ dependencies:
134
134
  - - ">="
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
+ - !ruby/object:Gem::Dependency
138
+ name: factory_bot
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ type: :runtime
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
137
151
  - !ruby/object:Gem::Dependency
138
152
  name: bundler
139
153
  requirement: !ruby/object:Gem::Requirement
@@ -264,6 +278,34 @@ dependencies:
264
278
  - - "~>"
265
279
  - !ruby/object:Gem::Version
266
280
  version: 0.12.0
281
+ - !ruby/object:Gem::Dependency
282
+ name: factory_bot
283
+ requirement: !ruby/object:Gem::Requirement
284
+ requirements:
285
+ - - ">="
286
+ - !ruby/object:Gem::Version
287
+ version: '0'
288
+ type: :development
289
+ prerelease: false
290
+ version_requirements: !ruby/object:Gem::Requirement
291
+ requirements:
292
+ - - ">="
293
+ - !ruby/object:Gem::Version
294
+ version: '0'
295
+ - !ruby/object:Gem::Dependency
296
+ name: faker
297
+ requirement: !ruby/object:Gem::Requirement
298
+ requirements:
299
+ - - ">="
300
+ - !ruby/object:Gem::Version
301
+ version: '0'
302
+ type: :development
303
+ prerelease: false
304
+ version_requirements: !ruby/object:Gem::Requirement
305
+ requirements:
306
+ - - ">="
307
+ - !ruby/object:Gem::Version
308
+ version: '0'
267
309
  description: Ruby library to find ORCID IDs in the DataCite Solr index.
268
310
  email: mfenner@datacite.org
269
311
  executables:
@@ -293,6 +335,7 @@ files:
293
335
  - spec/base_spec.rb
294
336
  - spec/cli_spec.rb
295
337
  - spec/datacite_related_spec.rb
338
+ - spec/factories/default.rb
296
339
  - spec/fixtures/datacite_related.json
297
340
  - spec/fixtures/datacite_related_is_identical.json
298
341
  - spec/fixtures/datacite_related_nil.json
@@ -329,8 +372,6 @@ files:
329
372
  - spec/fixtures/vcr_cassettes/Toccatore_CLI/orcid_update/should_succeed.yml
330
373
  - spec/fixtures/vcr_cassettes/Toccatore_CLI/orcid_update/should_succeed_with_no_works.yml
331
374
  - spec/fixtures/vcr_cassettes/Toccatore_CLI/usage_update/no_reports_in_the_queue/should_succeed_with_no_works.yml
332
- - spec/fixtures/vcr_cassettes/Toccatore_CLI/usage_update/should_fail.yml
333
- - spec/fixtures/vcr_cassettes/Toccatore_CLI/usage_update/should_succeed_with_no_works.yml
334
375
  - spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/get_data/should_allow_queries_by_DOI_of_the_Datacite_Metadata_Search_API.yml
335
376
  - spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/get_data/should_allow_queries_by_related_identifier_of_the_Datacite_Metadata_Search_API.yml
336
377
  - spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/get_data/should_report_if_there_are_no_works_returned_by_the_Datacite_Metadata_Search_API.yml
@@ -352,8 +393,12 @@ files:
352
393
  - spec/fixtures/vcr_cassettes/Toccatore_OrcidUpdate/queue_jobs/should_report_if_there_are_works_returned_by_the_Datacite_Metadata_Search_API.yml
353
394
  - spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_data/when_there_are_messages/should_return_the_data_for_one_message.yml
354
395
  - spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_data/when_there_is_ONE_message/should_return_the_data_for_one_message.yml
396
+ - spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_message/should_return_no_meessage_when_the_queue_is_empty.yml
397
+ - spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_message/should_return_one_message_when_there_are_multiple_messages.yml
398
+ - spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_total/when_is_working_with_AWS.yml
355
399
  - spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/push_data/should_fail_if_format_of_the_event_is_wrong.yml
356
- - spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/push_data/should_work_with_DataCite_Event_Data.yml
400
+ - spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/queue_url/should_fail_if_the_queue_doesn_exist.yml
401
+ - spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/queue_url/should_return_always_correct_queue_url.yml
357
402
  - spec/orcid_update_spec.rb
358
403
  - spec/queque_spec.rb
359
404
  - spec/spec_helper.rb
@@ -1,150 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://sqs.eu-west-1.amazonaws.com/
6
- body:
7
- encoding: UTF-8
8
- string: Action=GetQueueUrl&QueueName=test_usage&Version=2012-11-05
9
- headers:
10
- Content-Type:
11
- - application/x-www-form-urlencoded; charset=utf-8
12
- Accept-Encoding:
13
- - ''
14
- User-Agent:
15
- - aws-sdk-ruby3/3.20.2 ruby/2.3.3 x86_64-darwin15 aws-sdk-sqs/1.3.0
16
- X-Amz-Date:
17
- - 20180508T094700Z
18
- X-Amz-Content-Sha256:
19
- - 5761efd13dd0ed81182207171d3660628968189941431d6044920ef8fe7b1160
20
- Authorization:
21
- - AWS4-HMAC-SHA256 Credential=AKIAIXLDUBIDM74CC6KQ/20180508/eu-west-1/sqs/aws4_request,
22
- SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=320fd5e4a16dbf0f04c65595516867443637c8f7278349c0870209eeee57cd96
23
- Content-Length:
24
- - '58'
25
- Accept:
26
- - "*/*"
27
- response:
28
- status:
29
- code: 200
30
- message: OK
31
- headers:
32
- Server:
33
- - Server
34
- Date:
35
- - Tue, 08 May 2018 09:47:00 GMT
36
- Content-Type:
37
- - text/xml
38
- Content-Length:
39
- - '330'
40
- Connection:
41
- - keep-alive
42
- X-Amzn-Requestid:
43
- - 90d1e902-eb78-56b1-8e31-ba699f2cbc88
44
- body:
45
- encoding: UTF-8
46
- string: <?xml version="1.0"?><GetQueueUrlResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><GetQueueUrlResult><QueueUrl>https://sqs.eu-west-1.amazonaws.com/404017989009/test_usage</QueueUrl></GetQueueUrlResult><ResponseMetadata><RequestId>90d1e902-eb78-56b1-8e31-ba699f2cbc88</RequestId></ResponseMetadata></GetQueueUrlResponse>
47
- http_version:
48
- recorded_at: Tue, 08 May 2018 09:47:00 GMT
49
- - request:
50
- method: post
51
- uri: https://sqs.eu-west-1.amazonaws.com/404017989009/test_usage
52
- body:
53
- encoding: UTF-8
54
- string: Action=GetQueueAttributes&AttributeName.1=ApproximateNumberOfMessages&AttributeName.2=ApproximateNumberOfMessagesNotVisible&QueueUrl=https%3A%2F%2Fsqs.eu-west-1.amazonaws.com%2F404017989009%2Ftest_usage&Version=2012-11-05
55
- headers:
56
- Content-Type:
57
- - application/x-www-form-urlencoded; charset=utf-8
58
- Accept-Encoding:
59
- - ''
60
- User-Agent:
61
- - aws-sdk-ruby3/3.20.2 ruby/2.3.3 x86_64-darwin15 aws-sdk-sqs/1.3.0
62
- X-Amz-Date:
63
- - 20180508T094700Z
64
- X-Amz-Content-Sha256:
65
- - 4fa1f9790ab8d8b778fc048ef890ef00e82c1fd4658cd21964eff9eb5dc9426d
66
- Authorization:
67
- - AWS4-HMAC-SHA256 Credential=AKIAIXLDUBIDM74CC6KQ/20180508/eu-west-1/sqs/aws4_request,
68
- SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=9bf193363d0e9d47c2286f4ca182057152c791e99f73160ff7b17f8362f5fa88
69
- Content-Length:
70
- - '221'
71
- Accept:
72
- - "*/*"
73
- response:
74
- status:
75
- code: 200
76
- message: OK
77
- headers:
78
- Server:
79
- - Server
80
- Date:
81
- - Tue, 08 May 2018 09:47:00 GMT
82
- Content-Type:
83
- - text/xml
84
- Content-Length:
85
- - '446'
86
- Connection:
87
- - keep-alive
88
- X-Amzn-Requestid:
89
- - be0ad828-d22d-5165-88d7-8b43a67987ba
90
- body:
91
- encoding: UTF-8
92
- string: <?xml version="1.0"?><GetQueueAttributesResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><GetQueueAttributesResult><Attribute><Name>ApproximateNumberOfMessages</Name><Value>0</Value></Attribute><Attribute><Name>ApproximateNumberOfMessagesNotVisible</Name><Value>0</Value></Attribute></GetQueueAttributesResult><ResponseMetadata><RequestId>be0ad828-d22d-5165-88d7-8b43a67987ba</RequestId></ResponseMetadata></GetQueueAttributesResponse>
93
- http_version:
94
- recorded_at: Tue, 08 May 2018 09:47:00 GMT
95
- - request:
96
- method: post
97
- uri: "<SLACK_WEBHOOK_URL>"
98
- body:
99
- encoding: US-ASCII
100
- string: payload=%7B%22username%22%3A%22Event+Data+Agent%22%2C%22icon_url%22%3A%22https%3A%2F%2Fraw.githubusercontent.com%2Fdatacite%2Ftoccatore%2Fmaster%2Flib%2Ftoccatore%2Fimages%2Ftoccatore.png%22%2C%22attachments%22%3A%5B%7B%22title%22%3A%22Report+for+usage_update%22%2C%22text%22%3Anull%2C%22color%22%3A%22warning%22%7D%5D%7D
101
- headers:
102
- Accept-Encoding:
103
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
104
- Accept:
105
- - "*/*"
106
- User-Agent:
107
- - Ruby
108
- Content-Type:
109
- - application/x-www-form-urlencoded
110
- response:
111
- status:
112
- code: 200
113
- message: OK
114
- headers:
115
- Content-Type:
116
- - text/html
117
- Content-Length:
118
- - '22'
119
- Connection:
120
- - keep-alive
121
- Date:
122
- - Tue, 08 May 2018 09:47:00 GMT
123
- Server:
124
- - Apache
125
- X-Slack-Backend:
126
- - h
127
- Referrer-Policy:
128
- - no-referrer
129
- Strict-Transport-Security:
130
- - max-age=31536000; includeSubDomains; preload
131
- X-Frame-Options:
132
- - SAMEORIGIN
133
- Vary:
134
- - Accept-Encoding
135
- Access-Control-Allow-Origin:
136
- - "*"
137
- X-Via:
138
- - haproxy-www-cvx8
139
- X-Cache:
140
- - Miss from cloudfront
141
- Via:
142
- - 1.1 f794b89ac7b5d3a7a6b25a236579db6c.cloudfront.net (CloudFront)
143
- X-Amz-Cf-Id:
144
- - bkYNFP6Gnanq0lrZLB3V4BwXtCqIGV0KyyQdx_n8Qcl7CyyD0_n1wQ==
145
- body:
146
- encoding: ASCII-8BIT
147
- string: ok
148
- http_version:
149
- recorded_at: Tue, 08 May 2018 09:47:00 GMT
150
- recorded_with: VCR 3.0.3