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
@@ -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
- - 20180508T094659Z
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=5f7473224d2f7dd464748f27ffc30935f69eed31ab6b5b5ed0728fd40fce2ba2
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:46:59 GMT
36
- Content-Type:
37
- - text/xml
38
- Content-Length:
39
- - '330'
40
- Connection:
41
- - keep-alive
42
- X-Amzn-Requestid:
43
- - f1a53869-39b4-551b-8328-6b024de7ba2f
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>f1a53869-39b4-551b-8328-6b024de7ba2f</RequestId></ResponseMetadata></GetQueueUrlResponse>
47
- http_version:
48
- recorded_at: Tue, 08 May 2018 09:46:59 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
- - 20180508T094659Z
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=cf3ef581236b7ee88540338aa3bc6cdd604b7d9b368c5c94eed20a75184acf01
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:46:59 GMT
82
- Content-Type:
83
- - text/xml
84
- Content-Length:
85
- - '446'
86
- Connection:
87
- - keep-alive
88
- X-Amzn-Requestid:
89
- - dad63327-bcc0-5db4-9612-604cc8936f6b
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>dad63327-bcc0-5db4-9612-604cc8936f6b</RequestId></ResponseMetadata></GetQueueAttributesResponse>
93
- http_version:
94
- recorded_at: Tue, 08 May 2018 09:46:59 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-v2r6
139
- X-Cache:
140
- - Miss from cloudfront
141
- Via:
142
- - 1.1 e98abde3c6a5bc27d4bdd4168baa587d.cloudfront.net (CloudFront)
143
- X-Amz-Cf-Id:
144
- - EOPeYSPwRDDHg0efem27-fUe1khpvI0655b_TRJMzl55N7m609xePw==
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
@@ -1,199 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://api.test.datacite.org/events
6
- body:
7
- encoding: UTF-8
8
- string: '{"data":{"id":"393ed959-b0b2-402b-aa48-e794529b9eef","type":"events","attributes":{"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":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
- headers:
10
- User-Agent:
11
- - Maremma - https://github.com/datacite/maremma
12
- Content-Type:
13
- - application/json
14
- Accept:
15
- - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
16
- Authorization:
17
- - Bearer <LAGOTTO_TOKEN>
18
- response:
19
- status:
20
- code: 201
21
- message: ''
22
- headers:
23
- Date:
24
- - Mon, 07 May 2018 15:07:42 GMT
25
- Content-Type:
26
- - application/json; charset=utf-8
27
- Connection:
28
- - keep-alive
29
- Status:
30
- - 201 Created
31
- Cache-Control:
32
- - max-age=0, private, must-revalidate
33
- Vary:
34
- - Accept-Encoding, Origin
35
- Etag:
36
- - W/"01700b9bbf553d49a585e0fb88779627"
37
- X-Runtime:
38
- - '0.010769'
39
- X-Credential-Username:
40
- - 0000-0001-5489-3594
41
- X-Request-Id:
42
- - def01fde-6bb8-4ee1-9c03-f73772932f72
43
- X-Powered-By:
44
- - Phusion Passenger 5.2.3
45
- Server:
46
- - nginx/1.12.2 + Phusion Passenger 5.2.3
47
- body:
48
- encoding: UTF-8
49
- string: '{"data":{"id":"58b64b91-4c0e-4058-9815-ed80b7d4604a","type":"events","attributes":{"subj-id":"https://metrics.test.datacite.org/reports/2018-3-Dash","obj-id":"https://doi.org/10.7291/d1q94r","message-action":"add","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","relation-type-id":"total-dataset-investigations-regular","source-id":"datacite","total":3,"license":"https://creativecommons.org/publicdomain/zero/1.0/","occurred-at":"2128-04-09T00:00:00.000Z","timestamp":"2018-05-07T15:07:42Z","subj":{"pid":"https://metrics.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"obj":{}}}}'
50
- http_version:
51
- recorded_at: Mon, 07 May 2018 15:07:42 GMT
52
- - request:
53
- method: post
54
- uri: https://api.test.datacite.org/events
55
- body:
56
- encoding: UTF-8
57
- string: '{"data":{"id":"d4934083-0552-4e32-bed1-b103698506aa","type":"events","attributes":{"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":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/"}}}'
58
- headers:
59
- User-Agent:
60
- - Maremma - https://github.com/datacite/maremma
61
- Content-Type:
62
- - application/json
63
- Accept:
64
- - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
65
- Authorization:
66
- - Bearer <LAGOTTO_TOKEN>
67
- response:
68
- status:
69
- code: 201
70
- message: ''
71
- headers:
72
- Date:
73
- - Mon, 07 May 2018 15:07:43 GMT
74
- Content-Type:
75
- - application/json; charset=utf-8
76
- Connection:
77
- - keep-alive
78
- Status:
79
- - 201 Created
80
- Cache-Control:
81
- - max-age=0, private, must-revalidate
82
- Vary:
83
- - Accept-Encoding, Origin
84
- Etag:
85
- - W/"5df37219e0abe7356435e8ad2c7d359f"
86
- X-Runtime:
87
- - '0.010413'
88
- X-Credential-Username:
89
- - 0000-0001-5489-3594
90
- X-Request-Id:
91
- - c86c445e-ffa4-4f8a-8a5c-64567b0ac8b9
92
- X-Powered-By:
93
- - Phusion Passenger 5.2.3
94
- Server:
95
- - nginx/1.12.2 + Phusion Passenger 5.2.3
96
- body:
97
- encoding: UTF-8
98
- string: '{"data":{"id":"5c4edbd7-3308-46d8-b018-4412988868f9","type":"events","attributes":{"subj-id":"https://metrics.test.datacite.org/reports/2018-3-Dash","obj-id":"https://doi.org/10.7291/d1q94r","message-action":"add","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","relation-type-id":"unique-dataset-investigations-regular","source-id":"datacite","total":3,"license":"https://creativecommons.org/publicdomain/zero/1.0/","occurred-at":"2128-04-09T00:00:00.000Z","timestamp":"2018-05-07T15:07:43Z","subj":{"pid":"https://metrics.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"obj":{}}}}'
99
- http_version:
100
- recorded_at: Mon, 07 May 2018 15:07:43 GMT
101
- - request:
102
- method: post
103
- uri: https://api.test.datacite.org/events
104
- body:
105
- encoding: UTF-8
106
- string: '{"data":{"id":"393ed959-b0b2-402b-aa48-e794529b9eef","type":"events","attributes":{"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":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/"}}}'
107
- headers:
108
- User-Agent:
109
- - Maremma - https://github.com/datacite/maremma
110
- Content-Type:
111
- - application/json
112
- Accept:
113
- - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
114
- Authorization:
115
- - Bearer <LAGOTTO_TOKEN>
116
- response:
117
- status:
118
- code: 201
119
- message: ''
120
- headers:
121
- Date:
122
- - Mon, 07 May 2018 15:07:43 GMT
123
- Content-Type:
124
- - application/json; charset=utf-8
125
- Connection:
126
- - keep-alive
127
- Status:
128
- - 201 Created
129
- Cache-Control:
130
- - max-age=0, private, must-revalidate
131
- Vary:
132
- - Accept-Encoding, Origin
133
- Etag:
134
- - W/"47258fc20a829faf79620c607b4b5e02"
135
- X-Runtime:
136
- - '0.010351'
137
- X-Credential-Username:
138
- - 0000-0001-5489-3594
139
- X-Request-Id:
140
- - e41d3e47-d6ff-46d4-9b37-bf80b5c485fe
141
- X-Powered-By:
142
- - Phusion Passenger 5.2.3
143
- Server:
144
- - nginx/1.12.2 + Phusion Passenger 5.2.3
145
- body:
146
- encoding: UTF-8
147
- string: '{"data":{"id":"8fde079c-f919-4d7f-96cb-e74e861c09e3","type":"events","attributes":{"subj-id":"https://metrics.test.datacite.org/reports/2018-3-Dash","obj-id":"https://doi.org/10.7291/d1q94r","message-action":"add","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","relation-type-id":"total-dataset-investigations-regular","source-id":"datacite","total":3,"license":"https://creativecommons.org/publicdomain/zero/1.0/","occurred-at":"2128-04-09T00:00:00.000Z","timestamp":"2018-05-07T15:07:43Z","subj":{"pid":"https://metrics.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"obj":{}}}}'
148
- http_version:
149
- recorded_at: Mon, 07 May 2018 15:07:43 GMT
150
- - request:
151
- method: post
152
- uri: https://api.test.datacite.org/events
153
- body:
154
- encoding: UTF-8
155
- string: '{"data":{"id":"d4934083-0552-4e32-bed1-b103698506aa","type":"events","attributes":{"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":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/"}}}'
156
- headers:
157
- User-Agent:
158
- - Maremma - https://github.com/datacite/maremma
159
- Content-Type:
160
- - application/json
161
- Accept:
162
- - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
163
- Authorization:
164
- - Bearer <LAGOTTO_TOKEN>
165
- response:
166
- status:
167
- code: 201
168
- message: ''
169
- headers:
170
- Date:
171
- - Mon, 07 May 2018 15:07:43 GMT
172
- Content-Type:
173
- - application/json; charset=utf-8
174
- Connection:
175
- - keep-alive
176
- Status:
177
- - 201 Created
178
- Cache-Control:
179
- - max-age=0, private, must-revalidate
180
- Vary:
181
- - Accept-Encoding, Origin
182
- Etag:
183
- - W/"ccb671619889c6d8d1340da3814ef0a0"
184
- X-Runtime:
185
- - '0.010571'
186
- X-Credential-Username:
187
- - 0000-0001-5489-3594
188
- X-Request-Id:
189
- - 3504a0cb-d384-490d-922f-15dbf095c42d
190
- X-Powered-By:
191
- - Phusion Passenger 5.2.3
192
- Server:
193
- - nginx/1.12.2 + Phusion Passenger 5.2.3
194
- body:
195
- encoding: UTF-8
196
- string: '{"data":{"id":"b14650aa-817e-4922-a06d-27d6a21a9920","type":"events","attributes":{"subj-id":"https://metrics.test.datacite.org/reports/2018-3-Dash","obj-id":"https://doi.org/10.7291/d1q94r","message-action":"add","source-token":"28276d12-b320-41ba-9272-bb0adc3466ff","relation-type-id":"unique-dataset-investigations-regular","source-id":"datacite","total":3,"license":"https://creativecommons.org/publicdomain/zero/1.0/","occurred-at":"2128-04-09T00:00:00.000Z","timestamp":"2018-05-07T15:07:43Z","subj":{"pid":"https://metrics.test.datacite.org/reports/2018-3-Dash","issued":"2128-04-09"},"obj":{}}}}'
197
- http_version:
198
- recorded_at: Mon, 07 May 2018 15:07:43 GMT
199
- recorded_with: VCR 3.0.3