yt 0.22.1 → 0.22.2

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.
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.22.1'
2
+ VERSION = '0.22.2'
3
3
  end
@@ -9,7 +9,7 @@ describe Yt::Collections::Reports do
9
9
  let(:msg) { {response_body: {error: {errors: [error]}}}.to_json }
10
10
 
11
11
  describe '#within' do
12
- let(:result) { reports.within Range.new(5.days.ago, 4.days.ago), :day, Float }
12
+ let(:result) { reports.within Range.new(5.days.ago, 4.days.ago), nil, nil, :day, Float }
13
13
  context 'given the request raises error 400 with "Invalid Query" message' do
14
14
  let(:reason) { 'badRequest' }
15
15
  let(:message) { 'Invalid query. Query did not conform to the expectations' }
@@ -170,24 +170,55 @@ describe Yt::Channel, :partner do
170
170
  it { expect(views.keys).to eq [country_code] }
171
171
  end
172
172
  end
173
+
174
+ context 'and grouped by state' do
175
+ let(:by) { :state }
176
+
177
+ context 'with the :in option set to the country code' do
178
+ let(:location) { country_code }
179
+ it { expect(views.keys.map(&:length).uniq).to eq [2] }
180
+ end
181
+
182
+ context 'with the :in option set to {country: country code}' do
183
+ let(:location) { {country: country_code} }
184
+ it { expect(views.keys.map(&:length).uniq).to eq [2] }
185
+ end
186
+ end
173
187
  end
174
188
 
175
- # describe 'views can be retrieved for a single US state' do
176
- # let(:state_code) { 'TX' }
177
- #
178
- # specify 'with the :in option set to {state: state_code}' do
179
- # require 'pry'; binding.pry; true;
180
- # views = channel.views in: {state: state_code}
181
- #
182
- # expect(views.keys).to eq [state_code]
183
- # end
184
- #
185
- # specify 'with the :in option set to {country: "US", state: state_code}' do
186
- # views = channel.views by: :state, in: {country: "US", state: state_code}
187
- # p views
188
- # expect(views.keys).to eq [state_code]
189
- # end
190
- # end
189
+ describe 'views can be retrieved for a single US state' do
190
+ let(:state_code) { 'NY' }
191
+ let(:result) { channel.views since: date, by: by, in: location }
192
+ let(:date) { 4.days.ago }
193
+
194
+ context 'and grouped by day' do
195
+ let(:by) { :day }
196
+
197
+ context 'with the :in option set to {state: state code}' do
198
+ let(:location) { {state: state_code} }
199
+ it { expect(result.keys.min).to eq date.to_date }
200
+ end
201
+
202
+ context 'with the :in option set to {country: "US", state: state code}' do
203
+ let(:location) { {country: 'US', state: state_code} }
204
+ it { expect(result.keys.min).to eq date.to_date }
205
+ end
206
+ end
207
+
208
+ context 'and grouped by US state' do
209
+ let(:by) { :state }
210
+
211
+ context 'with the :in option set to {state: state code}' do
212
+ let(:location) { {state: state_code} }
213
+ it { expect(result.keys).to eq [state_code] }
214
+ end
215
+
216
+ context 'with the :in option set to {country: "US", state: state code}' do
217
+ let(:location) { {country: 'US', state: state_code} }
218
+ it { expect(result.keys).to eq [state_code] }
219
+ end
220
+ end
221
+ end
191
222
 
192
223
  describe 'views can be retrieved for a range of days' do
193
224
  let(:date) { 4.days.ago }
@@ -272,6 +303,15 @@ describe Yt::Channel, :partner do
272
303
  end
273
304
  end
274
305
 
306
+ describe 'views can be grouped by search term' do
307
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
308
+
309
+ specify 'with the :by option set to :search_term' do
310
+ views = channel.views range.merge by: :search_term
311
+ expect(views.keys).to all(be_a String)
312
+ end
313
+ end
314
+
275
315
  describe 'views can be grouped by video' do
276
316
  let(:range) { {since: 4.days.ago, until: 3.days.ago} }
277
317
 
@@ -322,6 +362,81 @@ describe Yt::Channel, :partner do
322
362
  end
323
363
  end
