toccatore 0.4.10 → 0.4.15

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2bca606b9f51fbc4d7f901f90abcec47976afae2c248469411b0ef5313a919b
4
- data.tar.gz: 43c7babcf034873703bbb44d385129d5b464d4f6f7e06b75f0c91b19bad9e302
3
+ metadata.gz: 56e3f7a50bedf097a157e0eab460c4131df5541a8ccb64c05a344ce90464060d
4
+ data.tar.gz: b01a010b2ac258c47c2cb705a4d122bb27f3a342dd838cdbab9c832dac66a563
5
5
  SHA512:
6
- metadata.gz: c0e46e32e4a2ba33941bdfabe8912d2a4cc6ffd60bbf0b77ae69711a3384ef36912f7b77a5c7b190c6b9f0f5ece228b01b04420eaf548fa942c434cd43c534cd
7
- data.tar.gz: 9a6b56efb2de5e86bbb7ddeea0009801e0f3f59d052b1151778d8a2d3efd434ed6d76497ca31d1300ca07c69160b81cb3b5956302550f9bcd39a5e04b5d24d4f
6
+ metadata.gz: 43afaa44061b2488a5e5c0a9f243f8bd951d63f3742854c7c65522d78783b7dae2d2959bb33c818462f6e509d0da532686b9bbb1b807a7d989beeea2bbe558cf
7
+ data.tar.gz: 4ea332dd543c5b933a31dd3736cc87e54bf5dd967e010059e0b1975c4ad045b38536bfceef217f41a9d7db4d66602258405fae6219fbae83cb0c6eaedf2b21d9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- toccatore (0.4.10)
4
+ toccatore (0.4.15)
5
5
  activesupport (>= 4.2.5, < 6)
6
6
  aws-sdk-sqs
7
7
  dotenv (~> 2.1, >= 2.1.1)
@@ -72,7 +72,12 @@ module Toccatore
72
72
  (0...total_pages).each do |page|
73
73
  options[:offset] = page * job_batch_size
74
74
  options[:total] = total
75
- error_total += process_data(options)
75
+ err = process_data(options)
76
+ if err.is_a?(Integer)
77
+ error_total += err
78
+ else
79
+ puts err.inspect
80
+ end
76
81
  end
77
82
  text = "#{total} works processed with #{error_total} errors for date range #{options[:from_date]} - #{options[:until_date]}."
78
83
  else
@@ -82,7 +87,13 @@ module Toccatore
82
87
  puts text
83
88
 
84
89
  # send slack notification
85
- options[:level] = total > 0 ? "good" : "warning"
90
+ if total == 0
91
+ options[:level] = "warning"
92
+ elsif error_total > 0
93
+ options[:level] = "danger"
94
+ else
95
+ options[:level] = "good"
96
+ end
86
97
  options[:title] = "Report for #{source_id}"
87
98
  send_notification_to_slack(text, options) if options[:slack_webhook_url].present?
88
99
 
@@ -45,7 +45,7 @@ module Toccatore
45
45
  "relation_type_id" => raw_relation_type.underscore,
46
46
  "source_id" => "datacite",
47
47
  "source_token" => options[:source_token],
48
- "occurred_at" => item.fetch("minted"),
48
+ "occurred_at" => item.fetch("updated"),
49
49
  "license" => LICENSE }
50
50
  else
51
51
  ssum
@@ -58,7 +58,10 @@ module Toccatore
58
58
  end
59
59
 
60
60
  def push_item(item, options={})
61
- return OpenStruct.new(body: { "errors" => [{ "title" => "Access token missing." }] }) if options[:access_token].blank?
61
+ if options[:access_token].blank?
62
+ puts "Access token missing."
63
+ return 1
64
+ end
62
65
 
63
66
  host = options[:push_url].presence || "https://bus.eventdata.crossref.org"
64
67
  push_url = host + "/events"
@@ -74,7 +77,7 @@ module Toccatore
74
77
  "relation-type-id" => item["relation_type_id"],
75
78
  "source-id" => "datacite-crossref",
76
79
  "source-token" => item["source_token"],
77
- "occurred-at" => item["occured-at"],
80
+ "occurred-at" => item["occurred_at"],
78
81
  "license" => item["license"] } }}
79
82
 
