File tree Expand file tree Collapse file tree 7 files changed +39
-5
lines changed
Expand file tree Collapse file tree 7 files changed +39
-5
lines changed Original file line number Diff line number Diff line change @@ -210,7 +210,6 @@ def reports_params
210210 params [ :filters ] = ( ( params [ :filters ] || '' ) . split ( ';' ) + [ "country==US" ] ) . compact . uniq . join ( ';' ) if @dimension == :state && !@state
211211 params [ :filters ] = ( ( params [ :filters ] || '' ) . split ( ';' ) + [ "country==#{ @country } " ] ) . compact . uniq . join ( ';' ) if @country && !@state
212212 params [ :filters ] = ( ( params [ :filters ] || '' ) . split ( ';' ) + [ "province==US-#{ @state } " ] ) . compact . uniq . join ( ';' ) if @state
213- params [ :filters ] = ( ( params [ :filters ] || '' ) . split ( ';' ) + [ 'isCurated==1' ] ) . compact . uniq . join ( ';' ) if @dimension == :playlist
214213 params [ :filters ] = ( ( params [ :filters ] || '' ) . split ( ';' ) + [ 'insightPlaybackLocationType==EMBEDDED' ] ) . compact . uniq . join ( ';' ) if @dimension == :embedded_player_location
215214 params [ :filters ] = ( ( params [ :filters ] || '' ) . split ( ';' ) + [ 'insightTrafficSourceType==RELATED_VIDEO' ] ) . compact . uniq . join ( ';' ) if @dimension == :related_video
216215 params [ :filters ] = ( ( params [ :filters ] || '' ) . split ( ';' ) + [ 'insightTrafficSourceType==YT_SEARCH' ] ) . compact . uniq . join ( ';' ) if @dimension == :search_term
Original file line number Diff line number Diff line change @@ -160,6 +160,9 @@ def delete_playlist_items(attributes = {})
160160 # @macro report_by_playlist_dimensions
161161 has_report :views , Integer
162162
163+ # @macro report_by_playlist_dimensions
164+ has_report :engaged_views , Integer
165+
163166 # @macro report_by_playlist_dimensions
164167 has_report :estimated_minutes_watched , Integer
165168
@@ -202,7 +205,7 @@ def reports_params
202205 else
203206 params [ :ids ] = "channel==#{ channel_id } "
204207 end
205- params [ :filters ] = "playlist==#{ id } ;isCurated==1 "
208+ params [ :filters ] = "playlist==#{ id } "
206209 end
207210 end
208211
Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ class VideoGroup < Base
3737 # @macro report_by_video_dimensions
3838 has_report :views , Integer
3939
40+ # @macro report_by_video_dimensions
41+ has_report :engaged_views , Integer
42+
4043 # @macro report_by_video_dimensions
4144 has_report :estimated_minutes_watched , Integer
4245
Original file line number Diff line number Diff line change 178178 let ( :id ) { test_account . channel . playlists . first . id }
179179
180180 before do
181- allow ( Date ) . to receive ( :today ) . and_return ( Date . new ( 2020 , 2 , 5 ) )
181+ allow ( Date ) . to receive ( :today ) . and_return ( Date . new ( 2025 , 5 , 20 ) )
182182 end
183183
184184 it 'returns valid reports for playlist-related metrics' do
185185 expect { playlist . views } . not_to raise_error
186+ expect { playlist . engaged_views } . not_to raise_error
186187 expect { playlist . playlist_starts } . not_to raise_error
187188 expect { playlist . average_time_in_playlist } . not_to raise_error
188189 expect { playlist . views_per_playlist_start } . not_to raise_error
Original file line number Diff line number Diff line change 22require 'yt/models/content_owner'
33require 'yt/models/match_policy'
44
5- describe Yt ::ContentOwner , :partner do
5+ describe Yt ::ContentOwner , :partner , :vcr do
66 describe '.partnered_channels' do
77 let ( :partnered_channels ) { $content_owner. partnered_channels }
88
6666 end
6767
6868 describe '.video_groups' do
69- let ( :video_group ) { $content_owner . video_groups . first }
69+ let ( :video_group ) { test_content_owner . video_groups . first }
7070
7171 specify 'returns the first video-group created by the account' do
7272 expect ( video_group ) . to be_a Yt ::VideoGroup
7777
7878 specify 'allows to run reports against each video-group' do
7979 expect ( video_group . views ) . to be
80+ expect ( video_group . engaged_views ) . to be
8081 end
8182 end
8283
Original file line number Diff line number Diff line change @@ -5,6 +5,15 @@ module Helpers
55 def test_account
66 @test_account ||= Yt ::Account . new ( refresh_token : ENV [ 'YT_TEST_REFRESH_TOKEN' ] )
77 end
8+
9+ # Create one Youtube Partner channel, authenticated as the content owner
10+ def test_content_owner
11+ @test_content_owner ||= begin
12+ attrs = { refresh_token : ENV [ 'YT_TEST_CONTENT_OWNER_REFRESH_TOKEN' ] }
13+ attrs [ :owner_name ] = ENV [ 'YT_TEST_CONTENT_OWNER_NAME' ]
14+ Yt ::ContentOwner . new attrs
15+ end
16+ end
817end
918
1019RSpec . configure do |config |
@@ -23,4 +32,9 @@ def test_account
2332 config . before :each , server_app : true do
2433 allow ( Yt . configuration ) . to receive ( :api_key ) . and_return ( ENV [ 'YT_TEST_API_KEY' ] )
2534 end
35+
36+ config . before :each , partner : true do
37+ allow ( Yt . configuration ) . to receive ( :client_id ) . and_return ( ENV [ 'YT_TEST_PARTNER_CLIENT_ID' ] )
38+ allow ( Yt . configuration ) . to receive ( :client_secret ) . and_return ( ENV [ 'YT_TEST_PARTNER_CLIENT_SECRET' ] )
39+ end
2640end
Original file line number Diff line number Diff line change 3232 c . filter_sensitive_data ( "<YT_AUTH_HEADER>" ) do |interaction |
3333 interaction . request . headers [ 'Authorization' ] . first rescue nil
3434 end
35+
36+ c . filter_sensitive_data ( "<YT_TEST_CONTENT_OWNER_NAME>" ) { ENV [ 'YT_TEST_CONTENT_OWNER_NAME' ] }
37+ c . filter_sensitive_data ( "<YT_TEST_PARTNER_CLIENT_ID>" ) { ENV [ 'YT_TEST_PARTNER_CLIENT_ID' ] }
38+ c . filter_sensitive_data ( "<YT_TEST_PARTNER_CLIENT_SECRET>" ) { ENV [ 'YT_TEST_PARTNER_CLIENT_SECRET' ] }
39+ c . filter_sensitive_data ( "<YT_TEST_CONTENT_OWNER_REFRESH_TOKEN>" ) { CGI . escape ( ENV [ 'YT_TEST_CONTENT_OWNER_REFRESH_TOKEN' ] ) }
40+ c . filter_sensitive_data ( "<YT_TEST_CONTENT_OWNER_ACCESS_TOKEN>" ) do |interaction |
41+ begin
42+ body = JSON . parse ( interaction . response . body )
43+ body [ 'access_token' ]
44+ rescue
45+ # noop
46+ end
47+ end
3548end
You can’t perform that action at this time.
0 commit comments