324
364
 
365
+ describe 'uniques can be retrieved for a single country' do
366
+ let(:country_code) { 'US' }
367
+ let(:uniques) { channel.uniques since: date, by: by, in: location }
368
+ let(:date) { 4.days.ago }
369
+
370
+ context 'and grouped by day' do
371
+ let(:by) { :day }
372
+
373
+ context 'with the :in option set to the country code' do
374
+ let(:location) { country_code }
375
+ it { expect(uniques.keys.min).to eq date.to_date }
376
+ end
377
+
378
+ context 'with the :in option set to {country: country code}' do
379
+ let(:location) { {country: country_code} }
380
+ it { expect(uniques.keys.min).to eq date.to_date }
381
+ end
382
+ end
383
+ end
384
+
385
+ describe 'uniques can be retrieved for a single US state' do
386
+ let(:state_code) { 'NY' }
387
+ let(:result) { channel.uniques since: date, by: by, in: location }
388
+ let(:date) { 4.days.ago }
389
+
390
+ context 'and grouped by day' do
391
+ let(:by) { :day }
392
+
393
+ context 'with the :in option set to {state: state code}' do
394
+ let(:location) { {state: state_code} }
395
+ it { expect(result.keys.min).to eq date.to_date }
396
+ end
397
+
398
+ context 'with the :in option set to {country: "US", state: state code}' do
399
+ let(:location) { {country: 'US', state: state_code} }
400
+ it { expect(result.keys.min).to eq date.to_date }
401
+ end
402
+ end
403
+ end
404
+
405
+ describe 'uniques can be retrieved for a range of days' do
406
+ let(:date) { 4.days.ago }
407
+
408
+ specify 'with a given start (:since option)' do
409
+ expect(channel.uniques(since: date).keys.min).to eq date.to_date
410
+ end
411
+
412
+ specify 'with a given end (:until option)' do
413
+ expect(channel.uniques(until: date).keys.max).to eq date.to_date
414
+ end
415
+
416
+ specify 'with a given start (:from option)' do
417
+ expect(channel.uniques(from: date).keys.min).to eq date.to_date
418
+ end
419
+
420
+ specify 'with a given end (:to option)' do
421
+ expect(channel.uniques(to: date).keys.max).to eq date.to_date
422
+ end
423
+ end
424
+
425
+ describe 'uniques can be grouped by day' do
426
+ let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
427
+ let(:keys) { range.values }
428
+
429
+ specify 'without a :by option (default)' do
430
+ uniques = channel.uniques range
431
+ expect(uniques.keys).to eq range.values
432
+ end
433
+
434
+ specify 'with the :by option set to :day' do
435
+ uniques = channel.uniques range.merge by: :day
436
+ expect(uniques.keys).to eq range.values
437
+ end
438
+ end
439
+
325
440
  describe 'comments can be retrieved for a specific day' do
326
441
  context 'in which the channel was partnered' do
327
442
  let(:comments) { channel.comments_on 5.days.ago}
@@ -1185,6 +1300,40 @@ describe Yt::Channel, :partner do
1185
1300
  end
1186
1301
  end
1187
1302
 
1303
+ describe 'estimated minutes watched can be retrieved for a single US state' do
1304
+ let(:state_code) { 'NY' }
1305
+ let(:result) { channel.estimated_minutes_watched since: date, by: by, in: location }
1306
+ let(:date) { 4.days.ago }
1307
+
1308
+ context 'and grouped by day' do
1309
+ let(:by) { :day }
1310
+
1311
+ context 'with the :in option set to {state: state code}' do
1312
+ let(:location) { {state: state_code} }
1313
+ it { expect(result.keys.min).to eq date.to_date }
1314
+ end
1315
+
1316
+ context 'with the :in option set to {country: "US", state: state code}' do
1317
+ let(:location) { {country: 'US', state: state_code} }
1318
+ it { expect(result.keys.min).to eq date.to_date }
1319
+ end
1320
+ end
1321
+
1322
+ context 'and grouped by US state' do
1323
+ let(:by) { :state }
1324
+
1325
+ context 'with the :in option set to {state: state code}' do
1326
+ let(:location) { {state: state_code} }
1327
+ it { expect(result.keys).to eq [state_code] }
1328
+ end
1329
+
1330
+ context 'with the :in option set to {country: "US", state: state code}' do
1331
+ let(:location) { {country: 'US', state: state_code} }
1332
+ it { expect(result.keys).to eq [state_code] }
1333
+ end
1334
+ end
1335
+ end
1336
+
1188
1337
  describe 'estimated minutes watched can be retrieved for a range of days' do
