toccatore 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +52 -52
- data/lib/toccatore/base.rb +2 -2
- data/lib/toccatore/datacite_related.rb +10 -1
- data/lib/toccatore/version.rb +1 -1
- data/spec/base_spec.rb +4 -4
- data/spec/cli_spec.rb +31 -31
- data/spec/datacite_related_spec.rb +10 -10
- data/spec/fixtures/event_data_resp_1 +2 -2
- data/spec/fixtures/event_data_resp_2 +4 -4
- data/spec/fixtures/events_empty.json +3 -3
- data/spec/fixtures/usage_event.json +1 -1
- data/spec/fixtures/usage_event_fail.json +2 -2
- data/spec/fixtures/usage_events.json +15 -15
- data/spec/fixtures/vcr_cassettes/Toccatore_Base/get_doi_ra/crossref.yml +21 -45
- data/spec/fixtures/vcr_cassettes/Toccatore_Base/get_doi_ra/datacite.yml +23 -47
- data/spec/fixtures/vcr_cassettes/Toccatore_Base/send_notification_to_slack/datacite_related.yml +14 -12
- data/spec/fixtures/vcr_cassettes/Toccatore_Base/send_notification_to_slack/datacite_related_no_works.yml +15 -13
- data/spec/fixtures/vcr_cassettes/Toccatore_Base/send_notification_to_slack/orcid_update.yml +14 -12
- data/spec/fixtures/vcr_cassettes/Toccatore_Base/send_notification_to_slack/orcid_update_no_works.yml +15 -13
- data/spec/fixtures/vcr_cassettes/Toccatore_CLI/datacite_related/should_fail.yml +345 -852
- data/spec/fixtures/vcr_cassettes/Toccatore_CLI/datacite_related/should_query_by_DOI.yml +327 -409
- data/spec/fixtures/vcr_cassettes/Toccatore_CLI/datacite_related/should_query_by_related_identifier.yml +140 -117
- data/spec/fixtures/vcr_cassettes/Toccatore_CLI/datacite_related/should_succeed.yml +1267 -2068
- data/spec/fixtures/vcr_cassettes/Toccatore_CLI/datacite_related/should_succeed_with_no_works.yml +31 -25
- data/spec/fixtures/vcr_cassettes/Toccatore_CLI/orcid_update/should_fail.yml +47 -39
- data/spec/fixtures/vcr_cassettes/Toccatore_CLI/orcid_update/should_query_by_DOI.yml +673 -855
- data/spec/fixtures/vcr_cassettes/Toccatore_CLI/orcid_update/should_query_by_ORCID_ID.yml +1885 -2419
- data/spec/fixtures/vcr_cassettes/Toccatore_CLI/orcid_update/should_succeed.yml +1555 -1991
- data/spec/fixtures/vcr_cassettes/Toccatore_CLI/orcid_update/should_succeed_with_no_works.yml +31 -27
- data/spec/fixtures/vcr_cassettes/Toccatore_CLI/usage_update/no_reports_in_the_queue/should_succeed_with_no_works.yml +29 -29
- data/spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/get_data/should_allow_queries_by_DOI_of_the_Datacite_Metadata_Search_API.yml +16 -12
- data/spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/get_data/should_allow_queries_by_related_identifier_of_the_Datacite_Metadata_Search_API.yml +17 -13
- data/spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/get_data/should_report_if_there_are_no_works_returned_by_the_Datacite_Metadata_Search_API.yml +16 -12
- data/spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/get_data/should_report_if_there_are_works_returned_by_the_Datacite_Metadata_Search_API.yml +16 -14
- data/spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/get_total/with_no_works.yml +15 -11
- data/spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/get_total/with_works.yml +16 -12
- data/spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/parse_data/should_report_if_there_are_works_returned_by_the_Datacite_Metadata_Search_API.yml +437 -869
- data/spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/push_data/should_report_if_there_are_works_returned_by_the_Datacite_Metadata_Search_API.yml +1240 -1662
- data/spec/fixtures/vcr_cassettes/Toccatore_DataciteRelated/push_data/should_work_with_DataCite_Event_Data.yml +4026 -6556
- data/spec/fixtures/vcr_cassettes/Toccatore_OrcidUpdate/get_data/should_allow_queries_by_DOI_of_the_Datacite_Metadata_Search_API.yml +15 -13
- data/spec/fixtures/vcr_cassettes/Toccatore_OrcidUpdate/get_data/should_allow_queries_by_ORCID_ID_of_the_Datacite_Metadata_Search_API.yml +15 -11
- data/spec/fixtures/vcr_cassettes/Toccatore_OrcidUpdate/get_data/should_report_if_there_are_no_works_returned_by_the_Datacite_Metadata_Search_API.yml +15 -11
- data/spec/fixtures/vcr_cassettes/Toccatore_OrcidUpdate/get_data/should_report_if_there_are_works_returned_by_the_Datacite_Metadata_Search_API.yml +15 -13
- data/spec/fixtures/vcr_cassettes/Toccatore_OrcidUpdate/get_total/with_no_works.yml +15 -13
- data/spec/fixtures/vcr_cassettes/Toccatore_OrcidUpdate/get_total/with_works.yml +15 -13
- data/spec/fixtures/vcr_cassettes/Toccatore_OrcidUpdate/push_data/should_delete_claims.yml +25 -32
- data/spec/fixtures/vcr_cassettes/Toccatore_OrcidUpdate/push_data/should_report_if_there_are_works_returned_by_the_Datacite_Metadata_Search_API.yml +1347 -1791
- data/spec/fixtures/vcr_cassettes/Toccatore_OrcidUpdate/queue_jobs/should_report_if_there_are_no_works_returned_by_the_Datacite_Metadata_Search_API.yml +14 -10
- data/spec/fixtures/vcr_cassettes/Toccatore_OrcidUpdate/queue_jobs/should_report_if_there_are_works_returned_by_the_Datacite_Metadata_Search_API.yml +29 -25
- data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_data/when_there_are_messages/should_return_the_data_for_one_message.yml +50 -29
- data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_data/when_there_is_ONE_message/should_return_the_data_for_one_message.yml +50 -29
- data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_message/should_return_no_meessage_when_the_queue_is_empty.yml +17 -17
- data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_message/should_return_one_message_when_there_are_multiple_messages.yml +17 -17
- data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/get_total/when_is_working_with_AWS.yml +32 -32
- data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/push_data/should_fail_if_format_of_the_event_is_empty.yml +139 -22
- data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/push_data/should_fail_if_format_of_the_event_is_wrong.yml +534 -1025
- data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/push_data/should_work_with_a_single_item.yml +134 -254
- data/spec/fixtures/vcr_cassettes/Toccatore_UsageUpdate/queue_url/should_return_always_correct_queue_url.yml +8 -8
- data/spec/orcid_update_spec.rb +1 -1
- data/spec/{queque_spec.rb → queue_spec.rb} +0 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/usage_update_spec.rb +32 -32
- data/toccatore.gemspec +6 -6
- metadata +31 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2bca606b9f51fbc4d7f901f90abcec47976afae2c248469411b0ef5313a919b
|
4
|
+
data.tar.gz: 43c7babcf034873703bbb44d385129d5b464d4f6f7e06b75f0c91b19bad9e302
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0e46e32e4a2ba33941bdfabe8912d2a4cc6ffd60bbf0b77ae69711a3384ef36912f7b77a5c7b190c6b9f0f5ece228b01b04420eaf548fa942c434cd43c534cd
|
7
|
+
data.tar.gz: 9a6b56efb2de5e86bbb7ddeea0009801e0f3f59d052b1151778d8a2d3efd434ed6d76497ca31d1300ca07c69160b81cb3b5956302550f9bcd39a5e04b5d24d4f
|
data/Gemfile.lock
CHANGED
@@ -1,38 +1,38 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
toccatore (0.4.
|
5
|
-
activesupport (
|
4
|
+
toccatore (0.4.10)
|
5
|
+
activesupport (>= 4.2.5, < 6)
|
6
6
|
aws-sdk-sqs
|
7
7
|
dotenv (~> 2.1, >= 2.1.1)
|
8
8
|
factory_bot
|
9
9
|
gender_detector (~> 1.0)
|
10
|
-
maremma (
|
10
|
+
maremma (>= 3.5.7, < 5)
|
11
11
|
namae (~> 0.11.0)
|
12
|
-
slack-notifier (
|
12
|
+
slack-notifier (~> 2.1)
|
13
13
|
thor (~> 0.19)
|
14
14
|
|
15
15
|
GEM
|
16
16
|
remote: https://rubygems.org/
|
17
17
|
specs:
|
18
|
-
activesupport (
|
19
|
-
|
18
|
+
activesupport (5.2.1)
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
|
+
i18n (>= 0.7, < 2)
|
20
21
|
minitest (~> 5.1)
|
21
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
22
22
|
tzinfo (~> 1.1)
|
23
|
-
addressable (2.5.
|
24
|
-
public_suffix (
|
25
|
-
aws-eventstream (1.0.
|
26
|
-
aws-partitions (1.
|
27
|
-
aws-sdk-core (3.
|
23
|
+
addressable (2.5.2)
|
24
|
+
public_suffix (>= 2.0.2, < 4.0)
|
25
|
+
aws-eventstream (1.0.1)
|
26
|
+
aws-partitions (1.97.0)
|
27
|
+
aws-sdk-core (3.24.0)
|
28
28
|
aws-eventstream (~> 1.0)
|
29
29
|
aws-partitions (~> 1.0)
|
30
30
|
aws-sigv4 (~> 1.0)
|
31
31
|
jmespath (~> 1.0)
|
32
|
-
aws-sdk-sqs (1.
|
32
|
+
aws-sdk-sqs (1.4.0)
|
33
33
|
aws-sdk-core (~> 3)
|
34
34
|
aws-sigv4 (~> 1.0)
|
35
|
-
aws-sigv4 (1.0.
|
35
|
+
aws-sigv4 (1.0.3)
|
36
36
|
builder (3.2.3)
|
37
37
|
codeclimate-test-reporter (1.0.8)
|
38
38
|
simplecov (<= 0.13)
|
@@ -41,32 +41,32 @@ GEM
|
|
41
41
|
safe_yaml (~> 1.0.0)
|
42
42
|
diff-lcs (1.3)
|
43
43
|
docile (1.1.5)
|
44
|
-
dotenv (2.
|
45
|
-
excon (0.
|
46
|
-
factory_bot (4.
|
44
|
+
dotenv (2.5.0)
|
45
|
+
excon (0.62.0)
|
46
|
+
factory_bot (4.10.0)
|
47
47
|
activesupport (>= 3.0.0)
|
48
|
-
faker (1.
|
48
|
+
faker (1.9.1)
|
49
49
|
i18n (>= 0.7)
|
50
|
-
faraday (0.
|
50
|
+
faraday (0.15.2)
|
51
51
|
multipart-post (>= 1.2, < 3)
|
52
52
|
faraday-encoding (0.0.4)
|
53
53
|
faraday
|
54
|
-
faraday_middleware (0.
|
54
|
+
faraday_middleware (0.12.2)
|
55
55
|
faraday (>= 0.7.4, < 1.0)
|
56
56
|
gender_detector (1.0.0)
|
57
|
-
hashdiff (0.3.
|
58
|
-
i18n (
|
57
|
+
hashdiff (0.3.7)
|
58
|
+
i18n (1.1.0)
|
59
59
|
concurrent-ruby (~> 1.0)
|
60
60
|
jmespath (1.4.0)
|
61
61
|
json (2.1.0)
|
62
|
-
maremma (
|
62
|
+
maremma (4.1)
|
63
63
|
activesupport (>= 4.2.5, < 6)
|
64
64
|
addressable (>= 2.3.6)
|
65
65
|
builder (~> 3.2, >= 3.2.2)
|
66
|
-
excon (~> 0.
|
67
|
-
faraday (~> 0.
|
68
|
-
faraday-encoding (~> 0.0.
|
69
|
-
faraday_middleware (~> 0.
|
66
|
+
excon (~> 0.60)
|
67
|
+
faraday (~> 0.14)
|
68
|
+
faraday-encoding (~> 0.0.4)
|
69
|
+
faraday_middleware (~> 0.12.0)
|
70
70
|
multi_json (~> 1.12)
|
71
71
|
nokogiri (~> 1.8.1)
|
72
72
|
oj (>= 2.8.3)
|
@@ -75,40 +75,40 @@ GEM
|
|
75
75
|
multi_json (1.13.1)
|
76
76
|
multipart-post (2.0.0)
|
77
77
|
namae (0.11.3)
|
78
|
-
nokogiri (1.8.
|
78
|
+
nokogiri (1.8.4)
|
79
79
|
mini_portile2 (~> 2.3.0)
|
80
|
-
oj (3.6.
|
81
|
-
public_suffix (
|
82
|
-
rack (2.0.
|
83
|
-
rack-test (0.
|
84
|
-
rack (>= 1.0)
|
85
|
-
rake (12.
|
86
|
-
rspec (3.
|
87
|
-
rspec-core (~> 3.
|
88
|
-
rspec-expectations (~> 3.
|
89
|
-
rspec-mocks (~> 3.
|
90
|
-
rspec-core (3.
|
91
|
-
rspec-support (~> 3.
|
92
|
-
rspec-expectations (3.
|
80
|
+
oj (3.6.5)
|
81
|
+
public_suffix (3.0.2)
|
82
|
+
rack (2.0.5)
|
83
|
+
rack-test (0.8.3)
|
84
|
+
rack (>= 1.0, < 3)
|
85
|
+
rake (12.3.1)
|
86
|
+
rspec (3.8.0)
|
87
|
+
rspec-core (~> 3.8.0)
|
88
|
+
rspec-expectations (~> 3.8.0)
|
89
|
+
rspec-mocks (~> 3.8.0)
|
90
|
+
rspec-core (3.8.0)
|
91
|
+
rspec-support (~> 3.8.0)
|
92
|
+
rspec-expectations (3.8.1)
|
93
93
|
diff-lcs (>= 1.2.0, < 2.0)
|
94
|
-
rspec-support (~> 3.
|
95
|
-
rspec-mocks (3.
|
94
|
+
rspec-support (~> 3.8.0)
|
95
|
+
rspec-mocks (3.8.0)
|
96
96
|
diff-lcs (>= 1.2.0, < 2.0)
|
97
|
-
rspec-support (~> 3.
|
98
|
-
rspec-support (3.
|
97
|
+
rspec-support (~> 3.8.0)
|
98
|
+
rspec-support (3.8.0)
|
99
99
|
safe_yaml (1.0.4)
|
100
|
-
simplecov (0.
|
100
|
+
simplecov (0.13.0)
|
101
101
|
docile (~> 1.1.0)
|
102
102
|
json (>= 1.8, < 3)
|
103
103
|
simplecov-html (~> 0.10.0)
|
104
|
-
simplecov-html (0.10.
|
105
|
-
slack-notifier (2.
|
104
|
+
simplecov-html (0.10.2)
|
105
|
+
slack-notifier (2.3.2)
|
106
106
|
thor (0.20.0)
|
107
107
|
thread_safe (0.3.6)
|
108
108
|
tzinfo (1.2.5)
|
109
109
|
thread_safe (~> 0.1)
|
110
110
|
vcr (3.0.3)
|
111
|
-
webmock (
|
111
|
+
webmock (3.4.2)
|
112
112
|
addressable (>= 2.3.6)
|
113
113
|
crack (>= 0.3.2)
|
114
114
|
hashdiff
|
@@ -118,16 +118,16 @@ PLATFORMS
|
|
118
118
|
|
119
119
|
DEPENDENCIES
|
120
120
|
bundler (~> 1.0)
|
121
|
-
codeclimate-test-reporter (~> 1.0
|
121
|
+
codeclimate-test-reporter (~> 1.0)
|
122
122
|
factory_bot
|
123
123
|
faker
|
124
124
|
rack-test (~> 0)
|
125
125
|
rake (~> 12.0)
|
126
126
|
rspec (~> 3.4)
|
127
|
-
simplecov
|
127
|
+
simplecov
|
128
128
|
toccatore!
|
129
129
|
vcr (~> 3.0, >= 3.0.3)
|
130
|
-
webmock (~>
|
130
|
+
webmock (~> 3.0, >= 3.0.1)
|
131
131
|
|
132
132
|
BUNDLED WITH
|
133
133
|
1.16.1
|
data/lib/toccatore/base.rb
CHANGED
@@ -145,8 +145,8 @@ module Toccatore
|
|
145
145
|
notifier = Slack::Notifier.new options[:slack_webhook_url],
|
146
146
|
username: "Event Data Agent",
|
147
147
|
icon_url: ICON_URL
|
148
|
-
response = notifier.
|
149
|
-
response.
|
148
|
+
response = notifier.post attachments: [attachment]
|
149
|
+
response.first
|
150
150
|
end
|
151
151
|
|
152
152
|
def get_doi_ra(prefix)
|
@@ -67,7 +67,16 @@ module Toccatore
|
|
67
67
|
data = { "data" => {
|
68
68
|
"id" => item["id"],
|
69
69
|
"type" => "events",
|
70
|
-
"attributes" =>
|
70
|
+
"attributes" => {
|
71
|
+
"message-action" => item["message_action"],
|
72
|
+
"subj-id" => item["subj_id"],
|
73
|
+
"obj-id" => item["obj_id"],
|
74
|
+
"relation-type-id" => item["relation_type_id"],
|
75
|
+
"source-id" => "datacite-crossref",
|
76
|
+
"source-token" => item["source_token"],
|
77
|
+
"occurred-at" => item["occured-at"],
|
78
|
+
"license" => item["license"] } }}
|
79
|
+
|
71
80
|
response = Maremma.post(push_url, data: data.to_json,
|
72
81
|
bearer: options[:access_token],
|
73
82
|
content_type: 'json',
|
data/lib/toccatore/version.rb
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -35,7 +35,7 @@ describe Toccatore::Base, vcr: true do
|
|
35
35
|
it "datacite_related" do
|
36
36
|
text = "12 works processed for date range 2015-04-07 - 2015-04-08."
|
37
37
|
options = { title: "Report for datacite_related", slack_webhook_url: slack_webhook_url }
|
38
|
-
expect(subject.send_notification_to_slack(text, options)).to
|
38
|
+
expect(subject.send_notification_to_slack(text, options)).to be_kind_of(Net::HTTPOK)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "datacite_related no works" do
|
@@ -43,13 +43,13 @@ describe Toccatore::Base, vcr: true do
|
|
43
43
|
options = { title: "Report for datacite_related",
|
44
44
|
slack_webhook_url: slack_webhook_url,
|
45
45
|
level: "warning" }
|
46
|
-
expect(subject.send_notification_to_slack(text, options)).to
|
46
|
+
expect(subject.send_notification_to_slack(text, options)).to be_kind_of(Net::HTTPOK)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "orcid_update" do
|
50
50
|
text = "12 works processed for date range 2015-04-07 - 2015-04-08."
|
51
51
|
options = { title: "Report for orcid_update", slack_webhook_url: slack_webhook_url }
|
52
|
-
expect(subject.send_notification_to_slack(text, options)).to
|
52
|
+
expect(subject.send_notification_to_slack(text, options)).to be_kind_of(Net::HTTPOK)
|
53
53
|
end
|
54
54
|
|
55
55
|
it "orcid_update no works" do
|
@@ -57,7 +57,7 @@ describe Toccatore::Base, vcr: true do
|
|
57
57
|
options = { title: "Report for orcid_update",
|
58
58
|
slack_webhook_url: slack_webhook_url,
|
59
59
|
level: "warning" }
|
60
|
-
expect(subject.send_notification_to_slack(text, options)).to
|
60
|
+
expect(subject.send_notification_to_slack(text, options)).to be_kind_of(Net::HTTPOK)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
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.
|
11
|
+
expect { subject.__print_version }.to output("0.4.10\n").to_stdout
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -77,7 +77,7 @@ describe Toccatore::CLI do
|
|
77
77
|
|
78
78
|
it 'should succeed' do
|
79
79
|
subject.options = cli_options
|
80
|
-
expect { subject.datacite_related }.to output(/https:\/\/doi.org\/10.
|
80
|
+
expect { subject.datacite_related }.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
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'should query by DOI' do
|
@@ -86,7 +86,7 @@ describe Toccatore::CLI do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'should query by related_identifier' do
|
89
|
-
subject.options = cli_options.merge(related_identifier: "10.7554/elife.01567", from_date: "2013-01-01", until_date: "
|
89
|
+
subject.options = cli_options.merge(related_identifier: "10.7554/elife.01567", from_date: "2013-01-01", until_date: "2018-12-31")
|
90
90
|
expect { subject.datacite_related }.to output(/https:\/\/doi.org\/10.5061\/dryad.b835k is_referenced_by https:\/\/doi.org\/10.7554\/elife.01567 pushed to Event Data service.\n/).to_stdout
|
91
91
|
end
|
92
92
|
|
@@ -107,36 +107,36 @@ describe Toccatore::CLI do
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
110
|
+
describe "usage_update", vcr: true, :order => :defined do
|
111
|
+
let(:push_url) { ENV['LAGOTTINO_URL'] }
|
112
|
+
let(:access_token) { ENV['LAGOTTINO_TOKEN'] }
|
113
|
+
let(:source_token) { ENV['SOURCE_TOKEN'] }
|
114
|
+
let(:slack_webhook_url) { ENV['SLACK_WEBHOOK_URL'] }
|
115
|
+
let(:cli_options) { { push_url: push_url,
|
116
|
+
slack_webhook_url: slack_webhook_url,
|
117
|
+
access_token: access_token,
|
118
|
+
source_token: source_token } }
|
119
|
+
|
120
|
+
|
121
|
+
context "no reports in the queue" do
|
122
|
+
it 'should succeed with no works' do
|
123
|
+
subject.options = { push_url: push_url,
|
116
124
|
slack_webhook_url: slack_webhook_url,
|
117
|
-
access_token: access_token
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
context "no reports in the queue" do
|
122
|
-
it 'should succeed with no works' do
|
123
|
-
subject.options = { push_url: push_url,
|
124
|
-
slack_webhook_url: slack_webhook_url,
|
125
|
-
access_token: access_token}
|
126
|
-
expect { subject.usage_update }.to output("0 works processed with 0 errors for Usage Reports Queue https://sqs.eu-west-1.amazonaws.com/404017989009/test_usage\n").to_stdout
|
127
|
-
end
|
125
|
+
access_token: access_token}
|
126
|
+
expect { subject.usage_update }.to output("0 works processed with 0 errors for Usage Reports Queue https://sqs.eu-west-1.amazonaws.com/404017989009/test_usage\n").to_stdout
|
128
127
|
end
|
128
|
+
end
|
129
129
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
end
|
130
|
+
context "with reports in the queue" do
|
131
|
+
# TO test this we need a real queue working
|
132
|
+
# it 'should succeed' do
|
133
|
+
# subject.options = cli_options
|
134
|
+
# expect { subject.usage_update }.to output("0 works processed with 0 errors for Usage Reports Queue https://sqs.eu-west-1.amazonaws.com/404017989009/test_usage\n").to_stdout
|
135
|
+
# end
|
136
|
+
# it 'should fail' do
|
137
|
+
# subject.options = cli_options.except(:access_token)
|
138
|
+
# expect { subject.usage_update }.to output(/An error occured: Access token missing.\n/).to_stdout
|
139
|
+
# end
|
141
140
|
end
|
141
|
+
end
|
142
142
|
end
|
@@ -29,7 +29,7 @@ describe Toccatore::DataciteRelated, vcr: true do
|
|
29
29
|
|
30
30
|
context "get_total" do
|
31
31
|
it "with works" do
|
32
|
-
expect(subject.get_total(query_options)).to eq(
|
32
|
+
expect(subject.get_total(query_options)).to eq(640)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "with no works" do
|
@@ -57,19 +57,19 @@ describe Toccatore::DataciteRelated, vcr: true do
|
|
57
57
|
|
58
58
|
it "should report if there are works returned by the Datacite Metadata Search API" do
|
59
59
|
response = subject.get_data(query_options)
|
60
|
-
expect(response.body["data"]["response"]["numFound"]).to eq(
|
60
|
+
expect(response.body["data"]["response"]["numFound"]).to eq(640)
|
61
61
|
doc = response.body["data"]["response"]["docs"].first
|
62
|
-
expect(doc["doi"]).to eq("10.7480/KNOB.113.2014.3")
|
62
|
+
expect(doc["doi"]).to eq("10.7480/KNOB.113.2014.3.830")
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should allow queries by related_identifier of the Datacite Metadata Search API" do
|
66
|
-
response = subject.get_data({ related_identifier: "10.
|
67
|
-
expect(response.body["data"]["response"]["numFound"]).to eq(
|
66
|
+
response = subject.get_data({ related_identifier: "10.3897/phytokeys.12.2849", from_date: "2013-01-01", until_date: "2017-12-31", rows: 1000, offset: 0 })
|
67
|
+
expect(response.body["data"]["response"]["numFound"]).to eq(14223)
|
68
68
|
doc = response.body["data"]["response"]["docs"].first
|
69
|
-
expect(doc["doi"]).to eq("10.
|
69
|
+
expect(doc["doi"]).to eq("10.15468/DL.MBSMUW")
|
70
70
|
related_identifiers = doc["relatedIdentifier"]
|
71
|
-
expect(related_identifiers.count).to eq(
|
72
|
-
expect(related_identifiers
|
71
|
+
expect(related_identifiers.count).to eq(1)
|
72
|
+
expect(related_identifiers.first).to eq("References:DOI:10.3897/phytokeys.12.2849")
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should allow queries by DOI of the Datacite Metadata Search API" do
|
@@ -102,7 +102,7 @@ describe Toccatore::DataciteRelated, vcr: true do
|
|
102
102
|
response = subject.parse_data(result, source_token: ENV['SOURCE_TOKEN'])
|
103
103
|
|
104
104
|
expect(response.length).to eq(134)
|
105
|
-
expect(response.last.except("id")).to eq("message_action" => "create", "subj_id"=>"https://doi.org/10.17180/obs.yzeron", "obj_id"=>"https://doi.org/10.1016/j.jhydrol.2013.09.055", "relation_type_id"=>"is_referenced_by", "source_id"=>"datacite","source_token" =>
|
105
|
+
expect(response.last.except("id")).to eq("message_action" => "create", "subj_id"=>"https://doi.org/10.17180/obs.yzeron", "obj_id"=>"https://doi.org/10.1016/j.jhydrol.2013.09.055", "relation_type_id"=>"is_referenced_by", "source_id"=>"datacite","source_token" => ENV['SOURCE_TOKEN'], "occurred_at"=>"2015-04-07T12:22:40Z", "license" => "https://creativecommons.org/publicdomain/zero/1.0/")
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should report if there are works ignored because of an IsIdenticalTo relation" do
|
@@ -136,7 +136,7 @@ describe Toccatore::DataciteRelated, vcr: true do
|
|
136
136
|
body = File.read(fixture_path + 'datacite_related.json')
|
137
137
|
result = OpenStruct.new(body: { "data" => JSON.parse(body) })
|
138
138
|
result = subject.parse_data(result, source_token: ENV['SOURCE_TOKEN'])
|
139
|
-
options = { push_url: ENV['
|
139
|
+
options = { push_url: ENV['LAGOTTINO_URL'], access_token: ENV['LAGOTTINO_TOKEN'], jsonapi: true }
|
140
140
|
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
|
141
141
|
end
|
142
142
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
https://
|
2
|
-
https://
|
1
|
+
https://api.test.datacite.org/reports/2018-3-Dash total-dataset-investigations-regular https://doi.org/10.7291/d1q94r pushed to Event Data service.
|
2
|
+
https://api.test.datacite.org/reports/2018-3-Dash unique-dataset-investigations-regular https://doi.org/10.7291/d1q94r pushed to Event Data service.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
https://
|
2
|
-
https://
|
3
|
-
https://
|
4
|
-
https://
|
1
|
+
https://api.test.datacite.org/reports/2018-3-Dash total-dataset-investigations-regular https://doi.org/10.7291/d1q94r had an error:\nthe server responded with status 500/\n
|
2
|
+
https://api.test.datacite.org/reports/2018-3-Dash unique-dataset-investigations-regular https://doi.org/10.7291/d1q94r had an error:\nthe server responded with status 500/\n
|
3
|
+
https://api.test.datacite.org/reports/2018-3-Dash Total-Dataset-Requests-Machine https://doi.org/10.6071/z7wc73 had an error:\nthe server responded with status 500/\n
|
4
|
+
https://api.test.datacite.org/reports/2018-3-Dash Unique-Dataset-Requests-Machine https://doi.org/10.6071/z7wc73 had an error:\nthe server responded with status 500/\n
|
@@ -17,16 +17,16 @@
|
|
17
17
|
}, {
|
18
18
|
"uuid": "fc6860b8-4230-41bc-8b8e-21d60e9a7d9a",
|
19
19
|
"message-action": "add",
|
20
|
-
"subj-id": "https://
|
20
|
+
"subj-id": "https://api.test.datacite.org/reports/2018-3-Dashs",
|
21
21
|
"subj": {
|
22
|
-
"pid": "https://
|
22
|
+
"pid": "https://api.test.datacite.org/reports/2018-3-Dashs",
|
23
23
|
"issued": "2128-04-09"
|
24
24
|
},
|
25
25
|
"total": 3,
|
26
26
|
"obj-id": "https://doi.org/10.7291/d1q94r",
|
27
27
|
"relation-type-id": "unique-dataset-investigations-regular",
|
28
28
|
"source-id": "datacite",
|
29
|
-
"source-token": "
|
29
|
+
"source-token": "28276d12-b320-41ba-9272-bb0adc3466ff",
|
30
30
|
"occurred-at": "2128-04-09",
|
31
31
|
"license": "https://creativecommons.org/publicdomain/zero/1.0/"
|
32
32
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"report_id":"https://
|
1
|
+
{"report_id":"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad"}
|
@@ -2,14 +2,14 @@
|
|
2
2
|
"id": 12332423432432,
|
3
3
|
"message-action": "add",
|
4
4
|
"subj": {
|
5
|
-
"pid": "https://
|
5
|
+
"pid": "https://api.test.datacite.org/reports/2018-3-Dash",
|
6
6
|
"issued": "2128-04-09"
|
7
7
|
},
|
8
8
|
"total": "208",
|
9
9
|
"obj-id": "https://doi.org/10.6071/z7wc73",
|
10
10
|
"relation-type-id": "Unique-Dataset-Requests-Machine",
|
11
11
|
"source-id": "datacite",
|
12
|
-
"source-token": "
|
12
|
+
"source-token": "28276d12-b320-41ba-9272-bb0adc3466ff",
|
13
13
|
"occurred-at": "2128-04-09",
|
14
14
|
"license": "https://creativecommons.org/publicdomain/zero/1.0/"
|
15
15
|
}
|