yt 0.22.2 → 0.23.0
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 +4 -4
- data/CHANGELOG.md +26 -0
- data/README.md +1 -1
- data/lib/yt/associations/has_reports.rb +4 -4
- data/lib/yt/version.rb +1 -1
- data/spec/requests/as_content_owner/channel_spec.rb +79 -817
- data/spec/requests/as_content_owner/playlist_spec.rb +78 -473
- data/spec/requests/as_content_owner/video_spec.rb +149 -1485
- metadata +2 -2
@@ -10,48 +10,92 @@ describe Yt::Playlist, :partner do
|
|
10
10
|
context 'managed by the authenticated Content Owner' do
|
11
11
|
let(:id) { ENV['YT_TEST_PARTNER_PLAYLIST_ID'] }
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
[:views, :estimated_minutes_watched, :average_view_duration,
|
14
|
+
:playlist_starts, :average_time_in_playlist, :views_per_playlist_start].each do |metric|
|
15
|
+
describe "#{metric} can be retrieved for a range of days" do
|
16
|
+
let(:date_in) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
17
|
+
let(:date_out) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
|
18
|
+
let(:metric) { metric }
|
19
|
+
let(:result) { playlist.public_send metric, options }
|
20
|
+
|
21
|
+
context 'with a given start and end (:since/:until option)' do
|
22
|
+
let(:options) { {by: :day, since: date_in, until: date_out} }
|
23
|
+
it { expect(result.keys.min).to eq date_in.to_date }
|
24
|
+
it { expect(result.keys.max).to eq date_out.to_date }
|
25
|
+
end
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
|
27
|
+
context 'with a given start and end (:from/:to option)' do
|
28
|
+
let(:options) { {by: :day, from: date_in, to: date_out} }
|
29
|
+
it { expect(result.keys.min).to eq date_in.to_date }
|
30
|
+
it { expect(result.keys.max).to eq date_out.to_date }
|
31
|
+
end
|
22
32
|
end
|
23
33
|
end
|
24
34
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
35
|
+
{views: Integer, estimated_minutes_watched: Float, average_view_duration: Float,
|
36
|
+
playlist_starts: Integer, average_time_in_playlist: Float,
|
37
|
+
views_per_playlist_start: Float}.each do |metric, type|
|
38
|
+
describe "#{metric} can be retrieved for a specific day" do
|
39
|
+
let(:metric) { metric }
|
40
|
+
let(:result) { playlist.public_send "#{metric}_on", date }
|
29
41
|
|
30
|
-
|
31
|
-
|
42
|
+
context 'in which the playlist had data' do
|
43
|
+
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
44
|
+
it { expect(result).to be_a type }
|
45
|
+
end
|
32
46
|
|
33
|
-
context '
|
34
|
-
let(:
|
35
|
-
it { expect(
|
47
|
+
context 'in the future' do
|
48
|
+
let(:date) { 5.days.from_now }
|
49
|
+
it { expect(result).to be_nil }
|
36
50
|
end
|
51
|
+
end
|
37
52
|
|
38
|
-
|
39
|
-
|
40
|
-
|
53
|
+
describe "#{metric} can be grouped by range" do
|
54
|
+
let(:metric) { metric }
|
55
|
+
|
56
|
+
context 'without a :by option (default)' do
|
57
|
+
let(:result) { playlist.public_send metric }
|
58
|
+
it { expect(result.size).to be 1 }
|
59
|
+
it { expect(result[:total]).to be_a type }
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'with the :by option set to :range' do
|
63
|
+
let(:result) { playlist.public_send metric, by: :range }
|
64
|
+
it { expect(result.size).to be 1 }
|
65
|
+
it { expect(result[:total]).to be_a type }
|
41
66
|
end
|
42
67
|
end
|
43
68
|
|
44
|
-
|
45
|
-
let(:
|
69
|
+
describe "#{metric} can be retrieved for a single country" do
|
70
|
+
let(:result) { playlist.public_send metric, options }
|
71
|
+
|
72
|
+
context 'and grouped by day' do
|
73
|
+
let(:date_in) { 5.days.ago }
|
74
|
+
let(:options) { {by: :day, since: date_in, in: location} }
|
46
75
|
|
47
|
-
|
48
|
-
|
49
|
-
|
76
|
+
context 'with the :in option set to the country code' do
|
77
|
+
let(:location) { 'US' }
|
78
|
+
it { expect(result.keys.min).to eq date_in.to_date }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'with the :in option set to {country: country code}' do
|
82
|
+
let(:location) { {country: 'US'} }
|
83
|
+
it { expect(result.keys.min).to eq date_in.to_date }
|
84
|
+
end
|
50
85
|
end
|
51
86
|
|
52
|
-
context '
|
53
|
-
let(:
|
54
|
-
|
87
|
+
context 'and grouped by country' do
|
88
|
+
let(:options) { {by: :country, in: location} }
|
89
|
+
|
90
|
+
context 'with the :in option set to the country code' do
|
91
|
+
let(:location) { 'US' }
|
92
|
+
it { expect(result.keys).to eq ['US'] }
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'with the :in option set to {country: country code}' do
|
96
|
+
let(:location) { {country: 'US'} }
|
97
|
+
it { expect(result.keys).to eq ['US'] }
|
98
|
+
end
|
55
99
|
end
|
56
100
|
end
|
57
101
|
end
|
@@ -59,7 +103,7 @@ describe Yt::Playlist, :partner do
|
|
59
103
|
describe 'views can be retrieved for a single US state' do
|
60
104
|
let(:state_code) { 'CA' }
|
61
105
|
let(:result) { playlist.views since: date, by: by, in: location }
|
62
|
-
let(:date) {
|
106
|
+
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
63
107
|
|
64
108
|
context 'and grouped by day' do
|
65
109
|
let(:by) { :day }
|
@@ -90,45 +134,10 @@ describe Yt::Playlist, :partner do
|
|
90
134
|
end
|
91
135
|
end
|
92
136
|
|
93
|
-
describe 'views can be retrieved for a range of days' do
|
94
|
-
let(:date) { 4.days.ago }
|
95
|
-
|
96
|
-
specify 'with a given start (:since option)' do
|
97
|
-
expect(playlist.views(since: date).keys.min).to eq date.to_date
|
98
|
-
end
|
99
|
-
|
100
|
-
specify 'with a given end (:until option)' do
|
101
|
-
expect(playlist.views(until: date).keys.max).to eq date.to_date
|
102
|
-
end
|
103
|
-
|
104
|
-
specify 'with a given start (:from option)' do
|
105
|
-
expect(playlist.views(from: date).keys.min).to eq date.to_date
|
106
|
-
end
|
107
|
-
|
108
|
-
specify 'with a given end (:to option)' do
|
109
|
-
expect(playlist.views(to: date).keys.max).to eq date.to_date
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
describe 'views can be grouped by range' do
|
114
|
-
let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
|
115
|
-
|
116
|
-
specify 'with the :by option set to :range' do
|
117
|
-
views = playlist.views range.merge by: :range
|
118
|
-
expect(views.size).to be 1
|
119
|
-
expect(views[:total]).to be_an Integer
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
137
|
describe 'views can be grouped by day' do
|
124
138
|
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
125
139
|
let(:keys) { range.values }
|
126
140
|
|
127
|
-
specify 'without a :by option (default)' do
|
128
|
-
views = playlist.views range
|
129
|
-
expect(views.keys).to eq range.values
|
130
|
-
end
|
131
|
-
|
132
141
|
specify 'with the :by option set to :day' do
|
133
142
|
views = playlist.views range.merge by: :day
|
134
143
|
expect(views.keys).to eq range.values
|
@@ -223,56 +232,10 @@ describe Yt::Playlist, :partner do
|
|
223
232
|
end
|
224
233
|
end
|
225
234
|
|
226
|
-
describe 'estimated minutes watched can be retrieved for a specific day' do
|
227
|
-
context 'in which the playlist was viewed' do
|
228
|
-
let(:minutes) { playlist.estimated_minutes_watched_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
|
229
|
-
it { expect(minutes).to be_a Float }
|
230
|
-
end
|
231
|
-
|
232
|
-
context 'in which the playlist was not viewed' do
|
233
|
-
let(:minutes) { playlist.estimated_minutes_watched_on 20.years.ago}
|
234
|
-
it { expect(minutes).to be_nil }
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
describe 'estimated minutes watched can be retrieved for a single country' do
|
239
|
-
let(:country_code) { 'US' }
|
240
|
-
let(:estimated_minutes_watched) { playlist.estimated_minutes_watched since: date, by: by, in: location }
|
241
|
-
let(:date) { 4.days.ago }
|
242
|
-
|
243
|
-
context 'and grouped by day' do
|
244
|
-
let(:by) { :day }
|
245
|
-
|
246
|
-
context 'with the :in option set to the country code' do
|
247
|
-
let(:location) { country_code }
|
248
|
-
it { expect(estimated_minutes_watched.keys.min).to eq date.to_date }
|
249
|
-
end
|
250
|
-
|
251
|
-
context 'with the :in option set to {country: country code}' do
|
252
|
-
let(:location) { {country: country_code} }
|
253
|
-
it { expect(estimated_minutes_watched.keys.min).to eq date.to_date }
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
context 'and grouped by country' do
|
258
|
-
let(:by) { :country }
|
259
|
-
|
260
|
-
context 'with the :in option set to the country code' do
|
261
|
-
let(:location) { country_code }
|
262
|
-
it { expect(estimated_minutes_watched.keys).to eq [country_code] }
|
263
|
-
end
|
264
|
-
|
265
|
-
context 'with the :in option set to {country: country code}' do
|
266
|
-
let(:location) { {country: country_code} }
|
267
|
-
it { expect(estimated_minutes_watched.keys).to eq [country_code] }
|
268
|
-
end
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
235
|
describe 'estimated minutes watched can be retrieved for a single US state' do
|
273
236
|
let(:state_code) { 'CA' }
|
274
237
|
let(:result) { playlist.estimated_minutes_watched since: date, by: by, in: location }
|
275
|
-
let(:date) {
|
238
|
+
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
276
239
|
|
277
240
|
context 'and grouped by day' do
|
278
241
|
let(:by) { :day }
|
@@ -303,45 +266,10 @@ describe Yt::Playlist, :partner do
|
|
303
266
|
end
|
304
267
|
end
|
305
268
|
|
306
|
-
describe 'estimated minutes watched can be retrieved for a range of days' do
|
307
|
-
let(:date) { 4.days.ago }
|
308
|
-
|
309
|
-
specify 'with a given start (:since option)' do
|
310
|
-
expect(playlist.estimated_minutes_watched(since: date).keys.min).to eq date.to_date
|
311
|
-
end
|
312
|
-
|
313
|
-
specify 'with a given end (:until option)' do
|
314
|
-
expect(playlist.estimated_minutes_watched(until: date).keys.max).to eq date.to_date
|
315
|
-
end
|
316
|
-
|
317
|
-
specify 'with a given start (:from option)' do
|
318
|
-
expect(playlist.estimated_minutes_watched(from: date).keys.min).to eq date.to_date
|
319
|
-
end
|
320
|
-
|
321
|
-
specify 'with a given end (:to option)' do
|
322
|
-
expect(playlist.estimated_minutes_watched(to: date).keys.max).to eq date.to_date
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
describe 'estimated minutes watched can be grouped by range' do
|
327
|
-
let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
|
328
|
-
|
329
|
-
specify 'with the :by option set to :range' do
|
330
|
-
minutes = playlist.estimated_minutes_watched range.merge by: :range
|
331
|
-
expect(minutes.size).to be 1
|
332
|
-
expect(minutes[:total]).to be_a Float
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
269
|
describe 'estimated minutes watched can be grouped by day' do
|
337
270
|
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
338
271
|
let(:keys) { range.values }
|
339
272
|
|
340
|
-
specify 'without a :by option (default)' do
|
341
|
-
minutes = playlist.estimated_minutes_watched range
|
342
|
-
expect(minutes.keys).to eq range.values
|
343
|
-
end
|
344
|
-
|
345
273
|
specify 'with the :by option set to :day' do
|
346
274
|
minutes = playlist.estimated_minutes_watched range.merge by: :day
|
347
275
|
expect(minutes.keys).to eq range.values
|
@@ -487,56 +415,11 @@ describe Yt::Playlist, :partner do
|
|
487
415
|
end
|
488
416
|
end
|
489
417
|
|
490
|
-
describe 'average view duration can be retrieved for a specific day' do
|
491
|
-
context 'in which the playlist was partnered' do
|
492
|
-
let(:average_view_duration) { playlist.average_view_duration_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
|
493
|
-
it { expect(average_view_duration).to be_a Float }
|
494
|
-
end
|
495
|
-
|
496
|
-
context 'in which the playlist was not partnered' do
|
497
|
-
let(:average_view_duration) { playlist.average_view_duration_on 20.years.ago}
|
498
|
-
it { expect(average_view_duration).to be_nil }
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
describe 'average view duration can be retrieved for a single country' do
|
503
|
-
let(:country_code) { 'US' }
|
504
|
-
let(:average_view_duration) { playlist.average_view_duration since: date, by: by, in: location }
|
505
|
-
let(:date) { 4.days.ago }
|
506
|
-
|
507
|
-
context 'and grouped by day' do
|
508
|
-
let(:by) { :day }
|
509
|
-
|
510
|
-
context 'with the :in option set to the country code' do
|
511
|
-
let(:location) { country_code }
|
512
|
-
it { expect(average_view_duration.keys.min).to eq date.to_date }
|
513
|
-
end
|
514
|
-
|
515
|
-
context 'with the :in option set to {country: country code}' do
|
516
|
-
let(:location) { {country: country_code} }
|
517
|
-
it { expect(average_view_duration.keys.min).to eq date.to_date }
|
518
|
-
end
|
519
|
-
end
|
520
|
-
|
521
|
-
context 'and grouped by country' do
|
522
|
-
let(:by) { :country }
|
523
|
-
|
524
|
-
context 'with the :in option set to the country code' do
|
525
|
-
let(:location) { country_code }
|
526
|
-
it { expect(average_view_duration.keys).to eq [country_code] }
|
527
|
-
end
|
528
|
-
|
529
|
-
context 'with the :in option set to {country: country code}' do
|
530
|
-
let(:location) { {country: country_code} }
|
531
|
-
it { expect(average_view_duration.keys).to eq [country_code] }
|
532
|
-
end
|
533
|
-
end
|
534
|
-
end
|
535
418
|
|
536
419
|
describe 'average view duration can be retrieved for a single US state' do
|
537
420
|
let(:state_code) { 'CA' }
|
538
421
|
let(:result) { playlist.average_view_duration since: date, by: by, in: location }
|
539
|
-
let(:date) {
|
422
|
+
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
540
423
|
|
541
424
|
context 'and grouped by day' do
|
542
425
|
let(:by) { :day }
|
@@ -567,45 +450,10 @@ describe Yt::Playlist, :partner do
|
|
567
450
|
end
|
568
451
|
end
|
569
452
|
|
570
|
-
describe 'average view duration can be retrieved for a range of days' do
|
571
|
-
let(:date) { 4.days.ago }
|
572
|
-
|
573
|
-
specify 'with a given start (:since option)' do
|
574
|
-
expect(playlist.average_view_duration(since: date).keys.min).to eq date.to_date
|
575
|
-
end
|
576
|
-
|
577
|
-
specify 'with a given end (:until option)' do
|
578
|
-
expect(playlist.average_view_duration(until: date).keys.max).to eq date.to_date
|
579
|
-
end
|
580
|
-
|
581
|
-
specify 'with a given start (:from option)' do
|
582
|
-
expect(playlist.average_view_duration(from: date).keys.min).to eq date.to_date
|
583
|
-
end
|
584
|
-
|
585
|
-
specify 'with a given end (:to option)' do
|
586
|
-
expect(playlist.average_view_duration(to: date).keys.max).to eq date.to_date
|
587
|
-
end
|
588
|
-
end
|
589
|
-
|
590
|
-
describe 'average view duration can be grouped by range' do
|
591
|
-
let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
|
592
|
-
|
593
|
-
specify 'with the :by option set to :range' do
|
594
|
-
duration = playlist.average_view_duration range.merge by: :range
|
595
|
-
expect(duration.size).to be 1
|
596
|
-
expect(duration[:total]).to be_a Float
|
597
|
-
end
|
598
|
-
end
|
599
|
-
|
600
453
|
describe 'average view duration can be grouped by day' do
|
601
454
|
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
602
455
|
let(:keys) { range.values }
|
603
456
|
|
604
|
-
specify 'without a :by option (default)' do
|
605
|
-
average_view_duration = playlist.average_view_duration range
|
606
|
-
expect(average_view_duration.keys).to eq range.values
|
607
|
-
end
|
608
|
-
|
609
457
|
specify 'with the :by option set to :day' do
|
610
458
|
average_view_duration = playlist.average_view_duration range.merge by: :day
|
611
459
|
expect(average_view_duration.keys).to eq range.values
|
@@ -634,56 +482,10 @@ describe Yt::Playlist, :partner do
|
|
634
482
|
end
|
635
483
|
end
|
636
484
|
|
637
|
-
describe 'playlist starts can be retrieved for a specific day' do
|
638
|
-
context 'in which the playlist was viewed' do
|
639
|
-
let(:playlist_starts) { playlist.playlist_starts_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
|
640
|
-
it { expect(playlist_starts).to be_an Integer }
|
641
|
-
end
|
642
|
-
|
643
|
-
context 'in which the playlist was not viewed' do
|
644
|
-
let(:playlist_starts) { playlist.playlist_starts_on 20.years.ago}
|
645
|
-
it { expect(playlist_starts).to be_nil }
|
646
|
-
end
|
647
|
-
end
|
648
|
-
|
649
|
-
describe 'playlist starts can be retrieved for a single country' do
|
650
|
-
let(:country_code) { 'US' }
|
651
|
-
let(:playlist_starts) { playlist.playlist_starts since: date, by: by, in: location }
|
652
|
-
let(:date) { 4.days.ago }
|
653
|
-
|
654
|
-
context 'and grouped by day' do
|
655
|
-
let(:by) { :day }
|
656
|
-
|
657
|
-
context 'with the :in option set to the country code' do
|
658
|
-
let(:location) { country_code }
|
659
|
-
it { expect(playlist_starts.keys.min).to eq date.to_date }
|
660
|
-
end
|
661
|
-
|
662
|
-
context 'with the :in option set to {country: country code}' do
|
663
|
-
let(:location) { {country: country_code} }
|
664
|
-
it { expect(playlist_starts.keys.min).to eq date.to_date }
|
665
|
-
end
|
666
|
-
end
|
667
|
-
|
668
|
-
context 'and grouped by country' do
|
669
|
-
let(:by) { :country }
|
670
|
-
|
671
|
-
context 'with the :in option set to the country code' do
|
672
|
-
let(:location) { country_code }
|
673
|
-
it { expect(playlist_starts.keys).to eq [country_code] }
|
674
|
-
end
|
675
|
-
|
676
|
-
context 'with the :in option set to {country: country code}' do
|
677
|
-
let(:location) { {country: country_code} }
|
678
|
-
it { expect(playlist_starts.keys).to eq [country_code] }
|
679
|
-
end
|
680
|
-
end
|
681
|
-
end
|
682
|
-
|
683
485
|
describe 'playlist starts can be retrieved for a single US state' do
|
684
486
|
let(:state_code) { 'CA' }
|
685
487
|
let(:result) { playlist.playlist_starts since: date, by: by, in: location }
|
686
|
-
let(:date) {
|
488
|
+
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
687
489
|
|
688
490
|
context 'and grouped by day' do
|
689
491
|
let(:by) { :day }
|
@@ -714,45 +516,10 @@ describe Yt::Playlist, :partner do
|
|
714
516
|
end
|
715
517
|
end
|
716
518
|
|
717
|
-
describe 'playlist starts can be retrieved for a range of days' do
|
718
|
-
let(:date) { 4.days.ago }
|
719
|
-
|
720
|
-
specify 'with a given start (:since option)' do
|
721
|
-
expect(playlist.playlist_starts(since: date).keys.min).to eq date.to_date
|
722
|
-
end
|
723
|
-
|
724
|
-
specify 'with a given end (:until option)' do
|
725
|
-
expect(playlist.playlist_starts(until: date).keys.max).to eq date.to_date
|
726
|
-
end
|
727
|
-
|
728
|
-
specify 'with a given start (:from option)' do
|
729
|
-
expect(playlist.playlist_starts(from: date).keys.min).to eq date.to_date
|
730
|
-
end
|
731
|
-
|
732
|
-
specify 'with a given end (:to option)' do
|
733
|
-
expect(playlist.playlist_starts(to: date).keys.max).to eq date.to_date
|
734
|
-
end
|
735
|
-
end
|
736
|
-
|
737
|
-
describe 'playlist starts can be grouped by range' do
|
738
|
-
let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
|
739
|
-
|
740
|
-
specify 'with the :by option set to :range' do
|
741
|
-
playlist_starts = playlist.playlist_starts range.merge by: :range
|
742
|
-
expect(playlist_starts.size).to be 1
|
743
|
-
expect(playlist_starts[:total]).to be_an Integer
|
744
|
-
end
|
745
|
-
end
|
746
|
-
|
747
519
|
describe 'playlist starts can be grouped by day' do
|
748
520
|
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
749
521
|
let(:keys) { range.values }
|
750
522
|
|
751
|
-
specify 'without a :by option (default)' do
|
752
|
-
playlist_starts = playlist.playlist_starts range
|
753
|
-
expect(playlist_starts.keys).to eq range.values
|
754
|
-
end
|
755
|
-
|
756
523
|
specify 'with the :by option set to :day' do
|
757
524
|
playlist_starts = playlist.playlist_starts range.merge by: :day
|
758
525
|
expect(playlist_starts.keys).to eq range.values
|
@@ -781,56 +548,10 @@ describe Yt::Playlist, :partner do
|
|
781
548
|
end
|
782
549
|
end
|
783
550
|
|
784
|
-
describe 'average time in playlist can be retrieved for a specific day' do
|
785
|
-
context 'in which the playlist was viewed' do
|
786
|
-
let(:average_time_in_playlist) { playlist.average_time_in_playlist_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
|
787
|
-
it { expect(average_time_in_playlist).to be_a Float }
|
788
|
-
end
|
789
|
-
|
790
|
-
context 'in which the playlist was not viewed' do
|
791
|
-
let(:average_time_in_playlist) { playlist.average_time_in_playlist_on 20.years.ago}
|
792
|
-
it { expect(average_time_in_playlist).to be_nil }
|
793
|
-
end
|
794
|
-
end
|
795
|
-
|
796
|
-
describe 'average time in playlist can be retrieved for a single country' do
|
797
|
-
let(:country_code) { 'US' }
|
798
|
-
let(:average_time_in_playlist) { playlist.average_time_in_playlist since: date, by: by, in: location }
|
799
|
-
let(:date) { 4.days.ago }
|
800
|
-
|
801
|
-
context 'and grouped by day' do
|
802
|
-
let(:by) { :day }
|
803
|
-
|
804
|
-
context 'with the :in option set to the country code' do
|
805
|
-
let(:location) { country_code }
|
806
|
-
it { expect(average_time_in_playlist.keys.min).to eq date.to_date }
|
807
|
-
end
|
808
|
-
|
809
|
-
context 'with the :in option set to {country: country code}' do
|
810
|
-
let(:location) { {country: country_code} }
|
811
|
-
it { expect(average_time_in_playlist.keys.min).to eq date.to_date }
|
812
|
-
end
|
813
|
-
end
|
814
|
-
|
815
|
-
context 'and grouped by country' do
|
816
|
-
let(:by) { :country }
|
817
|
-
|
818
|
-
context 'with the :in option set to the country code' do
|
819
|
-
let(:location) { country_code }
|
820
|
-
it { expect(average_time_in_playlist.keys).to eq [country_code] }
|
821
|
-
end
|
822
|
-
|
823
|
-
context 'with the :in option set to {country: country code}' do
|
824
|
-
let(:location) { {country: country_code} }
|
825
|
-
it { expect(average_time_in_playlist.keys).to eq [country_code] }
|
826
|
-
end
|
827
|
-
end
|
828
|
-
end
|
829
|
-
|
830
551
|
describe 'average time in playlist can be retrieved for a single US state' do
|
831
552
|
let(:state_code) { 'CA' }
|
832
553
|
let(:result) { playlist.average_time_in_playlist since: date, by: by, in: location }
|
833
|
-
let(:date) {
|
554
|
+
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
834
555
|
|
835
556
|
context 'and grouped by day' do
|
836
557
|
let(:by) { :day }
|
@@ -861,45 +582,10 @@ describe Yt::Playlist, :partner do
|
|
861
582
|
end
|
862
583
|
end
|
863
584
|
|
864
|
-
describe 'average time in playlist can be retrieved for a range of days' do
|
865
|
-
let(:date) { 4.days.ago }
|
866
|
-
|
867
|
-
specify 'with a given start (:since option)' do
|
868
|
-
expect(playlist.average_time_in_playlist(since: date).keys.min).to eq date.to_date
|
869
|
-
end
|
870
|
-
|
871
|
-
specify 'with a given end (:until option)' do
|
872
|
-
expect(playlist.average_time_in_playlist(until: date).keys.max).to eq date.to_date
|
873
|
-
end
|
874
|
-
|
875
|
-
specify 'with a given start (:from option)' do
|
876
|
-
expect(playlist.average_time_in_playlist(from: date).keys.min).to eq date.to_date
|
877
|
-
end
|
878
|
-
|
879
|
-
specify 'with a given end (:to option)' do
|
880
|
-
expect(playlist.average_time_in_playlist(to: date).keys.max).to eq date.to_date
|
881
|
-
end
|
882
|
-
end
|
883
|
-
|
884
|
-
describe 'average time in playlist can be grouped by range' do
|
885
|
-
let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
|
886
|
-
|
887
|
-
specify 'with the :by option set to :range' do
|
888
|
-
times = playlist.average_time_in_playlist range.merge by: :range
|
889
|
-
expect(times.size).to be 1
|
890
|
-
expect(times[:total]).to be_a Float
|
891
|
-
end
|
892
|
-
end
|
893
|
-
|
894
585
|
describe 'average time in playlist can be grouped by day' do
|
895
586
|
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
896
587
|
let(:keys) { range.values }
|
897
588
|
|
898
|
-
specify 'without a :by option (default)' do
|
899
|
-
average_time_in_playlist = playlist.average_time_in_playlist range
|
900
|
-
expect(average_time_in_playlist.keys).to eq range.values
|
901
|
-
end
|
902
|
-
|
903
589
|
specify 'with the :by option set to :day' do
|
904
590
|
average_time_in_playlist = playlist.average_time_in_playlist range.merge by: :day
|
905
591
|
expect(average_time_in_playlist.keys).to eq range.values
|
@@ -928,56 +614,10 @@ describe Yt::Playlist, :partner do
|
|
928
614
|
end
|
929
615
|
end
|
930
616
|
|
931
|
-
describe 'views per playlist start can be retrieved for a specific day' do
|
932
|
-
context 'in which the playlist was viewed' do
|
933
|
-
let(:views_per_playlist_start) { playlist.views_per_playlist_start_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
|
934
|
-
it { expect(views_per_playlist_start).to be_a Float }
|
935
|
-
end
|
936
|
-
|
937
|
-
context 'in which the playlist was not viewed' do
|
938
|
-
let(:views_per_playlist_start) { playlist.views_per_playlist_start_on 20.years.ago}
|
939
|
-
it { expect(views_per_playlist_start).to be_nil }
|
940
|
-
end
|
941
|
-
end
|
942
|
-
|
943
|
-
describe 'views per playlist start can be retrieved for a single country' do
|
944
|
-
let(:country_code) { 'US' }
|
945
|
-
let(:views_per_playlist_start) { playlist.views_per_playlist_start since: date, by: by, in: location }
|
946
|
-
let(:date) { 4.days.ago }
|
947
|
-
|
948
|
-
context 'and grouped by day' do
|
949
|
-
let(:by) { :day }
|
950
|
-
|
951
|
-
context 'with the :in option set to the country code' do
|
952
|
-
let(:location) { country_code }
|
953
|
-
it { expect(views_per_playlist_start.keys.min).to eq date.to_date }
|
954
|
-
end
|
955
|
-
|
956
|
-
context 'with the :in option set to {country: country code}' do
|
957
|
-
let(:location) { {country: country_code} }
|
958
|
-
it { expect(views_per_playlist_start.keys.min).to eq date.to_date }
|
959
|
-
end
|
960
|
-
end
|
961
|
-
|
962
|
-
context 'and grouped by country' do
|
963
|
-
let(:by) { :country }
|
964
|
-
|
965
|
-
context 'with the :in option set to the country code' do
|
966
|
-
let(:location) { country_code }
|
967
|
-
it { expect(views_per_playlist_start.keys).to eq [country_code] }
|
968
|
-
end
|
969
|
-
|
970
|
-
context 'with the :in option set to {country: country code}' do
|
971
|
-
let(:location) { {country: country_code} }
|
972
|
-
it { expect(views_per_playlist_start.keys).to eq [country_code] }
|
973
|
-
end
|
974
|
-
end
|
975
|
-
end
|
976
|
-
|
977
617
|
describe 'views per playlists start can be retrieved for a single US state' do
|
978
618
|
let(:state_code) { 'CA' }
|
979
619
|
let(:result) { playlist.views_per_playlist_start since: date, by: by, in: location }
|
980
|
-
let(:date) {
|
620
|
+
let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
|
981
621
|
|
982
622
|
context 'and grouped by day' do
|
983
623
|
let(:by) { :day }
|
@@ -1008,45 +648,10 @@ describe Yt::Playlist, :partner do
|
|
1008
648
|
end
|
1009
649
|
end
|
1010
650
|
|
1011
|
-
describe 'views per playlist start can be retrieved for a range of days' do
|
1012
|
-
let(:date) { 4.days.ago }
|
1013
|
-
|
1014
|
-
specify 'with a given start (:since option)' do
|
1015
|
-
expect(playlist.views_per_playlist_start(since: date).keys.min).to eq date.to_date
|
1016
|
-
end
|
1017
|
-
|
1018
|
-
specify 'with a given end (:until option)' do
|
1019
|
-
expect(playlist.views_per_playlist_start(until: date).keys.max).to eq date.to_date
|
1020
|
-
end
|
1021
|
-
|
1022
|
-
specify 'with a given start (:from option)' do
|
1023
|
-
expect(playlist.views_per_playlist_start(from: date).keys.min).to eq date.to_date
|
1024
|
-
end
|
1025
|
-
|
1026
|
-
specify 'with a given end (:to option)' do
|
1027
|
-
expect(playlist.views_per_playlist_start(to: date).keys.max).to eq date.to_date
|
1028
|
-
end
|
1029
|
-
end
|
1030
|
-
|
1031
|
-
describe 'views per playlist start can be grouped by range' do
|
1032
|
-
let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
|
1033
|
-
|
1034
|
-
specify 'with the :by option set to :range' do
|
1035
|
-
views = playlist.views_per_playlist_start range.merge by: :range
|
1036
|
-
expect(views.size).to be 1
|
1037
|
-
expect(views[:total]).to be_a Float
|
1038
|
-
end
|
1039
|
-
end
|
1040
|
-
|
1041
651
|
describe 'views per playlist start can be grouped by day' do
|
1042
652
|
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
1043
653
|
let(:keys) { range.values }
|
1044
654
|
|
1045
|
-
specify 'without a :by option (default)' do
|
1046
|
-
views_per_playlist_start = playlist.views_per_playlist_start range
|
1047
|
-
expect(views_per_playlist_start.keys).to eq range.values
|
1048
|
-
end
|
1049
|
-
|
1050
655
|
specify 'with the :by option set to :day' do
|
1051
656
|
views_per_playlist_start = playlist.views_per_playlist_start range.merge by: :day
|
1052
657
|
expect(views_per_playlist_start.keys).to eq range.values
|