1189
1338
  let(:date) { 4.days.ago }
1190
1339
 
@@ -1268,6 +1417,15 @@ describe Yt::Channel, :partner do
1268
1417
  end
1269
1418
  end
1270
1419
 
1420
+ describe 'estimated minutes watched can be grouped by search term' do
1421
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
1422
+
1423
+ specify 'with the :by option set to :search_term' do
1424
+ estimated_minutes_watched = channel.estimated_minutes_watched range.merge by: :search_term
1425
+ expect(estimated_minutes_watched.keys).to all(be_a String)
1426
+ end
1427
+ end
1428
+
1271
1429
  describe 'estimated minutes watched can be grouped by video' do
1272
1430
  let(:range) { {since: 4.days.ago, until: 3.days.ago} }
1273
1431
 
@@ -1364,6 +1522,40 @@ describe Yt::Channel, :partner do
1364
1522
  end
1365
1523
  end
1366
1524
 
1525
+ describe 'average view duration can be retrieved for a single US state' do
1526
+ let(:state_code) { 'NY' }
1527
+ let(:result) { channel.average_view_duration since: date, by: by, in: location }
1528
+ let(:date) { 4.days.ago }
1529
+
1530
+ context 'and grouped by day' do
1531
+ let(:by) { :day }
1532
+
1533
+ context 'with the :in option set to {state: state code}' do
1534
+ let(:location) { {state: state_code} }
1535
+ it { expect(result.keys.min).to eq date.to_date }
1536
+ end
1537
+
1538
+ context 'with the :in option set to {country: "US", state: state code}' do
1539
+ let(:location) { {country: 'US', state: state_code} }
1540
+ it { expect(result.keys.min).to eq date.to_date }
1541
+ end
1542
+ end
1543
+
1544
+ context 'and grouped by US state' do
1545
+ let(:by) { :state }
1546
+
1547
+ context 'with the :in option set to {state: state code}' do
1548
+ let(:location) { {state: state_code} }
1549
+ it { expect(result.keys).to eq [state_code] }
1550
+ end
1551
+
1552
+ context 'with the :in option set to {country: "US", state: state code}' do
1553
+ let(:location) { {country: 'US', state: state_code} }
1554
+ it { expect(result.keys).to eq [state_code] }
1555
+ end
1556
+ end
1557
+ end
1558
+
1367
1559
  describe 'average view duration can be retrieved for a range of days' do
1368
1560
  let(:date) { 4.days.ago }
1369
1561
 
@@ -1477,6 +1669,40 @@ describe Yt::Channel, :partner do
1477
1669
  end
1478
1670
  end
1479
1671
 
1672
+ describe 'average view percentage can be retrieved for a single US state' do
1673
+ let(:state_code) { 'NY' }
1674
+ let(:result) { channel.average_view_percentage since: date, by: by, in: location }
1675
+ let(:date) { 4.days.ago }
1676
+
1677
+ context 'and grouped by day' do
1678
+ let(:by) { :day }
1679
+
1680
+ context 'with the :in option set to {state: state code}' do
1681
+ let(:location) { {state: state_code} }
1682
+ it { expect(result.keys.min).to eq date.to_date }
1683
+ end
1684
+
1685
+ context 'with the :in option set to {country: "US", state: state code}' do
1686
+ let(:location) { {country: 'US', state: state_code} }
1687
+ it { expect(result.keys.min).to eq date.to_date }
1688
+ end
1689
+ end
1690
+
1691
+ context 'and grouped by US state' do
1692
+ let(:by) { :state }
1693
+
1694
+ context 'with the :in option set to {state: state code}' do
1695
+ let(:location) { {state: state_code} }
1696
+ it { expect(result.keys).to eq [state_code] }
1697
+ end
1698
+
1699
+ context 'with the :in option set to {country: "US", state: state code}' do
1700
+ let(:location) { {country: 'US', state: state_code} }
1701
+ it { expect(result.keys).to eq [state_code] }
1702
+ end
1703
+ end
1704
+ end
1705
+
1480
1706
  describe 'average view percentage can be retrieved for a range of days' do