80
83
  response = Maremma.post(push_url, data: data.to_json,
@@ -92,6 +95,9 @@ module Toccatore
92
95
  if response.status == 201
93
96
  puts "#{item['subj_id']} #{item['relation_type_id']} #{item['obj_id']} pushed to Event Data service."
94
97
  0
98
+ elsif response.status == 409
99
+ puts "#{item['subj_id']} #{item['relation_type_id']} #{item['obj_id']} already pushed to Event Data service."
100
+ 0
95
101
  elsif response.body["errors"].present?
96
102
  puts "#{item['subj_id']} #{item['relation_type_id']} #{item['obj_id']} had an error:"
97
103
  puts "#{response.body['errors'].first['title']}"
@@ -44,9 +44,13 @@ module Toccatore
44
44
  end
45
45
 
46
46
  def push_item(item, options={})
47
- return OpenStruct.new(body: { "errors" => [{ "title" => "Access token missing." }] }) if options[:access_token].blank?
47
+ if options[:access_token].blank?
48
+ puts "Access token missing."
49
+ return 1
50
+ end
48
51
 
49
- push_url = (options[:push_url].presence || "https://profiles.datacite.org/api") + "/claims"
52
+ host = options[:push_url].presence || "https://profiles.datacite.org/api"
53
+ push_url = host + "/claims"
50
54
 
51
55
  response = Maremma.post(push_url, data: { "claim" => item }.to_json,
52
56
  bearer: options[:access_token],
@@ -95,7 +95,7 @@ module Toccatore
95
95
  fail "Report_id is missing" if data[:report_id].blank?
96
96
 
97
97
  { "uuid" => SecureRandom.uuid,
98
- "message-action" => "add",
98
+ "message-action" => "create",
99
99
  "subj-id" => data[:report_id],
100
100
  "subj"=> {
101
101
  "pid"=> data[:report_id],
@@ -161,10 +161,11 @@ module Toccatore
161
161
  "id" => item["uuid"],
162
162
  "type" => "events",
163
163
  "attributes" => item.except("id") }}
164
+
164
165
  response = Maremma.put(push_url, data: data.to_json,
165
- bearer: options[:access_token],
166
- content_type: 'application/json',
167
- host: host)
166
+ bearer: options[:access_token],
167
+ content_type: 'json',
168
+ host: host)
168
169
 
169
170
  if response.status == 201
170
171
  puts "#{item['subj-id']} #{item['relation-type-id']} #{item['obj-id']} pushed to Event Data service."
@@ -1,3 +1,3 @@
1
1
  module Toccatore
2
- VERSION = "0.4.10"
2
+ VERSION = "0.4.15"
3
3
  end
data/spec/cli_spec.rb CHANGED
@@ -8,7 +8,7 @@ describe Toccatore::CLI do
8
8
 
9
9
  describe "version" do
10
10
  it 'has version' do
11
- expect { subject.__print_version }.to output("0.4.10\n").to_stdout
11
+ expect { subject.__print_version }.to output("0.4.15\n").to_stdout
12
12
  end
13
13
  end
14
14
 
@@ -5,7 +5,7 @@ require 'securerandom'
5
5
  FactoryBot.define do
6
6
  factory :event , class: OpenStruct do
7
7
  sequence(:uuid) { |n| "#{SecureRandom.uuid}-#{n}" }
8
- message_action "add"
8
+ message_action "create"
9
9
  sequence(:obj_id) { |n| "#{Faker::Internet.url}#{n}" }
10
10
  sequence(:subj_id) { |n| "#{Faker::Internet.url}#{n}" }
11
11
  total Faker::Number.number(3)
@@ -1,7 +1,7 @@
1
1
  [
2
2
  {
3
3
  "uuid": "",
4
- "message-action": "add",
4
+ "message-action": "create",
5
5
  "subj-id": "",
6
6
  "subj": {
7
7
  "pid": "",
@@ -16,7 +16,7 @@
16
16
  "license": ""
17
17
  }, {
18
18
  "uuid": "fc6860b8-4230-41bc-8b8e-21d60e9a7d9a",
19
- "message-action": "add",
19
+ "message-action": "create",
20
20
  "subj-id": "https://api.test.datacite.org/reports/2018-3-Dashs",
21
21
  "subj": {
22
22
  "pid": "https://api.test.datacite.org/reports/2018-3-Dashs",
@@ -1,6 +1,6 @@
1
1
  [{
2
2
  "id": 12332423432432,
3
- "message-action": "add",
3
+ "message-action": "create",
4
4
  "subj": {
5
5
  "pid": "https://api.test.datacite.org/reports/2018-3-Dash",
6
6
  "issued": "2128-04-09"
@@ -1,7 +1,7 @@
1
1
  [
2
2
  {
3
3
  "uuid": "a17e783b-8214-451e-9b0d-077213c2acae",
4
- "message-action": "add",
4
+ "message-action": "create",
5
5
  "subj-id": "https://api.test.datacite.org/reports/2018-3-Dash",
6
6
  "subj": {
7
7
  "pid": "https://api.test.datacite.org/reports/2018-3-Dash",
@@ -16,7 +16,7 @@
16
16
  "license": "https://creativecommons.org/publicdomain/zero/1.0/"
17
17
  }, {
18
18
  "uuid": "fc6860b8-4230-41bc-8b8e-21d60e9a7d9a",
19
- "message-action": "add",
19
+ "message-action": "create",
20
20
  "subj-id": "https://api.test.datacite.org/reports/2018-3-Dash",
21
21
  "subj": {
22
22
  "pid": "https://api.test.datacite.org/reports/2018-3-Dash",
@@ -31,7 +31,7 @@
31
31
  "license": "https://creativecommons.org/publicdomain/zero/1.0/"
32
32
  }, {
33
33
  "uuid": "054da0ad-9821-492e-877e-5c3adbfd5ccf",
34
- "message-action": "add",
34
+ "message-action": "create",
35
35
  "subj-id": "https://api.test.datacite.org/reports/2018-3-Dash",
36
36
  "subj": {
37
37
  "pid": "https://api.test.datacite.org/reports/2018-3-Dash",
@@ -46,7 +46,7 @@
46
46
  "license": "https://creativecommons.org/publicdomain/zero/1.0/"
47
47
  }, {
48
48
  "uuid": "6d6fd620-2123-42da-91f3-6c02e63f3cec",
49
- "message-action": "add",
49
+ "message-action": "create",
50
50
  "subj-id": "https://api.test.datacite.org/reports/2018-3-Dash",
51
51
  "subj": {
52
52
  "pid": "https://api.test.datacite.org/reports/2018-3-Dash",
@@ -5,7 +5,7 @@ http_interactions:
5
5
  uri: https://api.test.datacite.org/events/fc6860b8-4230-41bc-8b8e-21d60e9a7d9a
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"data":{"id":"fc6860b8-4230-41bc-8b8e-21d60e9a7d9a","type":"events","attributes":{"uuid":"fc6860b8-4230-41bc-8b8e-21d60e9a7d9a","message-action":"add","subj-id":"https://api.test.datacite.org/reports/2018-3-Dashs","subj":{"pid":"https://api.test.datacite.org/reports/2018-3-Dashs","issued":"2128-04-09"},"total":3,"obj-id":"https://doi.org/10.7291/d1q94r","relation-type-id":"unique-dataset-investigations-regular","source-id":"datacite","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","occurred-at":"2128-04-09","license":"https://creativecommons.org/publicdomain/zero/1.0/"}}}'
8
+ string: '{"data":{"id":"fc6860b8-4230-41bc-8b8e-21d60e9a7d9a","type":"events","attributes":{"uuid":"fc6860b8-4230-41bc-8b8e-21d60e9a7d9a","message-action":"create","subj-id":"https://api.test.datacite.org/reports/2018-3-Dashs","subj":{"pid":"https://api.test.datacite.org/reports/2018-3-Dashs","issued":"2128-04-09"},"total":3,"obj-id":"https://doi.org/10.7291/d1q94r","relation-type-id":"unique-dataset-investigations-regular","source-id":"datacite","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","occurred-at":"2128-04-09","license":"https://creativecommons.org/publicdomain/zero/1.0/"}}}'
9
9
  headers:
10
10
  User-Agent:
11
11
  - Mozilla/5.0 (compatible; Maremma/4.1; +https://github.com/datacite/maremma)
@@ -5,7 +5,7 @@ http_interactions:
5
5
  uri: https://api.test.datacite.org/events/a17e783b-8214-451e-9b0d-077213c2acae
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"data":{"id":"a17e783b-8214-451e-9b0d-077213c2acae","type":"events","attributes":{"uuid":"a17e783b-8214-451e-9b0d-077213c2acae","message-action":"add","subj-id":"https://api.test.datacite.org/reports/2018-3-Dash","subj":{"pid":"https://api.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"total":3,"obj-id":"https://doi.org/10.7291/d1q94r","relation-type-id":"total-dataset-investigations-regular","source-id":"datacite","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","occurred-at":"2128-04-09","license":"https://creativecommons.org/publicdomain/zero/1.0/"}}}'
8
+ string: '{"data":{"id":"a17e783b-8214-451e-9b0d-077213c2acae","type":"events","attributes":{"uuid":"a17e783b-8214-451e-9b0d-077213c2acae","message-action":"create","subj-id":"https://api.test.datacite.org/reports/2018-3-Dash","subj":{"pid":"https://api.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"total":3,"obj-id":"https://doi.org/10.7291/d1q94r","relation-type-id":"total-dataset-investigations-regular","source-id":"datacite","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","occurred-at":"2128-04-09","license":"https://creativecommons.org/publicdomain/zero/1.0/"}}}'
9
9
  headers:
10
10
  User-Agent:
11
11
  - Mozilla/5.0 (compatible; Maremma/4.1; +https://github.com/datacite/maremma)
@@ -171,7 +171,7 @@ http_interactions:
171
171
  uri: https://api.test.datacite.org/events/fc6860b8-4230-41bc-8b8e-21d60e9a7d9a
172
172
  body:
173
173
  encoding: UTF-8
174
- string: '{"data":{"id":"fc6860b8-4230-41bc-8b8e-21d60e9a7d9a","type":"events","attributes":{"uuid":"fc6860b8-4230-41bc-8b8e-21d60e9a7d9a","message-action":"add","subj-id":"https://api.test.datacite.org/reports/2018-3-Dash","subj":{"pid":"https://api.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"total":3,"obj-id":"https://doi.org/10.7291/d1q94r","relation-type-id":"unique-dataset-investigations-regular","source-id":"datacite-usage","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","occurred-at":"2128-04-09","license":"https://creativecommons.org/publicdomain/zero/1.0/"}}}'
174
+ string: '{"data":{"id":"fc6860b8-4230-41bc-8b8e-21d60e9a7d9a","type":"events","attributes":{"uuid":"fc6860b8-4230-41bc-8b8e-21d60e9a7d9a","message-action":"create","subj-id":"https://api.test.datacite.org/reports/2018-3-Dash","subj":{"pid":"https://api.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"total":3,"obj-id":"https://doi.org/10.7291/d1q94r","relation-type-id":"unique-dataset-investigations-regular","source-id":"datacite-usage","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","occurred-at":"2128-04-09","license":"https://creativecommons.org/publicdomain/zero/1.0/"}}}'
175
175
  headers:
176
176
  User-Agent:
177
177
  - Mozilla/5.0 (compatible; Maremma/4.1; +https://github.com/datacite/maremma)
@@ -337,7 +337,7 @@ http_interactions:
337
337
  uri: https://api.test.datacite.org/events/054da0ad-9821-492e-877e-5c3adbfd5ccf
338
338
  body:
339
339
  encoding: UTF-8
340
- string: '{"data":{"id":"054da0ad-9821-492e-877e-5c3adbfd5ccf","type":"events","attributes":{"uuid":"054da0ad-9821-492e-877e-5c3adbfd5ccf","message-action":"add","subj-id":"https://api.test.datacite.org/reports/2018-3-Dash","subj":{"pid":"https://api.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"total":254,"obj-id":"https://doi.org/10.6071/z7wc73","relation-type-id":"Total-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/"}}}'
340
+ string: '{"data":{"id":"054da0ad-9821-492e-877e-5c3adbfd5ccf","type":"events","attributes":{"uuid":"054da0ad-9821-492e-877e-5c3adbfd5ccf","message-action":"create","subj-id":"https://api.test.datacite.org/reports/2018-3-Dash","subj":{"pid":"https://api.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"total":254,"obj-id":"https://doi.org/10.6071/z7wc73","relation-type-id":"Total-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/"}}}'
341
341
  headers:
342
342
  User-Agent:
343
343
  - Mozilla/5.0 (compatible; Maremma/4.1; +https://github.com/datacite/maremma)
@@ -503,7 +503,7 @@ http_interactions:
503
503
  uri: https://api.test.datacite.org/events/6d6fd620-2123-42da-91f3-6c02e63f3cec
504
504
  body:
505
505
  encoding: UTF-8
506
- string: '{"data":{"id":"6d6fd620-2123-42da-91f3-6c02e63f3cec","type":"events","attributes":{"uuid":"6d6fd620-2123-42da-91f3-6c02e63f3cec","message-action":"add","subj-id":"https://api.test.datacite.org/reports/2018-3-Dash","subj":{"pid":"https://api.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/"}}}'
506
+ string: '{"data":{"id":"6d6fd620-2123-42da-91f3-6c02e63f3cec","type":"events","attributes":{"uuid":"6d6fd620-2123-42da-91f3-6c02e63f3cec","message-action":"create","subj-id":"https://api.test.datacite.org/reports/2018-3-Dash","subj":{"pid":"https://api.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/"}}}'
507
507
  headers:
508
508
  User-Agent:
509
509
  - Mozilla/5.0 (compatible; Maremma/4.1; +https://github.com/datacite/maremma)
@@ -5,7 +5,7 @@ http_interactions:
5
5
  uri: https://api.test.datacite.org/events/a17e783b-8214-451e-9b0d-077213c2acae
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"data":{"id":"a17e783b-8214-451e-9b0d-077213c2acae","type":"events","attributes":{"uuid":"a17e783b-8214-451e-9b0d-077213c2acae","message-action":"add","subj-id":"https://api.test.datacite.org/reports/2018-3-Dash","subj":{"pid":"https://api.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"total":3,"obj-id":"https://doi.org/10.7291/d1q94r","relation-type-id":"total-dataset-investigations-regular","source-id":"datacite","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","occurred-at":"2128-04-09","license":"https://creativecommons.org/publicdomain/zero/1.0/"}}}'
8
+ string: '{"data":{"id":"a17e783b-8214-451e-9b0d-077213c2acae","type":"events","attributes":{"uuid":"a17e783b-8214-451e-9b0d-077213c2acae","message-action":"create","subj-id":"https://api.test.datacite.org/reports/2018-3-Dash","subj":{"pid":"https://api.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"total":3,"obj-id":"https://doi.org/10.7291/d1q94r","relation-type-id":"total-dataset-investigations-regular","source-id":"datacite","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","occurred-at":"2128-04-09","license":"https://creativecommons.org/publicdomain/zero/1.0/"}}}'
9
9
  headers:
10
10
  User-Agent:
11
11
  - Mozilla/5.0 (compatible; Maremma/4.1; +https://github.com/datacite/maremma)
@@ -76,7 +76,7 @@ describe Toccatore::UsageUpdate, vcr: true do
76
76
  result = OpenStruct.new(body: JSON.parse(body), url:"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad" )
77
77
  response = subject.parse_data(result, source_token: ENV['SOURCE_TOKEN'])
78
78
  expect(response.length).to eq(2)
79
- expect(response.last.except("uuid")).to eq("subj"=>{"pid"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "issued"=>"2128-04-09"},"total"=>3,"message-action" => "add", "subj-id"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "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" => ENV['SOURCE_TOKEN'])
79
+ expect(response.last.except("uuid")).to eq("subj"=>{"pid"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "issued"=>"2128-04-09"},"total"=>3,"message-action" => "create", "subj-id"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "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" => ENV['SOURCE_TOKEN'])
80
80
  end
81
81
 
82
82
  it "should parsed it correctly when it has five metrics and two DOIs" do
@@ -84,7 +84,7 @@ describe Toccatore::UsageUpdate, vcr: true do
84
84
  result = OpenStruct.new(body: JSON.parse(body), url:"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad" )
85
85
  response = subject.parse_data(result, source_token: ENV['SOURCE_TOKEN'])
86
86
  expect(response.length).to eq(5)
87
- expect(response.last.except("uuid")).to eq("message-action"=>"add", "subj-id"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "subj"=>{"pid"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "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"=>ENV['SOURCE_TOKEN'], "occurred-at"=>"2128-04-09", "license"=>"https://creativecommons.org/publicdomain/zero/1.0/")
87
+ expect(response.last.except("uuid")).to eq("message-action"=>"create", "subj-id"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "subj"=>{"pid"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "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"=>ENV['SOURCE_TOKEN'], "occurred-at"=>"2128-04-09", "license"=>"https://creativecommons.org/publicdomain/zero/1.0/")
88
88
  end
89
89
 
90
90
  it "should parsed it correctly when it has two metrics per DOI " do
@@ -92,7 +92,7 @@ describe Toccatore::UsageUpdate, vcr: true do
92
92
  result = OpenStruct.new(body: JSON.parse(body), url:"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad")
93
93
  response = subject.parse_data(result, source_token: ENV['SOURCE_TOKEN'])
94
94
  expect(response.length).to eq(4)
95
- expect(response.last.except("uuid")).to eq("message-action"=>"add", "subj-id"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "subj"=>{"pid"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "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"=>ENV['SOURCE_TOKEN'], "occurred-at"=>"2128-04-09", "license"=>"https://creativecommons.org/publicdomain/zero/1.0/")
95
+ expect(response.last.except("uuid")).to eq("message-action"=>"create", "subj-id"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "subj"=>{"pid"=>"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad", "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"=>ENV['SOURCE_TOKEN'], "occurred-at"=>"2128-04-09", "license"=>"https://creativecommons.org/publicdomain/zero/1.0/")
96
96
  end
97
97
 
98
98
  it "should send a warning if there are more than 4 metrics" do
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.10
4
+ version: 0.4.15
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-08-10 00:00:00.000000000 Z
11
+ date: 2018-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma