67 lines
1.9 KiB
Perl
67 lines
1.9 KiB
Perl
use strict;
|
|
use warnings;
|
|
|
|
use Test::More tests => 2;
|
|
use Test::Exception;
|
|
|
|
sub test_get_playlist_foreign {
|
|
my ( $yt, $yt_auth, $yt_oauth ) = @_;
|
|
|
|
lives_ok {
|
|
eval { $yt->get_playlist("PLABC") };
|
|
if ($@) {
|
|
die "Expected exception not thrown";
|
|
}
|
|
}
|
|
'Playlist retrieval with invalid ID should fail';
|
|
|
|
my $playlist = $yt_auth->get_playlist(
|
|
"PLk5BdzXBUiUe8Q5I13ZSCD8HbxMqJUUQA",
|
|
{ limit => 300, suggestions_limit => 7 }
|
|
);
|
|
ok(
|
|
length( $playlist->{"duration"} ) > 5,
|
|
"Playlist duration length check"
|
|
);
|
|
ok( scalar @{ $playlist->{"tracks"} } > 200, "Tracks count check" );
|
|
ok(
|
|
!exists $playlist->{"suggestions"},
|
|
"Playlist should not contain suggestions"
|
|
);
|
|
ok( !$playlist->{"owned"}, "Playlist should not be owned" );
|
|
|
|
$yt->get_playlist("RDATgXd-");
|
|
ok(
|
|
scalar @{ $playlist->{"tracks"} } >= 100,
|
|
"Tracks count check for RDATgXd- playlist"
|
|
);
|
|
|
|
$playlist = $yt_oauth->get_playlist(
|
|
"PLj4BSJLnVpNyIjbCWXWNAmybc97FXLlTk",
|
|
{ limit => undef, related => 1 }
|
|
);
|
|
ok(
|
|
scalar @{ $playlist->{"tracks"} } > 200,
|
|
"Tracks count check for oauth playlist"
|
|
);
|
|
ok(
|
|
scalar @{ $playlist->{"related"} } == 0,
|
|
"Related count check for oauth playlist"
|
|
);
|
|
}
|
|
|
|
sub test_get_playlist_owned {
|
|
my ( $config, $yt_brand ) = @_;
|
|
|
|
my $playlist = $yt_brand->get_playlist( $config->{"playlists"}->{"own"},
|
|
{ related => 1, suggestions_limit => 21 } );
|
|
ok(
|
|
scalar @{ $playlist->{"tracks"} } < 100,
|
|
"Owned playlist tracks count check"
|
|
);
|
|
ok( scalar @{ $playlist->{"suggestions"} } == 21,
|
|
"Suggestions count check" );
|
|
ok( scalar @{ $playlist->{"related"} } == 10, "Related count check" );
|
|
ok( $playlist->{"owned"}, "Playlist ownership check" );
|
|
}
|