1481
1707
  let(:date) { 4.days.ago }
1482
1708
 
@@ -1559,7 +1785,7 @@ describe Yt::Channel, :partner do
1559
1785
  describe 'impressions can be retrieved for a single country' do
1560
1786
  let(:country_code) { 'US' }
1561
1787
  let(:impressions) { channel.impressions since: date, by: by, in: location }
1562
- let(:date) { 4.days.ago }
1788
+ let(:date) { ENV['YT_TEST_PARTNER_PLAYLIST_DATE'] }
1563
1789
 
1564
1790
  context 'and grouped by day' do
1565
1791
  let(:by) { :day }
@@ -1636,7 +1862,7 @@ describe Yt::Channel, :partner do
1636
1862
  end
1637
1863
 
1638
1864
  describe 'impressions can be grouped by country' do
1639
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
1865
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
1640
1866
 
1641
1867
  specify 'with the :by option set to :country' do
1642
1868
  impressions = channel.impressions range.merge by: :country
@@ -1661,7 +1887,7 @@ describe Yt::Channel, :partner do
1661
1887
  describe 'monetized playbacks can be retrieved for a single country' do
1662
1888
  let(:country_code) { 'US' }
1663
1889
  let(:monetized_playbacks) { channel.monetized_playbacks since: date, by: by, in: location }
1664
- let(:date) { 4.days.ago }
1890
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1665
1891
 
1666
1892
  context 'and grouped by day' do
1667
1893
  let(:by) { :day }
@@ -1738,7 +1964,7 @@ describe Yt::Channel, :partner do
1738
1964
  end
1739
1965
 
1740
1966
  describe 'monetized playbacks can be grouped by country' do
1741
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
1967
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
1742
1968
 
1743
1969
  specify 'with the :by option set to :country' do
1744
1970
  playbacks = channel.monetized_playbacks range.merge by: :country
@@ -1782,6 +2008,40 @@ describe Yt::Channel, :partner do
1782
2008
  end
1783
2009
  end
1784
2010
 
2011
+ describe 'annotation clicks can be retrieved for a single US state' do
2012
+ let(:state_code) { 'NY' }
2013
+ let(:result) { channel.annotation_clicks since: date, by: by, in: location }
2014
+ let(:date) { 4.days.ago }
2015
+
2016
+ context 'and grouped by day' do
2017
+ let(:by) { :day }
2018
+
2019
+ context 'with the :in option set to {state: state code}' do
2020
+ let(:location) { {state: state_code} }
2021
+ it { expect(result.keys.min).to eq date.to_date }
2022
+ end
2023
+
2024
+ context 'with the :in option set to {country: "US", state: state code}' do
2025
+ let(:location) { {country: 'US', state: state_code} }
2026
+ it { expect(result.keys.min).to eq date.to_date }
2027
+ end
2028
+ end
2029
+
2030
+ context 'and grouped by US state' do
2031
+ let(:by) { :state }
2032
+
2033
+ context 'with the :in option set to {state: state code}' do
2034
+ let(:location) { {state: state_code} }
2035
+ it { expect(result.keys).to eq [state_code] }
2036
+ end
2037
+
2038
+ context 'with the :in option set to {country: "US", state: state code}' do
2039
+ let(:location) { {country: 'US', state: state_code} }
2040
+ it { expect(result.keys).to eq [state_code] }
2041
+ end
2042
+ end
2043
+ end
2044
+
1785
2045
  describe 'annotation clicks can be retrieved for a range of days' do
1786
2046
  let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1787
2047
  let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
@@ -1875,6 +2135,40 @@ describe Yt::Channel, :partner do
1875
2135
  end
1876
2136
  end
1877
2137
 
