yt 0.25.13 → 0.32.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +305 -1
- data/MIT-LICENSE +1 -1
- data/README.md +86 -5
- data/YOUTUBE_IT.md +3 -3
- data/lib/yt.rb +5 -2
- data/lib/yt/actions/list.rb +3 -3
- data/lib/yt/associations/has_authentication.rb +33 -1
- data/lib/yt/associations/has_reports.rb +13 -18
- data/lib/yt/collections/assets.rb +2 -2
- data/lib/yt/collections/authentications.rb +9 -2
- data/lib/yt/collections/base.rb +3 -3
- data/lib/yt/collections/bulk_report_jobs.rb +28 -0
- data/lib/yt/collections/bulk_reports.rb +24 -0
- data/lib/yt/collections/claims.rb +22 -1
- data/lib/yt/collections/comment_threads.rb +41 -0
- data/lib/yt/collections/content_owners.rb +1 -1
- data/lib/yt/collections/group_infos.rb +27 -0
- data/lib/yt/collections/group_items.rb +45 -0
- data/lib/yt/collections/reports.rb +75 -13
- data/lib/yt/collections/revocations.rb +30 -0
- data/lib/yt/collections/video_groups.rb +29 -0
- data/lib/yt/collections/videos.rb +34 -9
- data/lib/yt/constants/geography.rb +326 -0
- data/lib/yt/errors/forbidden.rb +1 -3
- data/lib/yt/errors/no_items.rb +1 -3
- data/lib/yt/errors/request_error.rb +10 -7
- data/lib/yt/errors/server_error.rb +1 -3
- data/lib/yt/errors/unauthorized.rb +3 -3
- data/lib/yt/models/account.rb +12 -0
- data/lib/yt/models/advertising_options_set.rb +4 -4
- data/lib/yt/models/bulk_report.rb +23 -0
- data/lib/yt/models/bulk_report_job.rb +23 -0
- data/lib/yt/models/channel.rb +21 -12
- data/lib/yt/models/claim.rb +13 -2
- data/lib/yt/models/comment.rb +37 -0
- data/lib/yt/models/comment_thread.rb +50 -0
- data/lib/yt/models/content_detail.rb +6 -0
- data/lib/yt/models/content_owner.rb +31 -1
- data/lib/yt/models/group_info.rb +16 -0
- data/lib/yt/models/group_item.rb +15 -0
- data/lib/yt/models/resource.rb +3 -10
- data/lib/yt/models/revocation.rb +12 -0
- data/lib/yt/models/right_owner.rb +0 -2
- data/lib/yt/models/snippet.rb +24 -3
- data/lib/yt/models/video.rb +42 -11
- data/lib/yt/models/video_group.rb +186 -0
- data/lib/yt/request.rb +5 -3
- data/lib/yt/version.rb +2 -2
- data/spec/collections/comment_threads_spec.rb +46 -0
- data/spec/collections/playlist_items_spec.rb +1 -1
- data/spec/collections/reports_spec.rb +2 -2
- data/spec/constants/geography_spec.rb +16 -0
- data/spec/models/annotation_spec.rb +1 -1
- data/spec/models/claim_spec.rb +15 -3
- data/spec/models/comment_spec.rb +40 -0
- data/spec/models/comment_thread_spec.rb +93 -0
- data/spec/models/content_detail_spec.rb +7 -0
- data/spec/models/reference_spec.rb +2 -2
- data/spec/models/request_spec.rb +21 -0
- data/spec/models/resource_spec.rb +0 -15
- data/spec/models/video_spec.rb +1 -1
- data/spec/requests/as_account/account_spec.rb +16 -4
- data/spec/requests/as_account/authentications_spec.rb +1 -13
- data/spec/requests/as_account/channel_spec.rb +15 -45
- data/spec/requests/as_account/playlist_item_spec.rb +3 -3
- data/spec/requests/as_account/playlist_spec.rb +5 -32
- data/spec/requests/as_account/video_spec.rb +2022 -21
- data/spec/requests/as_content_owner/account_spec.rb +4 -0
- data/spec/requests/as_content_owner/bulk_report_job_spec.rb +19 -0
- data/spec/requests/as_content_owner/channel_spec.rb +59 -270
- data/spec/requests/as_content_owner/content_owner_spec.rb +89 -1
- data/spec/requests/as_content_owner/playlist_spec.rb +0 -15
- data/spec/requests/as_content_owner/video_group_spec.rb +112 -0
- data/spec/requests/as_content_owner/video_spec.rb +72 -146
- data/spec/requests/as_server_app/channel_spec.rb +1 -21
- data/spec/requests/as_server_app/comment_spec.rb +22 -0
- data/spec/requests/as_server_app/comment_thread_spec.rb +27 -0
- data/spec/requests/as_server_app/comment_threads_spec.rb +41 -0
- data/spec/requests/as_server_app/playlist_item_spec.rb +2 -2
- data/spec/requests/as_server_app/playlist_spec.rb +1 -22
- data/spec/requests/as_server_app/video_spec.rb +21 -19
- data/spec/requests/as_server_app/videos_spec.rb +5 -5
- data/spec/requests/unauthenticated/video_spec.rb +1 -9
- data/spec/spec_helper.rb +1 -1
- data/yt.gemspec +2 -1
- metadata +51 -17
- data/lib/yt/collections/ids.rb +0 -27
- data/lib/yt/config.rb +0 -54
- data/lib/yt/models/configuration.rb +0 -70
- data/lib/yt/models/description.rb +0 -58
- data/lib/yt/models/url.rb +0 -91
- data/spec/models/configuration_spec.rb +0 -44
- data/spec/models/description_spec.rb +0 -94
- data/spec/models/url_spec.rb +0 -84
- data/spec/requests/as_account/resource_spec.rb +0 -18
@@ -16,6 +16,10 @@ describe Yt::Account, :partner do
|
|
16
16
|
expect(content_owners.first).to be_a Yt::ContentOwner
|
17
17
|
end
|
18
18
|
|
19
|
+
specify 'includes the display name for each content owner' do
|
20
|
+
expect(content_owners.first.display_name).to be_a String
|
21
|
+
end
|
22
|
+
|
19
23
|
specify 'ensures the content owners have the same credentials as the account' do
|
20
24
|
expect(content_owners.first.access_token).to eq account.access_token
|
21
25
|
expect(content_owners.first.refresh_token).to eq account.refresh_token
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yt/models/bulk_report_job'
|
3
|
+
|
4
|
+
describe Yt::BulkReportJob, :partner do
|
5
|
+
|
6
|
+
describe '.bulk_reports' do
|
7
|
+
describe 'given the bulk report job has bulk reports' do
|
8
|
+
let(:job) { $content_owner.bulk_report_jobs.first }
|
9
|
+
let(:report) { job.bulk_reports.first }
|
10
|
+
|
11
|
+
it 'returns valid bulk reports' do
|
12
|
+
expect(report.id).to be_a String
|
13
|
+
expect(report.start_time).to be_a Time
|
14
|
+
expect(report.end_time).to be_a Time
|
15
|
+
expect(report.download_url).to be_a String
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -11,17 +11,19 @@ describe Yt::Channel, :partner do
|
|
11
11
|
let(:id) { ENV['YT_TEST_PARTNER_CHANNEL_ID'] }
|
12
12
|
|
13
13
|
describe 'multiple reports can be retrieved at once' do
|
14
|
-
metrics = {views: Integer,
|
14
|
+
metrics = {views: Integer,
|
15
15
|
estimated_minutes_watched: Integer, comments: Integer, likes: Integer,
|
16
16
|
dislikes: Integer, shares: Integer, subscribers_gained: Integer,
|
17
|
-
subscribers_lost: Integer,
|
17
|
+
subscribers_lost: Integer,
|
18
18
|
videos_added_to_playlists: Integer, videos_removed_from_playlists: Integer,
|
19
|
-
|
19
|
+
average_view_duration: Integer,
|
20
20
|
average_view_percentage: Float, annotation_clicks: Integer,
|
21
|
-
annotation_click_through_rate: Float,
|
22
|
-
|
21
|
+
annotation_click_through_rate: Float, annotation_close_rate: Float,
|
22
|
+
card_impressions: Integer, card_clicks: Integer,
|
23
|
+
card_click_rate: Float, card_teaser_impressions: Integer,
|
24
|
+
card_teaser_clicks: Integer, card_teaser_click_rate: Float,
|
25
|
+
estimated_revenue: Float, ad_impressions: Integer,
|
23
26
|
monetized_playbacks: Integer, playback_based_cpm: Float}
|
24
|
-
|
25
27
|
specify 'by day, and are chronologically sorted' do
|
26
28
|
range = {since: 5.days.ago.to_date, until: 3.days.ago.to_date}
|
27
29
|
result = channel.reports range.merge(only: metrics, by: :day)
|
@@ -57,13 +59,15 @@ describe Yt::Channel, :partner do
|
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
60
|
-
[:views, :
|
61
|
-
:subscribers_gained, :subscribers_lost,
|
62
|
+
[:views, :comments, :likes, :dislikes, :shares,
|
63
|
+
:subscribers_gained, :subscribers_lost,
|
62
64
|
:videos_added_to_playlists, :videos_removed_from_playlists,
|
63
|
-
:
|
64
|
-
:average_view_percentage, :
|
65
|
-
:annotation_clicks, :annotation_click_through_rate,
|
66
|
-
:
|
65
|
+
:estimated_minutes_watched, :average_view_duration,
|
66
|
+
:average_view_percentage, :ad_impressions, :monetized_playbacks,
|
67
|
+
:annotation_clicks, :annotation_click_through_rate,
|
68
|
+
:card_impressions, :card_clicks, :card_click_rate,
|
69
|
+
:card_teaser_impressions, :card_teaser_clicks, :card_teaser_click_rate,
|
70
|
+
:playback_based_cpm, :annotation_close_rate, :estimated_revenue].each do |metric|
|
67
71
|
describe "#{metric} can be retrieved for a range of days" do
|
68
72
|
let(:date_in) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
69
73
|
let(:date_out) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
|
@@ -118,27 +122,14 @@ describe Yt::Channel, :partner do
|
|
118
122
|
subscribers_gained: Integer, subscribers_lost: Integer,
|
119
123
|
estimated_minutes_watched: Integer, average_view_duration: Integer,
|
120
124
|
annotation_clicks: Integer, annotation_click_through_rate: Float,
|
121
|
-
|
125
|
+
card_impressions: Integer, card_clicks: Integer,
|
126
|
+
card_click_rate: Float, card_teaser_impressions: Integer,
|
127
|
+
card_teaser_clicks: Integer, card_teaser_click_rate: Float,
|
122
128
|
videos_added_to_playlists: Integer, videos_removed_from_playlists: Integer,
|
123
|
-
average_view_percentage: Float,
|
129
|
+
average_view_percentage: Float, ad_impressions: Integer,
|
124
130
|
shares: Integer, playback_based_cpm: Float,
|
125
131
|
monetized_playbacks: Integer, annotation_close_rate: Float,
|
126
|
-
|
127
|
-
describe "#{metric} can be retrieved for a specific day" do
|
128
|
-
let(:metric) { metric }
|
129
|
-
let(:result) { channel.public_send "#{metric}_on", date }
|
130
|
-
|
131
|
-
context 'in which the channel had data for the report' do
|
132
|
-
let(:date) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 95 }
|
133
|
-
it { expect(result).to be_a type }
|
134
|
-
end
|
135
|
-
|
136
|
-
context 'in which the channel was not partnered' do
|
137
|
-
let(:date) { 5.days.from_now }
|
138
|
-
it { expect(result).to be_nil }
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
132
|
+
estimated_revenue: Float}.each do |metric, type|
|
142
133
|
describe "#{metric} can be grouped by range" do
|
143
134
|
let(:metric) { metric }
|
144
135
|
|
@@ -160,24 +151,24 @@ describe Yt::Channel, :partner do
|
|
160
151
|
end
|
161
152
|
end
|
162
153
|
|
163
|
-
describe '
|
154
|
+
describe 'estimated_revenue can be retrieved for a specific day' do
|
164
155
|
# NOTE: This test sounds redundant, but it’s actually a reflection of
|
165
156
|
# another irrational behavior of YouTube API. In short, if you ask for
|
166
|
-
# the "
|
167
|
-
# the API returns "nil". But if you also for the "
|
157
|
+
# the "estimated_revenue" metric of a day in which a channel made 0 USD, then
|
158
|
+
# the API returns "nil". But if you also for the "estimated_revenue" metric AND
|
168
159
|
# the "estimatedMinutesWatched" metric, then the API returns the
|
169
160
|
# correct value of "0", while still returning nil for those days in
|
170
|
-
# which the
|
161
|
+
# which the estimated_revenue have not been estimated yet.
|
171
162
|
context 'in which the channel did not make any money' do
|
172
|
-
let(:zero_date) { ENV['
|
173
|
-
let(:
|
174
|
-
it { expect(
|
163
|
+
let(:zero_date) { ENV['YT_TEST_PARTNER_CHANNEL_NO_estimated_revenue_DATE'] }
|
164
|
+
let(:estimated_revenue) { channel.estimated_revenue_on zero_date}
|
165
|
+
it { expect(estimated_revenue).to eq 0 }
|
175
166
|
end
|
176
167
|
end
|
177
168
|
|
178
|
-
describe '
|
169
|
+
describe 'estimated_revenue can be retrieved for a single country' do
|
179
170
|
let(:country_code) { 'US' }
|
180
|
-
let(:
|
171
|
+
let(:estimated_revenue) { channel.estimated_revenue since: date, by: by, in: location }
|
181
172
|
let(:date) { 4.days.ago }
|
182
173
|
|
183
174
|
context 'and grouped by day' do
|
@@ -185,12 +176,12 @@ describe Yt::Channel, :partner do
|
|
185
176
|
|
186
177
|
context 'with the :in option set to the country code' do
|
187
178
|
let(:location) { country_code }
|
188
|
-
it { expect(
|
179
|
+
it { expect(estimated_revenue.keys.min).to eq date.to_date }
|
189
180
|
end
|
190
181
|
|
191
182
|
context 'with the :in option set to {country: country code}' do
|
192
183
|
let(:location) { {country: country_code} }
|
193
|
-
it { expect(
|
184
|
+
it { expect(estimated_revenue.keys.min).to eq date.to_date }
|
194
185
|
end
|
195
186
|
end
|
196
187
|
|
@@ -199,34 +190,34 @@ describe Yt::Channel, :partner do
|
|
199
190
|
|
200
191
|
context 'with the :in option set to the country code' do
|
201
192
|
let(:location) { country_code }
|
202
|
-
it { expect(
|
193
|
+
it { expect(estimated_revenue.keys).to eq [country_code] }
|
203
194
|
end
|
204
195
|
|
205
196
|
context 'with the :in option set to {country: country code}' do
|
206
197
|
let(:location) { {country: country_code} }
|
207
|
-
it { expect(
|
198
|
+
it { expect(estimated_revenue.keys).to eq [country_code] }
|
208
199
|
end
|
209
200
|
end
|
210
201
|
end
|
211
202
|
|
212
|
-
describe '
|
203
|
+
describe 'estimated_revenue can be grouped by day' do
|
213
204
|
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
214
205
|
let(:keys) { range.values }
|
215
206
|
|
216
207
|
specify 'with the :by option set to :day' do
|
217
|
-
|
218
|
-
expect(
|
208
|
+
estimated_revenue = channel.estimated_revenue range.merge by: :day
|
209
|
+
expect(estimated_revenue.keys).to eq range.values
|
219
210
|
end
|
220
211
|
end
|
221
212
|
|
222
|
-
describe '
|
213
|
+
describe 'estimated_revenue can be grouped by country' do
|
223
214
|
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
224
215
|
|
225
216
|
specify 'with the :by option set to :country' do
|
226
|
-
|
227
|
-
expect(
|
228
|
-
expect(
|
229
|
-
expect(
|
217
|
+
estimated_revenue = channel.estimated_revenue range.merge by: :country
|
218
|
+
expect(estimated_revenue.keys).to all(be_a String)
|
219
|
+
expect(estimated_revenue.keys.map(&:length).uniq).to eq [2]
|
220
|
+
expect(estimated_revenue.values).to all(be_a Float)
|
230
221
|
end
|
231
222
|
end
|
232
223
|
|
@@ -496,56 +487,6 @@ describe Yt::Channel, :partner do
|
|
496
487
|
end
|
497
488
|
end
|
498
489
|
|
499
|
-
describe 'uniques can be retrieved for a single country' do
|
500
|
-
let(:country_code) { 'US' }
|
501
|
-
let(:uniques) { channel.uniques since: date, by: by, in: location }
|
502
|
-
let(:date) { 4.days.ago }
|
503
|
-
|
504
|
-
context 'and grouped by day' do
|
505
|
-
let(:by) { :day }
|
506
|
-
|
507
|
-
context 'with the :in option set to the country code' do
|
508
|
-
let(:location) { country_code }
|
509
|
-
it { expect(uniques.keys.min).to eq date.to_date }
|
510
|
-
end
|
511
|
-
|
512
|
-
context 'with the :in option set to {country: country code}' do
|
513
|
-
let(:location) { {country: country_code} }
|
514
|
-
it { expect(uniques.keys.min).to eq date.to_date }
|
515
|
-
end
|
516
|
-
end
|
517
|
-
end
|
518
|
-
|
519
|
-
describe 'uniques can be retrieved for a single US state' do
|
520
|
-
let(:state_code) { 'NY' }
|
521
|
-
let(:result) { channel.uniques since: date, by: by, in: location }
|
522
|
-
let(:date) { 4.days.ago }
|
523
|
-
|
524
|
-
context 'and grouped by day' do
|
525
|
-
let(:by) { :day }
|
526
|
-
|
527
|
-
context 'with the :in option set to {state: state code}' do
|
528
|
-
let(:location) { {state: state_code} }
|
529
|
-
it { expect(result.keys.min).to eq date.to_date }
|
530
|
-
end
|
531
|
-
|
532
|
-
context 'with the :in option set to {country: "US", state: state code}' do
|
533
|
-
let(:location) { {country: 'US', state: state_code} }
|
534
|
-
it { expect(result.keys.min).to eq date.to_date }
|
535
|
-
end
|
536
|
-
end
|
537
|
-
end
|
538
|
-
|
539
|
-
describe 'uniques can be grouped by day' do
|
540
|
-
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
541
|
-
let(:keys) { range.values }
|
542
|
-
|
543
|
-
specify 'with the :by option set to :day' do
|
544
|
-
uniques = channel.uniques range.merge by: :day
|
545
|
-
expect(uniques.keys).to eq range.values
|
546
|
-
end
|
547
|
-
end
|
548
|
-
|
549
490
|
describe 'comments can be retrieved for a single country' do
|
550
491
|
let(:country_code) { 'US' }
|
551
492
|
let(:comments) { channel.comments since: date, by: by, in: location }
|
@@ -876,116 +817,6 @@ describe Yt::Channel, :partner do
|
|
876
817
|
end
|
877
818
|
end
|
878
819
|
|
879
|
-
describe 'favorites added can be retrieved for a single country' do
|
880
|
-
let(:country_code) { 'US' }
|
881
|
-
let(:favorites_added) { channel.favorites_added since: date, by: by, in: location }
|
882
|
-
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
883
|
-
|
884
|
-
context 'and grouped by day' do
|
885
|
-
let(:by) { :day }
|
886
|
-
|
887
|
-
context 'with the :in option set to the country code' do
|
888
|
-
let(:location) { country_code }
|
889
|
-
it { expect(favorites_added.keys.min).to eq date.to_date }
|
890
|
-
end
|
891
|
-
|
892
|
-
context 'with the :in option set to {country: country code}' do
|
893
|
-
let(:location) { {country: country_code} }
|
894
|
-
it { expect(favorites_added.keys.min).to eq date.to_date }
|
895
|
-
end
|
896
|
-
end
|
897
|
-
|
898
|
-
context 'and grouped by country' do
|
899
|
-
let(:by) { :country }
|
900
|
-
|
901
|
-
context 'with the :in option set to the country code' do
|
902
|
-
let(:location) { country_code }
|
903
|
-
it { expect(favorites_added.keys).to eq [country_code] }
|
904
|
-
end
|
905
|
-
|
906
|
-
context 'with the :in option set to {country: country code}' do
|
907
|
-
let(:location) { {country: country_code} }
|
908
|
-
it { expect(favorites_added.keys).to eq [country_code] }
|
909
|
-
end
|
910
|
-
end
|
911
|
-
end
|
912
|
-
|
913
|
-
describe 'added favorites can be grouped by day' do
|
914
|
-
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
915
|
-
let(:keys) { range.values }
|
916
|
-
|
917
|
-
specify 'with the :by option set to :day' do
|
918
|
-
favorites_added = channel.favorites_added range.merge by: :day
|
919
|
-
expect(favorites_added.keys).to eq range.values
|
920
|
-
end
|
921
|
-
end
|
922
|
-
|
923
|
-
describe 'added favorites can be grouped by country' do
|
924
|
-
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
925
|
-
|
926
|
-
specify 'with the :by option set to :country' do
|
927
|
-
favorites_added = channel.favorites_added range.merge by: :country
|
928
|
-
expect(favorites_added.keys).to all(be_a String)
|
929
|
-
expect(favorites_added.keys.map(&:length).uniq).to eq [2]
|
930
|
-
expect(favorites_added.values).to all(be_an Integer)
|
931
|
-
end
|
932
|
-
end
|
933
|
-
|
934
|
-
describe 'favorites removed can be retrieved for a single country' do
|
935
|
-
let(:country_code) { 'US' }
|
936
|
-
let(:favorites_removed) { channel.favorites_removed since: date, by: by, in: location }
|
937
|
-
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
938
|
-
|
939
|
-
context 'and grouped by day' do
|
940
|
-
let(:by) { :day }
|
941
|
-
|
942
|
-
context 'with the :in option set to the country code' do
|
943
|
-
let(:location) { country_code }
|
944
|
-
it { expect(favorites_removed.keys.min).to eq date.to_date }
|
945
|
-
end
|
946
|
-
|
947
|
-
context 'with the :in option set to {country: country code}' do
|
948
|
-
let(:location) { {country: country_code} }
|
949
|
-
it { expect(favorites_removed.keys.min).to eq date.to_date }
|
950
|
-
end
|
951
|
-
end
|
952
|
-
|
953
|
-
context 'and grouped by country' do
|
954
|
-
let(:by) { :country }
|
955
|
-
|
956
|
-
context 'with the :in option set to the country code' do
|
957
|
-
let(:location) { country_code }
|
958
|
-
it { expect(favorites_removed.keys).to eq [country_code] }
|
959
|
-
end
|
960
|
-
|
961
|
-
context 'with the :in option set to {country: country code}' do
|
962
|
-
let(:location) { {country: country_code} }
|
963
|
-
it { expect(favorites_removed.keys).to eq [country_code] }
|
964
|
-
end
|
965
|
-
end
|
966
|
-
end
|
967
|
-
|
968
|
-
describe 'removed favorites can be grouped by day' do
|
969
|
-
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
970
|
-
let(:keys) { range.values }
|
971
|
-
|
972
|
-
specify 'with the :by option set to :day' do
|
973
|
-
favorites_removed = channel.favorites_removed range.merge by: :day
|
974
|
-
expect(favorites_removed.keys).to eq range.values
|
975
|
-
end
|
976
|
-
end
|
977
|
-
|
978
|
-
describe 'removed favorites can be grouped by country' do
|
979
|
-
let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
|
980
|
-
|
981
|
-
specify 'with the :by option set to :country' do
|
982
|
-
favorites_removed = channel.favorites_removed range.merge by: :country
|
983
|
-
expect(favorites_removed.keys).to all(be_a String)
|
984
|
-
expect(favorites_removed.keys.map(&:length).uniq).to eq [2]
|
985
|
-
expect(favorites_removed.values).to all(be_an Integer)
|
986
|
-
end
|
987
|
-
end
|
988
|
-
|
989
820
|
describe 'videos added to playlists can be retrieved for a single country' do
|
990
821
|
let(:country_code) { 'US' }
|
991
822
|
let(:videos_added_to_playlists) { channel.videos_added_to_playlists since: date, by: by, in: location }
|
@@ -1020,27 +851,6 @@ describe Yt::Channel, :partner do
|
|
1020
851
|
end
|
1021
852
|
end
|
1022
853
|
|
1023
|
-
describe 'added favorites can be grouped by day' do
|
1024
|
-
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
1025
|
-
let(:keys) { range.values }
|
1026
|
-
|
1027
|
-
specify 'with the :by option set to :day' do
|
1028
|
-
videos_added_to_playlists = channel.videos_added_to_playlists range.merge by: :day
|
1029
|
-
expect(videos_added_to_playlists.keys).to eq range.values
|
1030
|
-
end
|
1031
|
-
end
|
1032
|
-
|
1033
|
-
describe 'added favorites can be grouped by country' do
|
1034
|
-
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
1035
|
-
|
1036
|
-
specify 'with the :by option set to :country' do
|
1037
|
-
videos_added_to_playlists = channel.videos_added_to_playlists range.merge by: :country
|
1038
|
-
expect(videos_added_to_playlists.keys).to all(be_a String)
|
1039
|
-
expect(videos_added_to_playlists.keys.map(&:length).uniq).to eq [2]
|
1040
|
-
expect(videos_added_to_playlists.values).to all(be_an Integer)
|
1041
|
-
end
|
1042
|
-
end
|
1043
|
-
|
1044
854
|
describe 'videos removed from playlists can be retrieved for a single country' do
|
1045
855
|
let(:country_code) { 'US' }
|
1046
856
|
let(:videos_removed_from_playlists) { channel.videos_removed_from_playlists since: date, by: by, in: location }
|
@@ -1075,27 +885,6 @@ describe Yt::Channel, :partner do
|
|
1075
885
|
end
|
1076
886
|
end
|
1077
887
|
|
1078
|
-
describe 'removed favorites can be grouped by day' do
|
1079
|
-
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
1080
|
-
let(:keys) { range.values }
|
1081
|
-
|
1082
|
-
specify 'with the :by option set to :day' do
|
1083
|
-
videos_removed_from_playlists = channel.videos_removed_from_playlists range.merge by: :day
|
1084
|
-
expect(videos_removed_from_playlists.keys).to eq range.values
|
1085
|
-
end
|
1086
|
-
end
|
1087
|
-
|
1088
|
-
describe 'removed favorites can be grouped by country' do
|
1089
|
-
let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
|
1090
|
-
|
1091
|
-
specify 'with the :by option set to :country' do
|
1092
|
-
videos_removed_from_playlists = channel.videos_removed_from_playlists range.merge by: :country
|
1093
|
-
expect(videos_removed_from_playlists.keys).to all(be_a String)
|
1094
|
-
expect(videos_removed_from_playlists.keys.map(&:length).uniq).to eq [2]
|
1095
|
-
expect(videos_removed_from_playlists.values).to all(be_an Integer)
|
1096
|
-
end
|
1097
|
-
end
|
1098
|
-
|
1099
888
|
describe 'estimated minutes watched can be retrieved for a single country' do
|
1100
889
|
let(:country_code) { 'US' }
|
1101
890
|
let(:estimated_minutes_watched) { channel.estimated_minutes_watched since: date, by: by, in: location }
|
@@ -1480,9 +1269,9 @@ describe Yt::Channel, :partner do
|
|
1480
1269
|
end
|
1481
1270
|
end
|
1482
1271
|
|
1483
|
-
describe '
|
1272
|
+
describe 'ad_impressions can be retrieved for a single country' do
|
1484
1273
|
let(:country_code) { 'US' }
|
1485
|
-
let(:
|
1274
|
+
let(:ad_impressions) { channel.ad_impressions since: date, by: by, in: location }
|
1486
1275
|
let(:date) { ENV['YT_TEST_PARTNER_PLAYLIST_DATE'] }
|
1487
1276
|
|
1488
1277
|
context 'and grouped by day' do
|
@@ -1490,12 +1279,12 @@ describe Yt::Channel, :partner do
|
|
1490
1279
|
|
1491
1280
|
context 'with the :in option set to the country code' do
|
1492
1281
|
let(:location) { country_code }
|
1493
|
-
it { expect(
|
1282
|
+
it { expect(ad_impressions.keys.min).to eq date.to_date }
|
1494
1283
|
end
|
1495
1284
|
|
1496
1285
|
context 'with the :in option set to {country: country code}' do
|
1497
1286
|
let(:location) { {country: country_code} }
|
1498
|
-
it { expect(
|
1287
|
+
it { expect(ad_impressions.keys.min).to eq date.to_date }
|
1499
1288
|
end
|
1500
1289
|
end
|
1501
1290
|
|
@@ -1504,34 +1293,34 @@ describe Yt::Channel, :partner do
|
|
1504
1293
|
|
1505
1294
|
context 'with the :in option set to the country code' do
|
1506
1295
|
let(:location) { country_code }
|
1507
|
-
it { expect(
|
1296
|
+
it { expect(ad_impressions.keys).to eq [country_code] }
|
1508
1297
|
end
|
1509
1298
|
|
1510
1299
|
context 'with the :in option set to {country: country code}' do
|
1511
1300
|
let(:location) { {country: country_code} }
|
1512
|
-
it { expect(
|
1301
|
+
it { expect(ad_impressions.keys).to eq [country_code] }
|
1513
1302
|
end
|
1514
1303
|
end
|
1515
1304
|
end
|
1516
1305
|
|
1517
|
-
describe '
|
1306
|
+
describe 'ad_impressions can be grouped by day' do
|
1518
1307
|
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
1519
1308
|
let(:keys) { range.values }
|
1520
1309
|
|
1521
1310
|
specify 'with the :by option set to :day' do
|
1522
|
-
|
1523
|
-
expect(
|
1311
|
+
ad_impressions = channel.ad_impressions range.merge by: :day
|
1312
|
+
expect(ad_impressions.keys).to eq range.values
|
1524
1313
|
end
|
1525
1314
|
end
|
1526
1315
|
|
1527
|
-
describe '
|
1316
|
+
describe 'ad_impressions can be grouped by country' do
|
1528
1317
|
let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
|
1529
1318
|
|
1530
1319
|
specify 'with the :by option set to :country' do
|
1531
|
-
|
1532
|
-
expect(
|
1533
|
-
expect(
|
1534
|
-
expect(
|
1320
|
+
ad_impressions = channel.ad_impressions range.merge by: :country
|
1321
|
+
expect(ad_impressions.keys).to all(be_a String)
|
1322
|
+
expect(ad_impressions.keys.map(&:length).uniq).to eq [2]
|
1323
|
+
expect(ad_impressions.values).to all(be_an Integer)
|
1535
1324
|
end
|
1536
1325
|
end
|
1537
1326
|
|
@@ -2033,8 +1822,8 @@ describe Yt::Channel, :partner do
|
|
2033
1822
|
context 'not managed by the authenticated Content Owner' do
|
2034
1823
|
let(:id) { 'UCBR8-60-B28hp2BmDPdntcQ' }
|
2035
1824
|
|
2036
|
-
specify '
|
2037
|
-
expect{channel.
|
1825
|
+
specify 'estimated_revenue and ad_impressions cannot be retrieved' do
|
1826
|
+
expect{channel.estimated_revenue}.to raise_error Yt::Errors::Forbidden
|
2038
1827
|
expect{channel.views}.to raise_error Yt::Errors::Forbidden
|
2039
1828
|
end
|
2040
1829
|
|
@@ -2044,4 +1833,4 @@ describe Yt::Channel, :partner do
|
|
2044
1833
|
end
|
2045
1834
|
end
|
2046
1835
|
end
|
2047
|
-
end
|
1836
|
+
end
|