Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

tests for all_genres, artists_by_genre (sebastien nobili)

  • Loading branch information...
commit 1ecc02bc8a5ccace030f674bafde4f6debb2a59b 1 parent 8d412c6
Jérôme Quelin authored November 24, 2011
1  Changes
@@ -4,6 +4,7 @@ Changelog for Audio-MPD
4 4
  - fix rt#68357 - ipv6 support
5 5
  - fix rt#71201 - url handlers can vary with mpd installation
6 6
  - fix rt#71202 - requiring software mixer for tests
  7
+ - tests for all_genres, artists_by_genre (sebastien nobili)
7 8
 
8 9
 1.112670  2011-09-24 11:40:44 Europe/Paris
9 10
  - collection: new method all_genres (sebastien nobili)
2  dist.ini
@@ -11,7 +11,7 @@ repository     = http://github.com/jquelin/audio-mpd
11 11
 x_mailing_list = http://groups.google.com/group/audio-mpd
12 12
 
13 13
 [Prereqs / TestRequires]
14  
-Test::Corpus::Audio::MPD = 1.113281    ; ipv6
  14
+Test::Corpus::Audio::MPD = 1.113282    ; software mixer, ipv6, genre tag
15 15
 
16 16
 [@Filter]
17 17
 -bundle = @JQUELIN
4  t/24-info.t
@@ -24,9 +24,9 @@ my $stats = $mpd->stats;
24 24
 isa_ok( $stats, 'Audio::MPD::Common::Stats', 'stats() returns an AMC::Stats object' );
25 25
 is( $stats->artists,      1, 'one artist in the database' );
26 26
 is( $stats->albums,       1, 'one album in the database' );
27  
-is( $stats->songs,        4, '4 songs in the database' );
  27
+is( $stats->songs,        5, '5 songs in the database' );
28 28
 is( $stats->playtime,     0, 'already played 0 seconds' );
29  
-is( $stats->db_playtime,  8, '8 seconds worth of music in the db' );
  29
+is( $stats->db_playtime, 10, '10 seconds worth of music in the db' );
30 30
 isnt( $stats->uptime, undef, 'uptime is defined' );
31 31
 isnt( $stats->db_update,  0, 'database has been updated' );
32 32
 
37  t/30-collection.t
@@ -10,7 +10,7 @@ use Test::More;
10 10
 eval 'use Test::Corpus::Audio::MPD';
11 11
 plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s;
12 12
 
13  
-plan tests => 76;
  13
+plan tests => 90;
14 14
 my $mpd = Audio::MPD->new;
15 15
 my @list;
16 16
 
@@ -25,7 +25,7 @@ isa_ok( $coll, 'Audio::MPD::Collection',
25 25
 #
26 26
 # testing all_items.
27 27
 @list = $coll->all_items;
28  
-is( scalar @list, 6, 'all_items return all 6 items' );
  28
+is( scalar @list, 7, 'all_items return all 7 items' );
29 29
 isa_ok( $_, 'Audio::MPD::Common::Item', 'all_items return AMCI objects' )
30 30
     for @list;
31 31
 @list = $coll->all_items( 'dir1' );
@@ -37,7 +37,7 @@ is( $list[1]->artist, 'dir1-artist', 'all_items can be restricted to a subdir' )
37 37
 #
38 38
 # testing all_items_simple.
39 39
 @list = $coll->all_items_simple;
40  
-is( scalar @list, 6, 'all_items_simple return all 6 items' );
  40
+is( scalar @list, 7, 'all_items_simple return all 7 items' );
41 41
 isa_ok( $_, 'Audio::MPD::Common::Item', 'all_items_simple return AMCI objects' )
42 42
     for @list;
43 43
 @list = $coll->all_items_simple( 'dir1' );
@@ -49,7 +49,7 @@ is( $list[1]->artist, undef, 'all_items_simple does not return full tags' );
49 49
 #
50 50
 # testing items_in_dir.
51 51
 @list = $coll->items_in_dir;
52  
-is( scalar @list, 4, 'items_in_dir defaults to root' );
  52
+is( scalar @list, 5, 'items_in_dir defaults to root' );
53 53
 isa_ok( $_, 'Audio::MPD::Common::Item', 'items_in_dir return AMCI objects' ) for @list;
54 54
 @list = $coll->items_in_dir( 'dir1' );
55 55
 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' );
58 58
 #
59 59
 # testing all_songs.
60 60
 @list = $coll->all_songs;
61  
-is( scalar @list, 4, 'all_songs return all 4 songs' );
  61
+is( scalar @list, 5, 'all_songs return all 4 songs' );
62 62
 isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'all_items return AMCIS objects' ) for @list;
63 63
 @list = $coll->all_songs( 'dir1' );