2138
+ describe 'annotation click-through rate can be retrieved for a single US state' do
2139
+ let(:state_code) { 'NY' }
2140
+ let(:result) { channel.annotation_click_through_rate since: date, by: by, in: location }
2141
+ let(:date) { 4.days.ago }
2142
+
2143
+ context 'and grouped by day' do
2144
+ let(:by) { :day }
2145
+
2146
+ context 'with the :in option set to {state: state code}' do
2147
+ let(:location) { {state: state_code} }
2148
+ it { expect(result.keys.min).to eq date.to_date }
2149
+ end
2150
+
2151
+ context 'with the :in option set to {country: "US", state: state code}' do
2152
+ let(:location) { {country: 'US', state: state_code} }
2153
+ it { expect(result.keys.min).to eq date.to_date }
2154
+ end
2155
+ end
2156
+
2157
+ context 'and grouped by US state' do
2158
+ let(:by) { :state }
2159
+
2160
+ context 'with the :in option set to {state: state code}' do
2161
+ let(:location) { {state: state_code} }
2162
+ it { expect(result.keys).to eq [state_code] }
2163
+ end
2164
+
2165
+ context 'with the :in option set to {country: "US", state: state code}' do
2166
+ let(:location) { {country: 'US', state: state_code} }
2167
+ it { expect(result.keys).to eq [state_code] }
2168
+ end
2169
+ end
2170
+ end
2171
+
1878
2172
  describe 'annotation click-through rate can be retrieved for a range of days' do
1879
2173
  let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1880
2174
  let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
@@ -1968,6 +2262,40 @@ describe Yt::Channel, :partner do
1968
2262
  end
1969
2263
  end
1970
2264
 
2265
+ describe 'annotation close rate can be retrieved for a single US state' do
2266
+ let(:state_code) { 'NY' }
2267
+ let(:result) { channel.annotation_close_rate since: date, by: by, in: location }
2268
+ let(:date) { 4.days.ago }
2269
+
2270
+ context 'and grouped by day' do
2271
+ let(:by) { :day }
2272
+
2273
+ context 'with the :in option set to {state: state code}' do
2274
+ let(:location) { {state: state_code} }
2275
+ it { expect(result.keys.min).to eq date.to_date }
2276
+ end
2277
+
2278
+ context 'with the :in option set to {country: "US", state: state code}' do
2279
+ let(:location) { {country: 'US', state: state_code} }
2280
+ it { expect(result.keys.min).to eq date.to_date }
2281
+ end
2282
+ end
2283
+
2284
+ context 'and grouped by US state' do
2285
+ let(:by) { :state }
2286
+
2287
+ context 'with the :in option set to {state: state code}' do
2288
+ let(:location) { {state: state_code} }
2289
+ it { expect(result.keys).to eq [state_code] }
2290
+ end
2291
+
2292
+ context 'with the :in option set to {country: "US", state: state code}' do
2293
+ let(:location) { {country: 'US', state: state_code} }
2294
+ it { expect(result.keys).to eq [state_code] }
2295
+ end
2296
+ end
2297
+ end
2298
+
1971
2299
  describe 'annotation close rate can be retrieved for a range of days' do
1972
2300
  let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1973
2301
  let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
@@ -2042,6 +2370,22 @@ describe Yt::Channel, :partner do
2042
2370
  end
2043
2371
  end
2044
2372
 
2373
+ describe 'viewer percentage can be retrieved for a single US state' do
2374
+ let(:state_code) { 'TX' }
2375
+ let(:viewer_percentage) { channel.viewer_percentage since: date, in: location }
2376
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2377
+
2378
+ context 'with the :in option set to {state: state code}' do
2379
+ let(:location) { {state: state_code} }
2380
+ it {expect(viewer_percentage.keys).to match_array [:female, :male] }
2381
+ end
2382
+
2383
+ context 'with the :in option set to {country: "US", state: state code}' do
2384
+ let(:location) { {country: 'US', state: state_code} }
2385
+ it { expect(viewer_percentage.keys).to match_array [:female, :male] }
2386
+ end
2387
+ end
2388
+
2045
2389
  describe 'viewer percentage can be retrieved for a range of days' do
2046
2390
  let(:viewer_percentage) { channel.viewer_percentage since: 1.year.ago, until: 10.days.ago}
2047
2391
  it { expect(viewer_percentage).to be_a Hash }