| 1 |
use strict; |
| 2 |
use Test::More; |
| 3 |
|
| 4 |
use WebService::MusicBrainz; |
| 5 |
|
| 6 |
sub exit_if_mb_busy { |
| 7 |
my $res = shift; |
| 8 |
if(exists $res->{error} && $res->{error} =~ m/^The MusicBrainz web server is currently busy/) { |
| 9 |
done_testing(); |
| 10 |
exit(0); |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
my $ws = WebService::MusicBrainz->new(); |
| 15 |
ok($ws); |
| 16 |
|
| 17 |
# JSON TESTS |
| 18 |
my $s1_res = $ws->search(recording => { artist => 'Taylor Swift', release => '1989' }); |
| 19 |
exit_if_mb_busy($s1_res); |
| 20 |
ok($s1_res->{count} > 70); |
| 21 |
sleep(1); |
| 22 |
|
| 23 |
my $s2_res = $ws->search(recording => { mbid => '1d43314e-1d7a-4aef-942e-799370be2b15' }); |
| 24 |
exit_if_mb_busy($s2_res); |
| 25 |
ok($s2_res->{length} == 242000); |
| 26 |
sleep(1); |
| 27 |
|
| 28 |
my $s3_res = $ws->search(recording => { mbid => '1d43314e-1d7a-4aef-942e-799370be2b15', inc => 'artists' }); |
| 29 |
exit_if_mb_busy($s3_res); |
| 30 |
ok($s3_res->{'artist-credit'}->[0]->{name} eq 'Taylor Swift'); |
| 31 |
|
| 32 |
done_testing(); |