64 64
 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' );
92 92
 #
93 93
 # testing all_pathes.
94 94
 @list = $coll->all_pathes;
95  
-is( scalar @list, 4, 'all_pathes return the pathes' );
  95
+is( scalar @list, 5, 'all_pathes return the pathes' );
96 96
 like( $list[0], qr/\.ogg$/, 'all_pathes return strings' );
97 97
 
98 98
 
@@ -104,6 +104,15 @@ is( $list[0], 'test', 'all_playlists return strings' );
104 104
 
105 105
 
106 106
 #
  107
+# testing all_genres.
  108
+# note: mpd 0.14 also returns empty genres
  109
+@list = $coll->all_genres;
  110
+@list = grep (!/^$/, @list);
  111
+is( scalar @list, 1, 'all_genres return the genres' );
  112
+is( $list[0], 'foo-genre', 'all_genres return strings' );
  113
+
  114
+
  115
+#
107 116
 # testing song.
108 117
 my $path = 'dir1/title-artist-album.ogg';
109 118
 my $song = $coll->song($path);
@@ -131,7 +140,7 @@ is( $list[1], 'our album', 'albums_by_artist return plain strings' );
131 140
 #
132 141
 # testing songs_by_artist.
133 142
 @list = $coll->songs_by_artist( 'dir1-artist' );
134  
-is( scalar @list, 2, 'songs_by_artist return all the songs found' );
  143
+is( scalar @list, 3, 'songs_by_artist return all the songs found' );
135 144
 isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'songs_by_artist return AMCI::Songs' ) for @list;
136 145
 is( $list[0]->artist, 'dir1-artist', 'songs_by_artist return correct objects' );
137 146
 
@@ -139,7 +148,7 @@ is( $list[0]->artist, 'dir1-artist', 'songs_by_artist return correct objects' );
139 148
 #
140 149
 # testing songs_by_artist_partial.
141 150
 @list = $coll->songs_by_artist_partial( 'artist' );
142  
-is( scalar @list, 2, 'songs_by_artist_partial return all the songs found' );
  151
+is( scalar @list, 3, 'songs_by_artist_partial return all the songs found' );
143 152
 isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'songs_by_artist_partial return AMCI::Songs' ) for @list;
144 153
 like( $list[0]->artist, qr/artist/, 'songs_by_artist_partial return correct objects' );
145 154
 
@@ -147,7 +156,7 @@ like( $list[0]->artist, qr/artist/, 'songs_by_artist_partial return correct obje
147 156
 #
148 157
 # testing songs_from_album.
149 158
 @list = $coll->songs_from_album( 'our album' );
150  
-is( scalar @list, 2, 'songs_from_album return all the songs found' );
  159
+is( scalar @list, 3, 'songs_from_album return all the songs found' );
151 160
 isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'songs_from_album return AMCI::Songs' ) for @list;
152 161
 is( $list[0]->album, 'our album', 'songs_from_album_partial return correct objects' );
153 162
 
@@ -155,7 +164,7 @@ is( $list[0]->album, 'our album', 'songs_from_album_partial return correct objec
155 164
 #
156 165
 # testing songs_from_album_partial.
157 166
 @list = $coll->songs_from_album_partial( 'album' );
158  
-is( scalar @list, 2, 'songs_from_album_partial return all the songs found' );
  167
+is( scalar @list, 3, 'songs_from_album_partial return all the songs found' );
159 168
 isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'songs_from_album_partial return AMCI::Songs' ) for @list;
160 169
 like( $list[0]->album, qr/album/, 'songs_from_album_partial return correct objects' );
161 170
 
@@ -171,7 +180,13 @@ is( $list[0]->title, 'ok-title', 'songs_with_title return correct objects' );
171 180
 #
172 181
 # testing songs_with_title_partial.
173 182
 @list = $coll->songs_with_title_partial( 'title' );
174  
-is( scalar @list, 3, 'songs_with_title_partial return all the songs found' );
  183
+is( scalar @list, 4, 'songs_with_title_partial return all the songs found' );
175 184
 isa_ok( $_, 'Audio::MPD::Common::Item::Song', 'songs_with_title_partial return AMCI::Songs' ) for @list;
176 185
 like( $list[0]->title, qr/title/, 'songs_with_title_partial return correct objects' );
177 186
 
  187
+
  188
+#
  189
+# testing artists_by_genre.
  190
+@list = $coll->artists_by_genre( 'foo-genre' );
  191
+is( scalar @list, 1, 'artists_by_genre returns the artist' );
  192
+is( $list[0], 'dir1-artist', 'artists_by_genre return plain strings' );

0 notes on commit 1ecc02b

Please sign in to comment.
Something went wrong with that request. Please try again.