Permalink
Browse files

tests for all_genres, artists_by_genre (sebastien nobili)

  • Loading branch information...
jquelin committed Nov 24, 2011
1 parent 8d412c6 commit 1ecc02bc8a5ccace030f674bafde4f6debb2a59b
Showing with 30 additions and 14 deletions.
  1. +1 −0 Changes
  2. +1 −1 dist.ini
  3. +2 −2 t/24-info.t
  4. +26 −11 t/30-collection.t
View
@@ -4,6 +4,7 @@ Changelog for Audio-MPD
- fix rt#68357 - ipv6 support
- fix rt#71201 - url handlers can vary with mpd installation
- fix rt#71202 - requiring software mixer for tests
+ - tests for all_genres, artists_by_genre (sebastien nobili)
1.112670 2011-09-24 11:40:44 Europe/Paris
- collection: new method all_genres (sebastien nobili)
View
@@ -11,7 +11,7 @@ repository = http://github.com/jquelin/audio-mpd
x_mailing_list = http://groups.google.com/group/audio-mpd
[Prereqs / TestRequires]
-Test::Corpus::Audio::MPD = 1.113281 ; ipv6
+Test::Corpus::Audio::MPD = 1.113282 ; software mixer, ipv6, genre tag
[@Filter]
-bundle = @JQUELIN
View
@@ -24,9 +24,9 @@ my $stats = $mpd->stats;
isa_ok( $stats, 'Audio::MPD::Common::Stats', 'stats() returns an AMC::Stats object' );
is( $stats->artists, 1, 'one artist in the database' );
is( $stats->albums, 1, 'one album in the database' );
-is( $stats->songs, 4, '4 songs in the database' );
+is( $stats->songs, 5, '5 songs in the database' );
is( $stats->playtime, 0, 'already played 0 seconds' );
-is( $stats->db_playtime, 8, '8 seconds worth of music in the db' );
+is( $stats->db_playtime, 10, '10 seconds worth of music in the db' );
isnt( $stats->uptime, undef, 'uptime is defined' );
isnt( $stats->db_update, 0, 'database has been updated' );
View
@@ -10,7 +10,7 @@ use Test::More;
eval 'use Test::Corpus::Audio::MPD';
plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s;
-plan tests => 76;
+plan tests => 90;
my $mpd = Audio::MPD->new;
my @list;
@@ -25,7 +25,7 @@ isa_ok( $coll, 'Audio::MPD::Collection',
#
# testing all_items.
@list = $coll->all_items;
-is( scalar @list, 6, 'all_items return all 6 items' );
+is( scalar @list, 7, 'all_items return all 7 items' );
isa_ok( $_, 'Audio::MPD::Common::Item', 'all_items return AMCI objects' )
for @list;
@list = $coll->all_items( 'dir1' );
@@ -37,7 +37,7 @@ is( $list[1]->artist, 'dir1-artist', 'all_items can be restricted to a subdir' )
#
# testing all_items_simple.
@list = $coll->all_items_simple;
-is( scalar @list, 6, 'all_items_simple return all 6 items' );
+is( scalar @list, 7, 'all_items_simple return all 7 items' );
isa_ok( $_, 'Audio::MPD::Common::Item', 'all_items_simple return AMCI objects' )
for @list;
@list = $coll->all_items_simple( 'dir1' );
@@ -49,7 +49,7 @@ is( $list[1]->artist, undef, 'all_items_simple does not return full tags' );
#
# testing items_in_dir.
@list = $coll->items_in_dir;
-is( scalar @list, 4, 'items_in_dir defaults to root' );
+is( scalar @list, 5, 'items_in_dir defaults to root' );
isa_ok( $_, 'Audio::MPD::Common::Item', 'items_in_dir return AMCI objects' ) for @list;
@list = $coll->items_in_dir( 'dir1' );
is( scalar @list, 2, 'items_in_dir can take a param' );
@@ -58,7 +58,7 @@ is( scalar @list, 2, 'items_in_dir can take a param' );
#
# testing all_songs.
@list = $coll->all_songs;
-is( scalar @list, 4, 'all_songs return all 4 songs' );
+is( scalar @list, 5, 'all_songs return all 4 songs' );
isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'all_items return AMCIS objects' ) for @list;
@list = $coll->all_songs( 'dir1' );
is( scalar @list, 2, 'all_songs can be restricted to a subdir' );
@@ -92,7 +92,7 @@ like( $list[0], qr/-title$/, 'all_titles return strings' );
#
# testing all_pathes.
@list = $coll->all_pathes;
-is( scalar @list, 4, 'all_pathes return the pathes' );
+is( scalar @list, 5, 'all_pathes return the pathes' );
like( $list[0], qr/\.ogg$/, 'all_pathes return strings' );
@@ -103,6 +103,15 @@ is( scalar @list, 1, 'all_playlists return the playlists' );
is( $list[0], 'test', 'all_playlists return strings' );
+#
+# testing all_genres.
+# note: mpd 0.14 also returns empty genres
+@list = $coll->all_genres;
+@list = grep (!/^$/, @list);
+is( scalar @list, 1, 'all_genres return the genres' );
+is( $list[0], 'foo-genre', 'all_genres return strings' );
+
+
#
# testing song.
my $path = 'dir1/title-artist-album.ogg';
@@ -131,31 +140,31 @@ is( $list[1], 'our album', 'albums_by_artist return plain strings' );
#
# testing songs_by_artist.
@list = $coll->songs_by_artist( 'dir1-artist' );
-is( scalar @list, 2, 'songs_by_artist return all the songs found' );
+is( scalar @list, 3, 'songs_by_artist return all the songs found' );
isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'songs_by_artist return AMCI::Songs' ) for @list;
is( $list[0]->artist, 'dir1-artist', 'songs_by_artist return correct objects' );
#
# testing songs_by_artist_partial.
@list = $coll->songs_by_artist_partial( 'artist' );
-is( scalar @list, 2, 'songs_by_artist_partial return all the songs found' );
+is( scalar @list, 3, 'songs_by_artist_partial return all the songs found' );
isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'songs_by_artist_partial return AMCI::Songs' ) for @list;
like( $list[0]->artist, qr/artist/, 'songs_by_artist_partial return correct objects' );
#
# testing songs_from_album.
@list = $coll->songs_from_album( 'our album' );
-is( scalar @list, 2, 'songs_from_album return all the songs found' );
+is( scalar @list, 3, 'songs_from_album return all the songs found' );
isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'songs_from_album return AMCI::Songs' ) for @list;
is( $list[0]->album, 'our album', 'songs_from_album_partial return correct objects' );
#
# testing songs_from_album_partial.
@list = $coll->songs_from_album_partial( 'album' );
-is( scalar @list, 2, 'songs_from_album_partial return all the songs found' );
+is( scalar @list, 3, 'songs_from_album_partial return all the songs found' );
isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'songs_from_album_partial return AMCI::Songs' ) for @list;
like( $list[0]->album, qr/album/, 'songs_from_album_partial return correct objects' );
@@ -171,7 +180,13 @@ is( $list[0]->title, 'ok-title', 'songs_with_title return correct objects' );
#
# testing songs_with_title_partial.
@list = $coll->songs_with_title_partial( 'title' );
-is( scalar @list, 3, 'songs_with_title_partial return all the songs found' );
+is( scalar @list, 4, 'songs_with_title_partial return all the songs found' );
isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'songs_with_title_partial return AMCI::Songs' ) for @list;
like( $list[0]->title, qr/title/, 'songs_with_title_partial return correct objects' );
+
+#
+# testing artists_by_genre.
+@list = $coll->artists_by_genre( 'foo-genre' );
+is( scalar @list, 1, 'artists_by_genre returns the artist' );
+is( $list[0], 'dir1-artist', 'artists_by_genre return plain strings' );

0 comments on commit 1ecc02b

Please sign in to comment.