From 6c3c13752052a071b790b5c72154b7e8ebd88f04 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Tue, 19 Jan 2016 00:37:09 -0600 Subject: [PATCH 01/11] Force numeric context on recording length Part of MBS-8329. I couldn't reproduce this, but I couldn't consistently reproduce MBS-8620 either. --- .../Server/WebService/Serializer/JSON/2/Recording.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm index 8aa614364cd..fb09d1e4746 100644 --- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm +++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm @@ -1,6 +1,10 @@ package MusicBrainz::Server::WebService::Serializer::JSON::2::Recording; use Moose; -use MusicBrainz::Server::WebService::Serializer::JSON::2::Utils qw( serialize_entity list_of ); +use MusicBrainz::Server::WebService::Serializer::JSON::2::Utils qw( + number + serialize_entity + list_of +); use List::UtilsBy 'sort_by'; extends 'MusicBrainz::Server::WebService::Serializer::JSON::2'; @@ -18,7 +22,7 @@ sub serialize $body{title} = $entity->name; $body{disambiguation} = $entity->comment // ""; - $body{length} = $entity->length // JSON::null; + $body{length} = number($entity->length); $body{video} = $entity->video ? 1 : 0; $body{"artist-credit"} = serialize_entity($entity->artist_credit) From 23c174b5c4179b47567b0b19d3164e5c5d58013e Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Tue, 19 Jan 2016 00:43:54 -0600 Subject: [PATCH 02/11] Return 'video' as a boolean in /ws/2/recording JSON (MBS-7735) Also reported in MBS-8329. --- .../WebService/Serializer/JSON/2/Recording.pm | 3 +- .../Controller/WS/2/JSON/BrowseRecordings.pm | 20 +++++----- .../Controller/WS/2/JSON/LookupArtist.pm | 4 +- .../Controller/WS/2/JSON/LookupRecording.pm | 20 +++++----- .../Controller/WS/2/JSON/LookupRelease.pm | 38 +++++++++---------- .../Server/Controller/WS/2/JSON/LookupWork.pm | 4 +- 6 files changed, 45 insertions(+), 44 deletions(-) diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm index fb09d1e4746..8678eda1aa4 100644 --- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm +++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm @@ -1,6 +1,7 @@ package MusicBrainz::Server::WebService::Serializer::JSON::2::Recording; use Moose; use MusicBrainz::Server::WebService::Serializer::JSON::2::Utils qw( + boolean number serialize_entity list_of @@ -23,7 +24,7 @@ sub serialize $body{title} = $entity->name; $body{disambiguation} = $entity->comment // ""; $body{length} = number($entity->length); - $body{video} = $entity->video ? 1 : 0; + $body{video} = boolean($entity->video); $body{"artist-credit"} = serialize_entity($entity->artist_credit) if ($entity->artist_credit && diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm index 96cccb114c3..13cf71b63ff 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm @@ -25,7 +25,7 @@ test 'browse recordings via artist (first page)' => sub { length => 217440, puids => [ ], disambiguation => "", - video => 0, + video => JSON::false, }, { id => "6f9c8c32-3aae-4dad-b023-56389361cf6b", @@ -33,7 +33,7 @@ test 'browse recordings via artist (first page)' => sub { length => 173960, puids => [ ], disambiguation => "", - video => 0, + video => JSON::false, }, { id => "7e379a1d-f2bc-47b8-964e-00723df34c8a", @@ -41,7 +41,7 @@ test 'browse recordings via artist (first page)' => sub { length => 208706, puids => [ ], disambiguation => "", - video => 0, + video => JSON::false, }] }); }; @@ -62,7 +62,7 @@ test 'browse recordings via artist (second page)' => sub { length => 267560, puids => [ ], disambiguation => "", - video => 0, + video => JSON::false, }, { id => "6e89c516-b0b6-4735-a758-38e31855dcb6", @@ -70,7 +70,7 @@ test 'browse recordings via artist (second page)' => sub { length => 237133, puids => [ ], disambiguation => "", - video => 0, + video => JSON::false, }, { id => "791d9b27-ae1a-4295-8943-ded4284f2122", @@ -78,7 +78,7 @@ test 'browse recordings via artist (second page)' => sub { length => 229826, puids => [ ], disambiguation => "", - video => 0, + video => JSON::false, }] }); }; @@ -99,28 +99,28 @@ test 'browse recordings via release' => sub { title => "Cella", length => 334000, disambiguation => "", - video => 0, + video => JSON::false, }, { id => "9011e90d-b7e3-400b-b932-305f94608772", title => "Delight", length => 339000, disambiguation => "", - video => 0, + video => JSON::false, }, { id => "a4eb6323-519d-44e4-8ab7-df0a0f9df349", title => "Cyclops", length => 265000, disambiguation => "", - video => 0, + video => JSON::false, }, { id => "e5a5847b-451b-4051-a09b-8295329097e3", title => "Confined", length => 314000, disambiguation => "", - video => 0, + video => JSON::false, }] }); }; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm index 6f2afb92d70..34e898d5e0e 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm @@ -559,7 +559,7 @@ test 'artist lookup with recordings and artist credits' => sub { joinphrase => "" } ], - video => 0 + video => JSON::false, }, { id => "84c98ebf-5d40-4a29-b7b2-0e9c26d9061d", @@ -588,7 +588,7 @@ test 'artist lookup with recordings and artist credits' => sub { joinphrase => "" } ], - video => 0 + video => JSON::false, }, ], ipis => [], diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm index ab374367c84..74d29f9f018 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm @@ -20,7 +20,7 @@ test 'basic recording lookup' => sub { title => "サマーれげぇ!レインボー", length => 296026, disambiguation => "", - video => 0, + video => JSON::false, }); }; @@ -39,7 +39,7 @@ test 'basic recording lookup, inc=annotation' => sub { length => 237133, annotation => "this is a recording annotation", disambiguation => "", - video => 0, + video => JSON::false, }); }; @@ -55,7 +55,7 @@ test 'recording lookup with releases' => sub { title => "サマーれげぇ!レインボー", length => 296026, disambiguation => "", - video => 0, + video => JSON::false, releases => [ { id => "0385f276-5f4f-4c81-a7a4-6bd7b8d85a7e", @@ -117,7 +117,7 @@ test 'lookup recording with official singles' => sub { title => "サマーれげぇ!レインボー", length => 296026, disambiguation => "", - video => 0, + video => JSON::false, releases => [ { id => "0385f276-5f4f-4c81-a7a4-6bd7b8d85a7e", @@ -156,7 +156,7 @@ test 'lookup recording with official singles (+media)' => sub { title => "サマーれげぇ!レインボー", length => 296026, disambiguation => "", - video => 0, + video => JSON::false, releases => [ { id => "0385f276-5f4f-4c81-a7a4-6bd7b8d85a7e", @@ -214,7 +214,7 @@ test 'recording lookup with artists' => sub { title => "the Love Bug", disambiguation => "", length => 243000, - video => 0, + video => JSON::false, "artist-credit" => [ { name => "m-flo", @@ -251,7 +251,7 @@ test 'recording lookup with puids and isrcs' => sub { title => "サマーれげぇ!レインボー", disambiguation => "", length => 296026, - video => 0, + video => JSON::false, puids => [ ], isrcs => [ "JPA600102450" ], }); @@ -268,7 +268,7 @@ test 'recording lookup with release relationships' => sub { title => "Dear Diary", disambiguation => "", length => 86666, - video => 0, + video => JSON::false, relations => [ { attributes => [], @@ -327,7 +327,7 @@ test 'recording lookup with work relationships' => sub { title => "the Love Bug", disambiguation => "", length => 243000, - video => 0, + video => JSON::false, relations => [ { attributes => [], @@ -365,7 +365,7 @@ test 'recording lookup with work-level relationships' => sub { disambiguation => '', id => '4878bc36-7306-497a-b45a-561d9f7f8573', length => 274666, - video => 0, + video => JSON::false, relations => [ { attributes => [], "attribute-values" => {}, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm index f7f301b2e8e..2f589a658ef 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm @@ -326,7 +326,7 @@ test 'release lookup with labels and recordings' => sub { title => "the Love Bug", length => 243000, disambiguation => "", - video => 0, + video => JSON::false, } }, { @@ -339,7 +339,7 @@ test 'release lookup with labels and recordings' => sub { title => "the Love Bug (Big Bug NYC remix)", length => 222000, disambiguation => "", - video => 0, + video => JSON::false, } }, { @@ -352,7 +352,7 @@ test 'release lookup with labels and recordings' => sub { title => "the Love Bug (cover)", length => 333000, disambiguation => "", - video => 0, + video => JSON::false, } }] }], @@ -500,7 +500,7 @@ test 'release lookup with discids and puids' => sub { length => 296026, disambiguation => "", puids => [ ], - video => 0, + video => JSON::false, } }, { @@ -514,7 +514,7 @@ test 'release lookup with discids and puids' => sub { length => 213106, disambiguation => "", puids => [ ], - video => 0, + video => JSON::false, } }, { @@ -528,7 +528,7 @@ test 'release lookup with discids and puids' => sub { length => 292800, disambiguation => "", puids => [ ], - video => 0, + video => JSON::false, } }] }] @@ -767,7 +767,7 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => '44704dda-b877-4551-a2a8-c1f764476e65', length => 267560, - video => 0, + video => JSON::false, relations => [ { artist => { @@ -801,7 +801,7 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => '8920288e-7541-48a7-b23b-f80447c8b1ab', length => 230506, - video => 0, + video => JSON::false, relations => [ { artist => { disambiguation => '', @@ -833,7 +833,7 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => '6e89c516-b0b6-4735-a758-38e31855dcb6', length => 237133, - video => 0, + video => JSON::false, relations => [ { artist => { disambiguation => '', @@ -865,7 +865,7 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => '791d9b27-ae1a-4295-8943-ded4284f2122', length => 229826, - video => 0, + video => JSON::false, relations => [ { artist => { disambiguation => '', @@ -897,7 +897,7 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => '4f392ffb-d3df-4f8a-ba74-fdecbb1be877', length => 217440, - video => 0, + video => JSON::false, relations => [ { artist => { disambiguation => '', @@ -929,7 +929,7 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => 'dc891eca-bf42-4103-8682-86068fe732a5', length => 227293, - video => 0, + video => JSON::false, relations => [ { artist => { disambiguation => '', @@ -961,7 +961,7 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => '25e9ae0f-8b7d-4230-9cde-9a07f7680e4a', length => 244506, - video => 0, + video => JSON::false, relations => [ { artist => { disambiguation => '', @@ -993,7 +993,7 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => '6f9c8c32-3aae-4dad-b023-56389361cf6b', length => 173960, - video => 0, + video => JSON::false, relations => [ { artist => { disambiguation => '', @@ -1025,7 +1025,7 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => '7e379a1d-f2bc-47b8-964e-00723df34c8a', length => 208706, - video => 0, + video => JSON::false, relations => [ { artist => { disambiguation => '', @@ -1057,7 +1057,7 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => 'a8614bda-42dc-43c7-ac5f-4067acb6f1c5', length => 320067, - video => 0, + video => JSON::false, relations => [ { artist => { disambiguation => '', @@ -1172,7 +1172,7 @@ test 'release lookup, pregap track' => sub { title => 'Hello Goodbye [hidden track]', disambiguation => '', length => 128000, - video => 0, + video => JSON::false, %artist_credit, } }, @@ -1188,7 +1188,7 @@ test 'release lookup, pregap track' => sub { title => 'Hello Goodbye / Galaxie', disambiguation => '', length => 211133, - video => 0, + video => JSON::false, %artist_credit, } }, @@ -1203,7 +1203,7 @@ test 'release lookup, pregap track' => sub { title => '2 X 4', disambiguation => '', length => 240400, - video => 0, + video => JSON::false, %artist_credit, } } diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm index 5a950b1bdfa..72852befd6d 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm @@ -101,7 +101,7 @@ test 'work lookup with recording relationships' => sub { id => "162630d9-36d2-4a8d-ade1-1c77440b34e7", title => "サマーれげぇ!レインボー", length => 296026, - video => 0, + video => JSON::false, disambiguation => "", relations => [] }, @@ -121,7 +121,7 @@ test 'work lookup with recording relationships' => sub { id => "eb818aa4-d472-4d2b-b1a9-7fe5f1c7d26e", title => "サマーれげぇ!レインボー (instrumental)", length => 292800, - video => 0, + video => JSON::false, disambiguation => "", relations => [] }, From bf77d2c06e6bc326dc1382d0737b65006f65db57 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Tue, 19 Jan 2016 16:28:26 -0600 Subject: [PATCH 03/11] Output 'ordering-key' in /ws/2 relationship JSON (MBS-8396) This is just the link_order, with a different name for some reason. The order in which relationships are returned is also changed in this commit. --- .../Serializer/JSON/2/Relationship.pm | 7 +- .../Serializer/JSON/2/Role/Relationships.pm | 7 +- script/dump-entities-sql.pl | 1 + .../Controller/WS/2/JSON/LookupArtist.pm | 35 ++--- .../Controller/WS/2/JSON/LookupSeries.pm | 122 ++++++++++++++++++ t/sql/webservice.sql | 25 ++++ 6 files changed, 177 insertions(+), 20 deletions(-) create mode 100644 t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relationship.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relationship.pm index 57cc158e4ae..a1a1d434a66 100644 --- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relationship.pm +++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relationship.pm @@ -3,7 +3,11 @@ use Moose; use Hash::Merge qw( merge ); use List::AllUtils qw( any ); use MusicBrainz::Server::Data::Utils qw( non_empty ); -use MusicBrainz::Server::WebService::Serializer::JSON::2::Utils qw( date_period serialize_entity ); +use MusicBrainz::Server::WebService::Serializer::JSON::2::Utils qw( + date_period + number + serialize_entity +); extends 'MusicBrainz::Server::WebService::Serializer::JSON::2'; @@ -18,6 +22,7 @@ sub serialize $body->{type} = $entity->link->type->name; $body->{"type-id"} = $entity->link->type->gid; $body->{direction} = $entity->direction == 2 ? "backward" : "forward"; + $body->{'ordering-key'} = number($entity->link_order) if $entity->link_order; $body = merge($body, date_period($entity->link)); $body->{attributes} = [ map { $_->type->name } @attributes ]; diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Role/Relationships.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Role/Relationships.pm index 97c135bd900..d1f72ccfeca 100644 --- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Role/Relationships.pm +++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Role/Relationships.pm @@ -14,8 +14,11 @@ around serialize => sub return $ret unless defined $inc && $inc->has_rels; my @rels = map { serialize_entity($_, $inc, $opts) } - sort_by { $_->target_key . $_->link->type->name } - @{ $entity->relationships }; + sort_by { join("\t", + $_->link->type->name, + (sprintf "%09d", $_->link_order // 0), + $_->target_key) + } $entity->all_relationships; $ret->{relations} = \@rels; diff --git a/script/dump-entities-sql.pl b/script/dump-entities-sql.pl index 3631ee62193..c7112e5e47b 100755 --- a/script/dump-entities-sql.pl +++ b/script/dump-entities-sql.pl @@ -164,6 +164,7 @@ sub relationships { my $link_ids = pluck('link', $results); print_rows($c, 'link', 'id', $link_ids); print_rows($c, 'link_attribute', 'link', $link_ids); + print_rows($c, 'link_attribute_text_value', 'link', $link_ids); print_inserts($c, $table, $results); } diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm index 34e898d5e0e..be52aba8b52 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm @@ -149,11 +149,11 @@ test 'basic artist lookup, inc=url-rels' => sub { direction => "forward", url => { relations => [], - id => '6f0fce21-abd4-4ef7-a7cf-d9ec9830b350', - resource => 'http://farm4.static.flickr.com/3652/3334818186_6e19173c33_b.jpg' + id => '37ad368b-d37d-46d4-be3a-349f78355253', + resource => 'http://www.imdb.com/name/nm4057169/' }, - type => "image", - "type-id" => '221132e9-e30e-43f2-a741-15afc4c5fa7c', + type => "IMDb", + 'type-id' => '94c8b0cc-4477-4106-932c-da60e63de61c', begin => JSON::null, end => JSON::null, ended => JSON::false, @@ -166,11 +166,11 @@ test 'basic artist lookup, inc=url-rels' => sub { direction => "forward", url => { relations => [], - id => '09ea2bb6-0280-4be1-aa7a-46e641c16451', - resource => 'http://members.boardhost.com/wedlock/' + id => 'daa73242-f491-4d94-bbd0-b08a03a4a69b', + resource => 'http://www.paulallgood.com/' }, - type => "online community", - 'type-id' => '35b3a50f-bf0e-4309-a3b4-58eeed8cee6a', + type => "blog", + 'type-id' => 'eb535226-f8ca-499d-9b18-6a144df4ae6f', begin => JSON::null, end => JSON::null, ended => JSON::false, @@ -200,11 +200,11 @@ test 'basic artist lookup, inc=url-rels' => sub { direction => "forward", url => { relations => [], - id => '37ad368b-d37d-46d4-be3a-349f78355253', - resource => 'http://www.imdb.com/name/nm4057169/' + id => '6f0fce21-abd4-4ef7-a7cf-d9ec9830b350', + resource => 'http://farm4.static.flickr.com/3652/3334818186_6e19173c33_b.jpg' }, - type => "IMDb", - 'type-id' => '94c8b0cc-4477-4106-932c-da60e63de61c', + type => "image", + "type-id" => '221132e9-e30e-43f2-a741-15afc4c5fa7c', begin => JSON::null, end => JSON::null, ended => JSON::false, @@ -217,17 +217,18 @@ test 'basic artist lookup, inc=url-rels' => sub { direction => "forward", url => { relations => [], - id => 'daa73242-f491-4d94-bbd0-b08a03a4a69b', - resource => 'http://www.paulallgood.com/' + id => '09ea2bb6-0280-4be1-aa7a-46e641c16451', + resource => 'http://members.boardhost.com/wedlock/' }, - type => "blog", - 'type-id' => 'eb535226-f8ca-499d-9b18-6a144df4ae6f', + type => "online community", + 'type-id' => '35b3a50f-bf0e-4309-a3b4-58eeed8cee6a', begin => JSON::null, end => JSON::null, ended => JSON::false, 'source-credit' => '', 'target-credit' => '', - }], + }, + ], ipis => [], gender => JSON::null, }); diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm new file mode 100644 index 00000000000..0830747c91f --- /dev/null +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm @@ -0,0 +1,122 @@ +package t::MusicBrainz::Server::Controller::WS::2::JSON::LookupSeries; + +use JSON; +use Test::Routine; +use Test::More; +use MusicBrainz::Server::Test ws_test_json => { + version => 2 +}; + +with 't::Mechanize', 't::Context'; + +test 'basic series lookup' => sub { + my $c = shift->c; + + MusicBrainz::Server::Test->prepare_test_database($c, '+webservice'); + + ws_test_json 'basic series lookup', + '/series/d977f7fd-96c9-4e3e-83b5-eb484a9e6582' => encode_json({ + disambiguation => '', + name => 'Bach-Werke-Verzeichnis', + type => 'Catalogue', + id => 'd977f7fd-96c9-4e3e-83b5-eb484a9e6582', + }); + + ws_test_json 'series lookup, inc=aliases', + '/series/d977f7fd-96c9-4e3e-83b5-eb484a9e6582?inc=aliases' => + encode_json({ + disambiguation => '', + name => 'Bach-Werke-Verzeichnis', + type => 'Catalogue', + id => 'd977f7fd-96c9-4e3e-83b5-eb484a9e6582', + aliases => [ + { + primary => JSON::null, + type => JSON::null, + 'sort-name' => 'BWV', + name => 'BWV', + locale => JSON::null, + } + ], + }); + + ws_test_json 'series lookup, inc=work-rels', + '/series/d977f7fd-96c9-4e3e-83b5-eb484a9e6582?inc=work-rels' => + encode_json({ + disambiguation => '', + name => 'Bach-Werke-Verzeichnis', + type => 'Catalogue', + id => 'd977f7fd-96c9-4e3e-83b5-eb484a9e6582', + relations => [ + { + 'attribute-values' => {number => 'BWV 1'}, + attributes => ['number'], + begin => JSON::null, + direction => 'forward', + end => JSON::null, + ended => JSON::false, + 'ordering-key' => 1, + 'source-credit' => '', + 'target-credit' => '', + type => 'part of', + 'type-id' => 'b0d44366-cdf0-3acb-bee6-0f65a77a6ef0', + work => { + attributes => [], + disambiguation => '', + id => '13bb5d97-00db-4fd8-920c-14da7c11bdd4', + iswcs => [], + language => 'deu', + relations => [], + title => "Kantate, BWV 1 \"Wie sch\x{f6}n leuchtet der Morgenstern\"", + type => JSON::null, + }, + }, + { + 'attribute-values' => {number => 'BWV 2'}, + attributes => ['number'], + begin => JSON::null, + direction => 'forward', + end => JSON::null, + ended => JSON::false, + 'ordering-key' => 2, + 'source-credit' => '', + 'target-credit' => '', + type => 'part of', + 'type-id' => 'b0d44366-cdf0-3acb-bee6-0f65a77a6ef0', + work => { + attributes => [], + disambiguation => '', + id => 'fa97639c-ea29-47d6-9461-16b411322bac', + iswcs => [], + language => 'deu', + relations => [], + title => 'Kantate, BWV 2 "Ach Gott, vom Himmel sieh darein"', + type => JSON::null, + }, + }, + { + 'attribute-values' => {number => 'BWV 3'}, + attributes => ['number'], + begin => JSON::null, + direction => 'forward', + end => JSON::null, + ended => JSON::false, + 'ordering-key' => 3, + 'source-credit' => '', + 'target-credit' => '', + type => 'part of', + 'type-id' => 'b0d44366-cdf0-3acb-bee6-0f65a77a6ef0', + work => { + attributes => [], + disambiguation => '', + id => '3edf4a3f-2b11-4a61-a5cf-e193363ef55c', + iswcs => [], + language => 'deu', + relations => [], + title => 'Kantate, BWV 3 "Ach Gott, wie manches Herzeleid"', + type => JSON::null, + }, + }, + ], + }); +}; diff --git a/t/sql/webservice.sql b/t/sql/webservice.sql index 989b0971672..463f46d8f24 100644 --- a/t/sql/webservice.sql +++ b/t/sql/webservice.sql @@ -1615,6 +1615,31 @@ INSERT INTO series (id, gid, name, type, ordering_attribute, ordering_type) VALU INSERT INTO series_alias (id, series, name, sort_name) VALUES (7, 25, 'BWV', 'BWV'); +INSERT INTO work (comment, edits_pending, gid, id, language, last_updated, name, type) VALUES + ('', 0, '13bb5d97-00db-4fd8-920c-14da7c11bdd4', 12488154, 145, '2014-07-09 15:10:16.494155-05', 'Kantate, BWV 1 "Wie schön leuchtet der Morgenstern"', 3), + ('', 0, 'fa97639c-ea29-47d6-9461-16b411322bac', 12488155, 145, '2014-07-09 14:59:14.107699-05', 'Kantate, BWV 2 "Ach Gott, vom Himmel sieh darein"', 3), + ('', 0, '3edf4a3f-2b11-4a61-a5cf-e193363ef55c', 12488156, 145, '2014-07-03 15:29:22.181908-05', 'Kantate, BWV 3 "Ach Gott, wie manches Herzeleid"', 3); + +INSERT INTO link (attribute_count, begin_date_day, begin_date_month, begin_date_year, created, end_date_day, end_date_month, end_date_year, ended, id, link_type) VALUES + (1, NULL, NULL, NULL, '2014-07-09 15:10:16.494155-05', NULL, NULL, NULL, '0', 180865, 743), + (1, NULL, NULL, NULL, '2014-07-03 15:25:50.050958-05', NULL, NULL, NULL, '0', 180086, 743), + (1, NULL, NULL, NULL, '2014-06-24 07:16:41.33395-05', NULL, NULL, NULL, '0', 178448, 743); + +INSERT INTO link_attribute (attribute_type, created, link) VALUES + (788, '2014-07-09 15:10:16.494155-05', 180865), + (788, '2014-07-03 15:25:50.050958-05', 180086), + (788, '2014-06-24 07:16:41.33395-05', 178448); + +INSERT INTO link_attribute_text_value (attribute_type, link, text_value) VALUES + (788, 180865, 'BWV 1'), + (788, 180086, 'BWV 2'), + (788, 178448, 'BWV 3'); + +INSERT INTO l_series_work (edits_pending, entity0, entity0_credit, entity1, entity1_credit, id, last_updated, link, link_order) VALUES + (0, 25, '', 12488154, '', 7760, '2014-07-09 15:10:16.494155-05', 180865, 1), + (0, 25, '', 12488155, '', 7494, '2014-07-03 15:25:50.050958-05', 180086, 2), + (0, 25, '', 12488156, '', 6668, '2014-06-24 07:16:41.33395-05', 178448, 3); + -- Works INSERT INTO work (comment, edits_pending, gid, id, language, last_updated, name, type) VALUES ('', 0, 'f5cdd40d-6dc3-358b-8d7d-22dd9d8f87a8', 7905446, 198, NULL, 'Asseswaving', NULL); From 38314d738df8291dd4b755a6caecf9feb5365246 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Tue, 19 Jan 2016 19:18:51 -0600 Subject: [PATCH 04/11] inc=recordings should imply inc=media (MBS-8367) The only effect this has is to include the medium format when inc=recordings is specified. --- lib/MusicBrainz/Server/Controller/WS/2/Release.pm | 8 +------- lib/MusicBrainz/Server/ControllerBase/WS/2.pm | 2 +- .../Server/Controller/WS/2/JSON/LookupRelease.pm | 6 +++--- .../Server/Controller/WS/2/LookupRelationship.pm | 1 + .../t/MusicBrainz/Server/Controller/WS/2/LookupRelease.pm | 5 +++++ 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/MusicBrainz/Server/Controller/WS/2/Release.pm b/lib/MusicBrainz/Server/Controller/WS/2/Release.pm index e61f12a25cc..bacfce46600 100644 --- a/lib/MusicBrainz/Server/Controller/WS/2/Release.pm +++ b/lib/MusicBrainz/Server/Controller/WS/2/Release.pm @@ -103,13 +103,7 @@ sub release_toplevel if ($c->stash->{inc}->recordings) { - my @mediums; - if (!$c->stash->{inc}->media) - { - $c->model('Medium')->load_for_releases($release); - } - - @mediums = $release->all_mediums; + my @mediums = $release->all_mediums; if (!$c->stash->{inc}->discids) { diff --git a/lib/MusicBrainz/Server/ControllerBase/WS/2.pm b/lib/MusicBrainz/Server/ControllerBase/WS/2.pm index 406a6fd3ca6..758cca2a615 100644 --- a/lib/MusicBrainz/Server/ControllerBase/WS/2.pm +++ b/lib/MusicBrainz/Server/ControllerBase/WS/2.pm @@ -421,7 +421,7 @@ sub linked_releases $c->model('Release')->load_release_events(@$releases); my @mediums; - if ($c->stash->{inc}->media) + if ($c->stash->{inc}->media || $c->stash->{inc}->recordings) { @mediums = map { $_->all_mediums } @$releases; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm index 2f589a658ef..c1246301afc 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm @@ -310,7 +310,7 @@ test 'release lookup with labels and recordings' => sub { }], media => [ { - format => JSON::null, + format => 'CD', title => '', position => 1, "track-offset" => 0, @@ -753,7 +753,7 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => '4f5a6b97-a09b-4893-80d1-eae1f3bfa221', media => [ { - format => undef, + format => 'CD', title => '', 'track-count' => 10, 'track-offset' => 0, @@ -1156,7 +1156,7 @@ test 'release lookup, pregap track' => sub { disambiguation => '', id => 'ec0d0122-b559-4aa1-a017-7068814aae57', media => [ { - format => undef, + format => 'CD', title => '', 'track-count' => 2, 'track-offset' => 0, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/LookupRelationship.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/LookupRelationship.pm index 725ab0b9eaf..8d4cb1f2dbd 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/LookupRelationship.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/LookupRelationship.pm @@ -257,6 +257,7 @@ ws_test 'release lookup with recording-level relationships', + CD 1 diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/LookupRelease.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/LookupRelease.pm index 202aceb2e64..ce22fc82d4f 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/LookupRelease.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/LookupRelease.pm @@ -276,6 +276,7 @@ ws_test 'release lookup with labels, recordings and tags', 1 + CD 11 @@ -654,6 +655,7 @@ ws_test 'release lookup, related artists have no tags', 1 + CD 11267560 @@ -847,6 +849,7 @@ ws_test 'release lookup, track artists have no aliases', 1 + CD 11243000 @@ -1014,6 +1017,7 @@ ws_test 'release lookup, tags are not duplicated for artists that are both relea 1 + CD 1 @@ -1451,6 +1455,7 @@ ws_test 'release lookup, pregap track', 1 + CD 0 0 From 3f304c11252b22a438f539900d09934eab5ee5e0 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Tue, 19 Jan 2016 20:32:34 -0600 Subject: [PATCH 05/11] Replace is_json with cmp_deeply Test::JSON::is_json is really maddening since it just outputs the two huge JSON documents side-by-side, with no indication of where the differences are. --- lib/MusicBrainz/Server/Test.pm | 10 ++-- .../Controller/WS/2/JSON/BrowseArtists.pm | 12 ++-- .../Controller/WS/2/JSON/BrowseLabels.pm | 4 +- .../Controller/WS/2/JSON/BrowseRecordings.pm | 12 ++-- .../WS/2/JSON/BrowseReleaseGroups.pm | 12 ++-- .../Controller/WS/2/JSON/BrowseReleases.pm | 20 +++---- .../Controller/WS/2/JSON/BrowseWorks.pm | 8 +-- .../Server/Controller/WS/2/JSON/Collection.pm | 8 +-- .../Controller/WS/2/JSON/LookupArtist.pm | 58 +++++++++---------- .../Controller/WS/2/JSON/LookupDiscID.pm | 9 ++- .../Controller/WS/2/JSON/LookupEvent.pm | 10 ++-- .../Controller/WS/2/JSON/LookupLabel.pm | 20 +++---- .../Controller/WS/2/JSON/LookupRecording.pm | 43 +++++++------- .../Controller/WS/2/JSON/LookupRelease.pm | 52 ++++++++--------- .../WS/2/JSON/LookupReleaseGroup.pm | 24 ++++---- .../Controller/WS/2/JSON/LookupSeries.pm | 12 ++-- .../Server/Controller/WS/2/JSON/LookupURL.pm | 12 ++-- .../Server/Controller/WS/2/JSON/LookupWork.pm | 19 +++--- .../Server/Controller/WS/js/Autocomplete.pm | 8 +-- 19 files changed, 170 insertions(+), 183 deletions(-) diff --git a/lib/MusicBrainz/Server/Test.pm b/lib/MusicBrainz/Server/Test.pm index 7a49c629e5a..9a0e3761e53 100644 --- a/lib/MusicBrainz/Server/Test.pm +++ b/lib/MusicBrainz/Server/Test.pm @@ -9,7 +9,7 @@ use FindBin '$Bin'; use Getopt::Long; use HTTP::Headers; use HTTP::Request; -use JSON qw( encode_json ); +use JSON qw( decode_json encode_json ); use List::UtilsBy qw( nsort_by ); use MusicBrainz::Server::CacheManager; use MusicBrainz::Server::Context; @@ -20,8 +20,9 @@ use MusicBrainz::WWW::Mechanize; use Sql; use Template; use Test::Builder; +use Test::Deep qw( cmp_deeply ); use Test::Differences; -use Test::JSON import => [qw( is_json is_valid_json )]; +use Test::JSON import => [qw( is_valid_json )]; use Test::Mock::Class ':all'; use Test::WWW::Mechanize::Catalyst; use Test::XML::SemanticCompare; @@ -404,8 +405,7 @@ sub _build_ws_test_json { $mech->get_ok($end_point . $url, 'fetching'); is_valid_json($mech->content, "validating (is_valid_json)"); - is_json($mech->content, $expected); - $Test->note($mech->content); + cmp_deeply(decode_json($mech->content), $expected); }); }; } @@ -486,7 +486,7 @@ sub page_test_jsonld { my $jsonld = encode('UTF-8', $tx->find_value('//script[@type="application/ld+json"]')); is_valid_json($jsonld, 'has valid JSON-LD'); - is_json($jsonld, encode_json($expected), 'has expected JSON-LD'); + cmp_deeply(decode_json($jsonld), $expected, 'has expected JSON-LD'); } 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseArtists.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseArtists.pm index 88e039cae37..d21f4d9376f 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseArtists.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseArtists.pm @@ -14,7 +14,7 @@ test 'browse artists via release group' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse artists via release group', - '/artist?release-group=22b54315-6e51-350b-bb34-e6e16f7688bd' => encode_json( + '/artist?release-group=22b54315-6e51-350b-bb34-e6e16f7688bd' => { "artist-offset" => 0, "artist-count" => 1, @@ -37,7 +37,7 @@ test 'browse artists via release group' => sub { ipis => [], gender => JSON::null, }] - }); + }; }; test 'browse artists via recording' => sub { @@ -45,7 +45,7 @@ test 'browse artists via recording' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse artists via recording', - '/artist?inc=aliases&recording=0cf3008f-e246-428f-abc1-35f87d584d60' => encode_json( + '/artist?inc=aliases&recording=0cf3008f-e246-428f-abc1-35f87d584d60' => { "artist-offset" => 0, "artist-count" => 2, @@ -101,7 +101,7 @@ test 'browse artists via recording' => sub { ipis => [], gender => JSON::null, }] - }); + }; }; test 'browse artists via release, inc=tags+ratings' => sub { @@ -109,7 +109,7 @@ test 'browse artists via release, inc=tags+ratings' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse artists via release, inc=tags+ratings', - '/artist?release=aff4a693-5970-4e2e-bd46-e2ee49c22de7&inc=tags+ratings' => encode_json( + '/artist?release=aff4a693-5970-4e2e-bd46-e2ee49c22de7&inc=tags+ratings' => { "artist-offset" => 0, "artist-count" => 3, @@ -182,7 +182,7 @@ test 'browse artists via release, inc=tags+ratings' => sub { ipis => [], gender => JSON::null, }] - }); + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm index d8415d41a0f..f560fe74b3b 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm @@ -14,7 +14,7 @@ test 'browse labels via release' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse labels via release', - '/label?release=aff4a693-5970-4e2e-bd46-e2ee49c22de7' => encode_json( + '/label?release=aff4a693-5970-4e2e-bd46-e2ee49c22de7' => { "label-count" => 1, "label-offset" => 0, @@ -42,7 +42,7 @@ test 'browse labels via release' => sub { "label-code" => JSON::null, ipis => [], }] - }); + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm index 13cf71b63ff..69bc36337f6 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm @@ -14,7 +14,7 @@ test 'browse recordings via artist (first page)' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse recordings via artist (first page)', - '/recording?artist=3088b672-fba9-4b4b-8ae0-dce13babfbb4&inc=puids&limit=3' => encode_json( + '/recording?artist=3088b672-fba9-4b4b-8ae0-dce13babfbb4&inc=puids&limit=3' => { "recording-count" => 10, "recording-offset" => 0, @@ -43,7 +43,7 @@ test 'browse recordings via artist (first page)' => sub { disambiguation => "", video => JSON::false, }] - }); + }; }; test 'browse recordings via artist (second page)' => sub { @@ -51,7 +51,7 @@ test 'browse recordings via artist (second page)' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse recordings via artist (second page)', - '/recording?artist=3088b672-fba9-4b4b-8ae0-dce13babfbb4&inc=puids&limit=3&offset=3' => encode_json( + '/recording?artist=3088b672-fba9-4b4b-8ae0-dce13babfbb4&inc=puids&limit=3&offset=3' => { "recording-count" => 10, "recording-offset" => 3, @@ -80,7 +80,7 @@ test 'browse recordings via artist (second page)' => sub { disambiguation => "", video => JSON::false, }] - }); + }; }; @@ -89,7 +89,7 @@ test 'browse recordings via release' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse recordings via release', - '/recording?release=adcf7b48-086e-48ee-b420-1001f88d672f&limit=4' => encode_json( + '/recording?release=adcf7b48-086e-48ee-b420-1001f88d672f&limit=4' => { "recording-count" => 12, "recording-offset" => 0, @@ -122,7 +122,7 @@ test 'browse recordings via release' => sub { disambiguation => "", video => JSON::false, }] - }); + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleaseGroups.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleaseGroups.pm index 8bd0b4a145d..883369b20a8 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleaseGroups.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleaseGroups.pm @@ -14,7 +14,7 @@ test 'browse release group via release' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse release group via release', - '/release-group?release=adcf7b48-086e-48ee-b420-1001f88d672f&inc=artist-credits+tags+ratings' => encode_json( + '/release-group?release=adcf7b48-086e-48ee-b420-1001f88d672f&inc=artist-credits+tags+ratings' => { "release-group-offset" => 0, "release-group-count" => 1, @@ -43,7 +43,7 @@ test 'browse release group via release' => sub { "rating" => { "votes-count" => 1, "value" => 4 }, disambiguation => "", }] - }); + }; }; test 'browse release group via artist' => sub { @@ -51,7 +51,7 @@ test 'browse release group via artist' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse release group via artist', - '/release-group?artist=472bc127-8861-45e8-bc9e-31e8dd32de7a&inc=artist-credits+tags+ratings' => encode_json( + '/release-group?artist=472bc127-8861-45e8-bc9e-31e8dd32de7a&inc=artist-credits+tags+ratings' => { "release-group-count" => 2, "release-group-offset" => 0, @@ -101,7 +101,7 @@ test 'browse release group via artist' => sub { "rating" => { "votes-count" => 0, "value" => JSON::null }, disambiguation => "", }] - }); + }; }; test 'browse singles via artist' => sub { @@ -109,12 +109,12 @@ test 'browse singles via artist' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse singles via artist', - '/release-group?artist=a16d1433-ba89-4f72-a47b-a370add0bb55&type=single' => encode_json( + '/release-group?artist=a16d1433-ba89-4f72-a47b-a370add0bb55&type=single' => { "release-group-count" => 0, "release-group-offset" => 0, "release-groups" => [] - }); + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm index 18a631673e8..386d6638d85 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm @@ -30,7 +30,7 @@ test 'browse releases via artist (paging)' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse releases via artist (paging)', - '/release?artist=3088b672-fba9-4b4b-8ae0-dce13babfbb4&offset=2' => encode_json( + '/release?artist=3088b672-fba9-4b4b-8ae0-dce13babfbb4&offset=2' => { "release-count" => 3, "release-offset" => 2, @@ -66,7 +66,7 @@ test 'browse releases via artist (paging)' => sub { disambiguation => "", packaging => JSON::null, }] - }); + }; }; test 'browse releases via label' => sub { @@ -74,7 +74,7 @@ test 'browse releases via label' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse releases via label', - '/release?inc=mediums&label=b4edce40-090f-4956-b82a-5d9d285da40b' => encode_json( + '/release?inc=mediums&label=b4edce40-090f-4956-b82a-5d9d285da40b' => { "release-count" => 2, "release-offset" => 0, @@ -161,7 +161,7 @@ test 'browse releases via label' => sub { disambiguation => "", packaging => JSON::null, }] - }); + }; }; test 'browse releases via release group' => sub { @@ -169,7 +169,7 @@ test 'browse releases via release group' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse releases via release group', - '/release?release-group=b84625af-6229-305f-9f1b-59c0185df016' => encode_json( + '/release?release-group=b84625af-6229-305f-9f1b-59c0185df016' => { "release-count" => 2, "release-offset" => 0, @@ -236,7 +236,7 @@ test 'browse releases via release group' => sub { disambiguation => "", packaging => JSON::null, }] - }); + }; }; test 'browse releases via recording' => sub { @@ -244,7 +244,7 @@ test 'browse releases via recording' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse releases via recording', - '/release?inc=labels&status=official&recording=0c0245df-34f0-416b-8c3f-f20f66e116d0' => encode_json( + '/release?inc=labels&status=official&recording=0c0245df-34f0-416b-8c3f-f20f66e116d0' => { "release-count" => 2, "release-offset" => 0, @@ -333,7 +333,7 @@ test 'browse releases via recording' => sub { disambiguation => "", packaging => JSON::null, }] - }); + }; }; test 'browse releases via track artist' => sub { @@ -341,7 +341,7 @@ test 'browse releases via track artist' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse releases via track artist', - '/release?track_artist=a16d1433-ba89-4f72-a47b-a370add0bb55' => encode_json( + '/release?track_artist=a16d1433-ba89-4f72-a47b-a370add0bb55' => { "release-count" => 1, "release-offset" => 0, @@ -377,7 +377,7 @@ test 'browse releases via track artist' => sub { disambiguation => "", packaging => JSON::null, }] - }); + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseWorks.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseWorks.pm index 537998d4665..48a24f30aae 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseWorks.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseWorks.pm @@ -14,7 +14,7 @@ test 'browse works via artist (first page)' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse works via artist (first page)', - '/work?artist=3088b672-fba9-4b4b-8ae0-dce13babfbb4&limit=5' => encode_json( + '/work?artist=3088b672-fba9-4b4b-8ae0-dce13babfbb4&limit=5' => { "work-offset" => 0, "work-count" => 10, @@ -64,7 +64,7 @@ test 'browse works via artist (first page)' => sub { language => JSON::null, type => JSON::null, }] - }); + }; }; @@ -73,7 +73,7 @@ test 'browse works via artist (second page)' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'browse works via artist (second page)', - '/work?artist=3088b672-fba9-4b4b-8ae0-dce13babfbb4&limit=5&offset=5' => encode_json( + '/work?artist=3088b672-fba9-4b4b-8ae0-dce13babfbb4&limit=5&offset=5' => { "work-offset" => 5, "work-count" => 10, @@ -123,7 +123,7 @@ test 'browse works via artist (second page)' => sub { language => JSON::null, type => JSON::null, }] - }); + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm index c7ebe162733..dc5b932d4f7 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm @@ -23,7 +23,7 @@ INSERT INTO editor_collection_release (collection, release) VALUES (1, 123054); EOSQL ws_test_json 'collections lookup', - '/collection/f34c079d-374e-4436-9448-da92dedef3ce' => encode_json({ + '/collection/f34c079d-374e-4436-9448-da92dedef3ce' => { collections => [ { id => "f34c079d-374e-4436-9448-da92dedef3ce", @@ -34,10 +34,10 @@ EOSQL "release-count" => 1, } ] - }), { username => 'new_editor', password => 'password' }; + }, { username => 'new_editor', password => 'password' }; ws_test_json 'collection releases lookup', - '/collection/f34c079d-374e-4436-9448-da92dedef3ce/releases/' => encode_json( + '/collection/f34c079d-374e-4436-9448-da92dedef3ce/releases/' => { id => "f34c079d-374e-4436-9448-da92dedef3ce", name => "my collection", @@ -72,7 +72,7 @@ EOSQL disambiguation => "", packaging => JSON::null, }] - }), { username => 'new_editor', password => 'password' }; + }, { username => 'new_editor', password => 'password' }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm index be52aba8b52..86c82fb6d13 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm @@ -37,7 +37,7 @@ test 'basic artist lookup' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'basic artist lookup', - '/artist/472bc127-8861-45e8-bc9e-31e8dd32de7a' => encode_json( + '/artist/472bc127-8861-45e8-bc9e-31e8dd32de7a' => { id => "472bc127-8861-45e8-bc9e-31e8dd32de7a", name => "Distance", @@ -55,7 +55,7 @@ test 'basic artist lookup' => sub { type => "Person", ipis => [], gender => JSON::null, - }); + }; }; test 'basic artist lookup, inc=annotation' => sub { @@ -65,7 +65,7 @@ test 'basic artist lookup, inc=annotation' => sub { MusicBrainz::Server::Test->prepare_test_database($c, '+webservice_annotation'); ws_test_json 'basic artist lookup, inc=annotation', - '/artist/472bc127-8861-45e8-bc9e-31e8dd32de7a?inc=annotation' => encode_json( + '/artist/472bc127-8861-45e8-bc9e-31e8dd32de7a?inc=annotation' => { id => "472bc127-8861-45e8-bc9e-31e8dd32de7a", name => "Distance", @@ -84,7 +84,7 @@ test 'basic artist lookup, inc=annotation' => sub { }, ipis => [], gender => JSON::null, - }); + }; }; test 'basic artist lookup, inc=aliases' => sub { @@ -92,7 +92,7 @@ test 'basic artist lookup, inc=aliases' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'basic artist lookup, inc=aliases', - '/artist/a16d1433-ba89-4f72-a47b-a370add0bb55?inc=aliases' => encode_json( + '/artist/a16d1433-ba89-4f72-a47b-a370add0bb55?inc=aliases' => { id => "a16d1433-ba89-4f72-a47b-a370add0bb55", name => "BoA", @@ -117,8 +117,7 @@ test 'basic artist lookup, inc=aliases' => sub { ], ipis => [], gender => JSON::null, - }); - + }; }; test 'basic artist lookup, inc=url-rels' => sub { @@ -126,7 +125,7 @@ test 'basic artist lookup, inc=url-rels' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'basic artist lookup, inc=url-rels', - '/artist/05d83760-08b5-42bb-a8d7-00d80b3bf47c?inc=url-rels' => encode_json( + '/artist/05d83760-08b5-42bb-a8d7-00d80b3bf47c?inc=url-rels' => { id => "05d83760-08b5-42bb-a8d7-00d80b3bf47c", name => "Paul Allgood", @@ -231,8 +230,7 @@ test 'basic artist lookup, inc=url-rels' => sub { ], ipis => [], gender => JSON::null, - }); - + }; }; test 'artist lookup with releases' => sub { @@ -240,7 +238,7 @@ test 'artist lookup with releases' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'artist lookup with releases', - '/artist/802673f0-9b88-4e8a-bb5c-dd01d68b086f?inc=releases' => encode_json( + '/artist/802673f0-9b88-4e8a-bb5c-dd01d68b086f?inc=releases' => { id => "802673f0-9b88-4e8a-bb5c-dd01d68b086f", name => "7人祭", @@ -306,7 +304,7 @@ test 'artist lookup with releases' => sub { ], ipis => [], gender => JSON::null, - }); + }; }; test 'artist lookup with pseudo-releases' => sub { @@ -314,7 +312,7 @@ test 'artist lookup with pseudo-releases' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'artist lookup with pseudo-releases', - '/artist/802673f0-9b88-4e8a-bb5c-dd01d68b086f?inc=releases&type=single&status=pseudo-release' => encode_json( + '/artist/802673f0-9b88-4e8a-bb5c-dd01d68b086f?inc=releases&type=single&status=pseudo-release' => { id => "802673f0-9b88-4e8a-bb5c-dd01d68b086f", name => "7人祭", @@ -357,7 +355,7 @@ test 'artist lookup with pseudo-releases' => sub { ], ipis => [], gender => JSON::null, - }); + }; }; @@ -366,7 +364,7 @@ test 'artist lookup with releases and discids' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'artist lookup with releases and discids', - '/artist/472bc127-8861-45e8-bc9e-31e8dd32de7a?inc=releases+discids' => encode_json( + '/artist/472bc127-8861-45e8-bc9e-31e8dd32de7a?inc=releases+discids' => { id => "472bc127-8861-45e8-bc9e-31e8dd32de7a", name => "Distance", @@ -508,7 +506,7 @@ test 'artist lookup with releases and discids' => sub { }], ipis => [], gender => JSON::null, - }); + }; }; test 'artist lookup with recordings and artist credits' => sub { @@ -516,7 +514,7 @@ test 'artist lookup with recordings and artist credits' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'artist lookup with recordings and artist credits', - '/artist/22dd2db3-88ea-4428-a7a8-5cd3acf23175?inc=recordings+artist-credits' => encode_json( + '/artist/22dd2db3-88ea-4428-a7a8-5cd3acf23175?inc=recordings+artist-credits' => { id => "22dd2db3-88ea-4428-a7a8-5cd3acf23175", name => "m-flo", @@ -594,7 +592,7 @@ test 'artist lookup with recordings and artist credits' => sub { ], ipis => [], gender => JSON::null, - }); + }; }; test 'artist lookup with release groups' => sub { @@ -602,7 +600,7 @@ test 'artist lookup with release groups' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'artist lookup with release groups', - '/artist/22dd2db3-88ea-4428-a7a8-5cd3acf23175?inc=release-groups&type=single' => encode_json( + '/artist/22dd2db3-88ea-4428-a7a8-5cd3acf23175?inc=release-groups&type=single' => { id => "22dd2db3-88ea-4428-a7a8-5cd3acf23175", name => "m-flo", @@ -630,7 +628,7 @@ test 'artist lookup with release groups' => sub { ], ipis => [], gender => JSON::null, - }); + }; }; test 'single artist release lookup' => sub { @@ -638,7 +636,7 @@ test 'single artist release lookup' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'single artist release lookup', - '/artist/22dd2db3-88ea-4428-a7a8-5cd3acf23175?inc=releases' => encode_json( + '/artist/22dd2db3-88ea-4428-a7a8-5cd3acf23175?inc=releases' => { id => "22dd2db3-88ea-4428-a7a8-5cd3acf23175", name => "m-flo", @@ -681,7 +679,7 @@ test 'single artist release lookup' => sub { ], ipis => [], gender => JSON::null, - }); + }; }; test 'various artists release lookup' => sub { @@ -689,7 +687,7 @@ test 'various artists release lookup' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'various artists release lookup', - '/artist/a16d1433-ba89-4f72-a47b-a370add0bb55?inc=releases+various-artists&status=official' => encode_json( + '/artist/a16d1433-ba89-4f72-a47b-a370add0bb55?inc=releases+various-artists&status=official' => { id => "a16d1433-ba89-4f72-a47b-a370add0bb55", name => "BoA", @@ -732,7 +730,7 @@ test 'various artists release lookup' => sub { ], ipis => [], gender => JSON::null, - }); + }; }; test 'artist lookup with works (using l_artist_work)' => sub { @@ -740,7 +738,7 @@ test 'artist lookup with works (using l_artist_work)' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'artist lookup with works (using l_artist_work)', - '/artist/472bc127-8861-45e8-bc9e-31e8dd32de7a?inc=works' => encode_json( + '/artist/472bc127-8861-45e8-bc9e-31e8dd32de7a?inc=works' => { id => "472bc127-8861-45e8-bc9e-31e8dd32de7a", name => "Distance", @@ -769,7 +767,7 @@ test 'artist lookup with works (using l_artist_work)' => sub { ], ipis => [], gender => JSON::null, - }); + }; }; test 'artist lookup with works (using l_recording_work)' => sub { @@ -777,7 +775,7 @@ test 'artist lookup with works (using l_recording_work)' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'artist lookup with works (using l_recording_work)', - '/artist/a16d1433-ba89-4f72-a47b-a370add0bb55?inc=works' => encode_json( + '/artist/a16d1433-ba89-4f72-a47b-a370add0bb55?inc=works' => { id => "a16d1433-ba89-4f72-a47b-a370add0bb55", name => "BoA", @@ -931,7 +929,7 @@ test 'artist lookup with works (using l_recording_work)' => sub { }], ipis => [], gender => JSON::null, - }); + }; }; @@ -940,7 +938,7 @@ test 'artist lookup with artist relations' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'artist lookup with artist relations', - '/artist/678ba12a-e485-44c7-8eaf-25e61a78a61b?inc=artist-rels' => encode_json( + '/artist/678ba12a-e485-44c7-8eaf-25e61a78a61b?inc=artist-rels' => { id => "678ba12a-e485-44c7-8eaf-25e61a78a61b", name => "後藤真希", @@ -986,7 +984,7 @@ test 'artist lookup with artist relations' => sub { ], ipis => [], gender => 'Female', - }); + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupDiscID.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupDiscID.pm index 7d5e5602cf2..62e687d4f6f 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupDiscID.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupDiscID.pm @@ -18,7 +18,7 @@ test 'direct disc id lookup' => sub { $test->c, "INSERT INTO medium_cdtoc (medium, cdtoc) VALUES (2, 2);"); ws_test_json 'direct disc id lookup', - '/discid/IeldkVfIh1wep_M8CMuDvA0nQ7Q-' => encode_json( + '/discid/IeldkVfIh1wep_M8CMuDvA0nQ7Q-' => { id => "IeldkVfIh1wep_M8CMuDvA0nQ7Q-", 'offset-count' => 9, @@ -93,7 +93,7 @@ test 'direct disc id lookup' => sub { }] } ] - }); + }; }; @@ -108,7 +108,7 @@ test 'lookup via toc' => sub { $test->c->model('DurationLookup')->update(4); ws_test_json 'lookup via toc', - '/discid/aa11.sPglQ1x0cybDcDi0OsZw9Q-?toc=1 9 189343 150 6614 32287 54041 61236 88129 92729 115276 153877&cdstubs=no' => encode_json( + '/discid/aa11.sPglQ1x0cybDcDi0OsZw9Q-?toc=1 9 189343 150 6614 32287 54041 61236 88129 92729 115276 153877&cdstubs=no' => { releases => [ { @@ -209,8 +209,7 @@ test 'lookup via toc' => sub { }] } ] - }); + }; }; 1; - diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupEvent.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupEvent.pm index 07cd68943ef..2f39eed6683 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupEvent.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupEvent.pm @@ -15,7 +15,7 @@ test 'basic event lookup' => sub { MusicBrainz::Server::Test->prepare_test_database($c, '+webservice'); ws_test_json 'basic event lookup', - '/event/eb668bdc-a928-49a1-beb7-8e37db2a5b65' => encode_json( + '/event/eb668bdc-a928-49a1-beb7-8e37db2a5b65' => { id => "eb668bdc-a928-49a1-beb7-8e37db2a5b65", name => "Cool Festival", @@ -29,7 +29,7 @@ test 'basic event lookup' => sub { end => JSON::null, ended => JSON::false }, - }); + }; }; test 'basic event lookup, inc=aliases' => sub { @@ -37,7 +37,7 @@ test 'basic event lookup, inc=aliases' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'basic event lookup, inc=aliases', - '/event/eb668bdc-a928-49a1-beb7-8e37db2a5b65?inc=aliases' => encode_json( + '/event/eb668bdc-a928-49a1-beb7-8e37db2a5b65?inc=aliases' => { id => "eb668bdc-a928-49a1-beb7-8e37db2a5b65", name => "Cool Festival", @@ -55,7 +55,5 @@ test 'basic event lookup, inc=aliases' => sub { { name => "El Festival Cool", "sort-name" => "Festival Cool, El", locale => JSON::null, primary => JSON::null, type => JSON::null }, { name => "Warm Festival", "sort-name" => "Warm Festival", locale => JSON::null, primary => JSON::null, type => JSON::null }, ], - }); - + }; }; - diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm index 3f86550fa59..cdc4d007065 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm @@ -14,7 +14,7 @@ test 'basic label lookup' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'basic label lookup', - '/label/b4edce40-090f-4956-b82a-5d9d285da40b' => encode_json( + '/label/b4edce40-090f-4956-b82a-5d9d285da40b' => { id => "b4edce40-090f-4956-b82a-5d9d285da40b", name => "Planet Mu", @@ -37,8 +37,7 @@ test 'basic label lookup' => sub { "iso_3166_2_codes" => [], "iso_3166_3_codes" => []}, ipis => [], - }); - + }; }; test 'basic label lookup, inc=annotation' => sub { @@ -48,7 +47,7 @@ test 'basic label lookup, inc=annotation' => sub { MusicBrainz::Server::Test->prepare_test_database($c, '+webservice_annotation'); ws_test_json 'basic label lookup, inc=annotation', - '/label/46f0f4cd-8aab-4b33-b698-f459faf64190?inc=annotation' => encode_json( + '/label/46f0f4cd-8aab-4b33-b698-f459faf64190?inc=annotation' => { id => "46f0f4cd-8aab-4b33-b698-f459faf64190", name => "Warp Records", @@ -72,8 +71,7 @@ test 'basic label lookup, inc=annotation' => sub { "iso_3166_2_codes" => [], "iso_3166_3_codes" => []}, ipis => [], - }); - + }; }; test 'label lookup, inc=aliases' => sub { @@ -81,7 +79,7 @@ test 'label lookup, inc=aliases' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'label lookup, inc=aliases', - '/label/b4edce40-090f-4956-b82a-5d9d285da40b?inc=aliases' => encode_json( + '/label/b4edce40-090f-4956-b82a-5d9d285da40b?inc=aliases' => { id => "b4edce40-090f-4956-b82a-5d9d285da40b", name => "Planet Mu", @@ -107,8 +105,7 @@ test 'label lookup, inc=aliases' => sub { { name => "Planet µ", "sort-name" => "Planet µ", locale => JSON::null, primary => JSON::null, type => JSON::null } ], ipis => [], - }); - + }; }; test 'label lookup with releases, inc=media' => sub { @@ -116,7 +113,7 @@ test 'label lookup with releases, inc=media' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'label lookup with releases, inc=media', - '/label/b4edce40-090f-4956-b82a-5d9d285da40b?inc=releases+media' => encode_json( + '/label/b4edce40-090f-4956-b82a-5d9d285da40b?inc=releases+media' => { id => "b4edce40-090f-4956-b82a-5d9d285da40b", name => "Planet Mu", @@ -208,8 +205,7 @@ test 'label lookup with releases, inc=media' => sub { } ], ipis => [], - }); + }; }; 1; - diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm index 74d29f9f018..522c181283b 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm @@ -14,15 +14,14 @@ test 'basic recording lookup' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'basic recording lookup', - '/recording/162630d9-36d2-4a8d-ade1-1c77440b34e7' => encode_json( + '/recording/162630d9-36d2-4a8d-ade1-1c77440b34e7' => { id => "162630d9-36d2-4a8d-ade1-1c77440b34e7", title => "サマーれげぇ!レインボー", length => 296026, disambiguation => "", video => JSON::false, - }); - + }; }; test 'basic recording lookup, inc=annotation' => sub { @@ -32,7 +31,7 @@ test 'basic recording lookup, inc=annotation' => sub { MusicBrainz::Server::Test->prepare_test_database($c, '+webservice_annotation'); ws_test_json 'basic recording lookup, inc=annotation', - '/recording/6e89c516-b0b6-4735-a758-38e31855dcb6?inc=annotation' => encode_json( + '/recording/6e89c516-b0b6-4735-a758-38e31855dcb6?inc=annotation' => { id => "6e89c516-b0b6-4735-a758-38e31855dcb6", title => "Plock", @@ -40,8 +39,7 @@ test 'basic recording lookup, inc=annotation' => sub { annotation => "this is a recording annotation", disambiguation => "", video => JSON::false, - }); - + }; }; test 'recording lookup with releases' => sub { @@ -49,7 +47,7 @@ test 'recording lookup with releases' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'recording lookup with releases', - '/recording/162630d9-36d2-4a8d-ade1-1c77440b34e7?inc=releases' => encode_json( + '/recording/162630d9-36d2-4a8d-ade1-1c77440b34e7?inc=releases' => { id => "162630d9-36d2-4a8d-ade1-1c77440b34e7", title => "サマーれげぇ!レインボー", @@ -103,7 +101,7 @@ test 'recording lookup with releases' => sub { disambiguation => "", packaging => JSON::null, }] - }); + }; }; test 'lookup recording with official singles' => sub { @@ -111,7 +109,7 @@ test 'lookup recording with official singles' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'lookup recording with official singles', - '/recording/162630d9-36d2-4a8d-ade1-1c77440b34e7?inc=releases&status=official&type=single' => encode_json( + '/recording/162630d9-36d2-4a8d-ade1-1c77440b34e7?inc=releases&status=official&type=single' => { id => "162630d9-36d2-4a8d-ade1-1c77440b34e7", title => "サマーれげぇ!レインボー", @@ -142,7 +140,7 @@ test 'lookup recording with official singles' => sub { disambiguation => "", packaging => JSON::null, }] - }); + }; }; test 'lookup recording with official singles (+media)' => sub { @@ -150,7 +148,7 @@ test 'lookup recording with official singles (+media)' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'lookup recording with official singles (+media)', - '/recording/162630d9-36d2-4a8d-ade1-1c77440b34e7?inc=releases+media&status=official&type=single' => encode_json( + '/recording/162630d9-36d2-4a8d-ade1-1c77440b34e7?inc=releases+media&status=official&type=single' => { id => "162630d9-36d2-4a8d-ade1-1c77440b34e7", title => "サマーれげぇ!レインボー", @@ -199,8 +197,7 @@ test 'lookup recording with official singles (+media)' => sub { ] }] }] - }); - + }; }; test 'recording lookup with artists' => sub { @@ -208,7 +205,7 @@ test 'recording lookup with artists' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'recording lookup with artists', - '/recording/0cf3008f-e246-428f-abc1-35f87d584d60?inc=artists' => encode_json( + '/recording/0cf3008f-e246-428f-abc1-35f87d584d60?inc=artists' => { id => "0cf3008f-e246-428f-abc1-35f87d584d60", title => "the Love Bug", @@ -237,7 +234,7 @@ test 'recording lookup with artists' => sub { joinphrase => "", } ], - }); + }; }; test 'recording lookup with puids and isrcs' => sub { @@ -245,7 +242,7 @@ test 'recording lookup with puids and isrcs' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'recording lookup with puids and isrcs', - '/recording/162630d9-36d2-4a8d-ade1-1c77440b34e7?inc=puids+isrcs' => encode_json( + '/recording/162630d9-36d2-4a8d-ade1-1c77440b34e7?inc=puids+isrcs' => { id => "162630d9-36d2-4a8d-ade1-1c77440b34e7", title => "サマーれげぇ!レインボー", @@ -254,7 +251,7 @@ test 'recording lookup with puids and isrcs' => sub { video => JSON::false, puids => [ ], isrcs => [ "JPA600102450" ], - }); + }; }; test 'recording lookup with release relationships' => sub { @@ -262,7 +259,7 @@ test 'recording lookup with release relationships' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'recording lookup with release relationships', - '/recording/37a8d72a-a9c9-4edc-9ecf-b5b58e6197a9?inc=release-rels' => encode_json( + '/recording/37a8d72a-a9c9-4edc-9ecf-b5b58e6197a9?inc=release-rels' => { id => "37a8d72a-a9c9-4edc-9ecf-b5b58e6197a9", title => "Dear Diary", @@ -313,7 +310,7 @@ test 'recording lookup with release relationships' => sub { 'target-credit' => '', } ] - }); + }; }; test 'recording lookup with work relationships' => sub { @@ -321,7 +318,7 @@ test 'recording lookup with work relationships' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'recording lookup with artists', - '/recording/0cf3008f-e246-428f-abc1-35f87d584d60?inc=work-rels' => encode_json( + '/recording/0cf3008f-e246-428f-abc1-35f87d584d60?inc=work-rels' => { id => "0cf3008f-e246-428f-abc1-35f87d584d60", title => "the Love Bug", @@ -352,7 +349,7 @@ test 'recording lookup with work relationships' => sub { 'target-credit' => '', } ], - }); + }; }; test 'recording lookup with work-level relationships' => sub { @@ -361,7 +358,7 @@ test 'recording lookup with work-level relationships' => sub { ws_test_json 'recording lookup with work-level relationships', '/recording/4878bc36-7306-497a-b45a-561d9f7f8573?inc=artist-rels+work-rels+work-level-rels' => - encode_json({ + { disambiguation => '', id => '4878bc36-7306-497a-b45a-561d9f7f8573', length => 274666, @@ -407,7 +404,7 @@ test 'recording lookup with work-level relationships' => sub { 'target-credit' => '', } ], title => 'Asseswaving' - }); + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm index c1246301afc..d30bba82a31 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm @@ -14,7 +14,7 @@ test 'basic release lookup' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'basic release lookup', - '/release/b3b7e934-445b-4c68-a097-730c6a6d47e6' => encode_json( + '/release/b3b7e934-445b-4c68-a097-730c6a6d47e6' => { id => "b3b7e934-445b-4c68-a097-730c6a6d47e6", title => "Summer Reggae! Rainbow", @@ -48,7 +48,7 @@ test 'basic release lookup' => sub { asin => "B00005LA6G", disambiguation => "", packaging => JSON::null, - }); + }; }; test 'basic release lookup, inc=annotation' => sub { @@ -58,7 +58,7 @@ test 'basic release lookup, inc=annotation' => sub { MusicBrainz::Server::Test->prepare_test_database($c, '+webservice_annotation'); ws_test_json 'basic release lookup, inc=annotation', - '/release/adcf7b48-086e-48ee-b420-1001f88d672f?inc=annotation' => encode_json( + '/release/adcf7b48-086e-48ee-b420-1001f88d672f?inc=annotation' => { id => "adcf7b48-086e-48ee-b420-1001f88d672f", title => "My Demons", @@ -93,7 +93,7 @@ test 'basic release lookup, inc=annotation' => sub { annotation => "this is a release annotation", disambiguation => "", packaging => JSON::null, - }); + }; }; test 'basic release with tags' => sub { @@ -105,7 +105,7 @@ test 'basic release with tags' => sub { $c, "INSERT INTO release_tag (count, release, tag) VALUES (1, 123054, 114);"); ws_test_json 'basic release with tags', - '/release/b3b7e934-445b-4c68-a097-730c6a6d47e6?inc=tags' => encode_json( + '/release/b3b7e934-445b-4c68-a097-730c6a6d47e6?inc=tags' => { id => "b3b7e934-445b-4c68-a097-730c6a6d47e6", title => "Summer Reggae! Rainbow", @@ -140,7 +140,7 @@ test 'basic release with tags' => sub { disambiguation => "", packaging => JSON::null, tags => [ { count => 1, name => "hello project" } ] - }); + }; }; test 'basic release with collections' => sub { @@ -156,7 +156,7 @@ test 'basic release with collections' => sub { "INSERT INTO editor_collection_release (collection, release) VALUES (14933, 123054); "); ws_test_json 'basic release with collections', - '/release/b3b7e934-445b-4c68-a097-730c6a6d47e6?inc=collections' => encode_json( + '/release/b3b7e934-445b-4c68-a097-730c6a6d47e6?inc=collections' => { id => "b3b7e934-445b-4c68-a097-730c6a6d47e6", title => "Summer Reggae! Rainbow", @@ -199,7 +199,7 @@ test 'basic release with collections' => sub { "entity-type" => "release", "release-count" => 1 }] - }); + }; }; test 'release lookup with artists + aliases' => sub { @@ -207,7 +207,7 @@ test 'release lookup with artists + aliases' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'release lookup with artists + aliases', - '/release/aff4a693-5970-4e2e-bd46-e2ee49c22de7?inc=artists+aliases' => encode_json( + '/release/aff4a693-5970-4e2e-bd46-e2ee49c22de7?inc=artists+aliases' => { id => "aff4a693-5970-4e2e-bd46-e2ee49c22de7", title => "the Love Bug", @@ -258,7 +258,7 @@ test 'release lookup with artists + aliases' => sub { barcode => "4988064451180", asin => "B0001FAD2O", aliases => [], - }); + }; }; test 'release lookup with labels and recordings' => sub { @@ -266,7 +266,7 @@ test 'release lookup with labels and recordings' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'release lookup with labels and recordings', - '/release/aff4a693-5970-4e2e-bd46-e2ee49c22de7?inc=labels+recordings' => encode_json( + '/release/aff4a693-5970-4e2e-bd46-e2ee49c22de7?inc=labels+recordings' => { id => "aff4a693-5970-4e2e-bd46-e2ee49c22de7", title => "the Love Bug", @@ -356,7 +356,7 @@ test 'release lookup with labels and recordings' => sub { } }] }], - }); + }; }; test 'release lookup with release-groups' => sub { @@ -364,7 +364,7 @@ test 'release lookup with release-groups' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'release lookup with release-groups', - '/release/aff4a693-5970-4e2e-bd46-e2ee49c22de7?inc=artist-credits+release-groups' => encode_json( + '/release/aff4a693-5970-4e2e-bd46-e2ee49c22de7?inc=artist-credits+release-groups' => { id => "aff4a693-5970-4e2e-bd46-e2ee49c22de7", title => "the Love Bug", @@ -427,7 +427,7 @@ test 'release lookup with release-groups' => sub { } ], } - }); + }; }; test 'release lookup with discids and puids' => sub { @@ -435,7 +435,7 @@ test 'release lookup with discids and puids' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'release lookup with discids and puids', - '/release/b3b7e934-445b-4c68-a097-730c6a6d47e6?inc=discids+puids+recordings' => encode_json( + '/release/b3b7e934-445b-4c68-a097-730c6a6d47e6?inc=discids+puids+recordings' => { id => "b3b7e934-445b-4c68-a097-730c6a6d47e6", title => "Summer Reggae! Rainbow", @@ -532,7 +532,7 @@ test 'release lookup with discids and puids' => sub { } }] }] - }); + }; }; test 'release lookup, barcode is NULL' => sub { @@ -540,7 +540,7 @@ test 'release lookup, barcode is NULL' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'release lookup, barcode is NULL', - '/release/fbe4eb72-0f24-3875-942e-f581589713d4' => encode_json( + '/release/fbe4eb72-0f24-3875-942e-f581589713d4' => { id => "fbe4eb72-0f24-3875-942e-f581589713d4", title => "For Beginner Piano", @@ -574,7 +574,7 @@ test 'release lookup, barcode is NULL' => sub { asin => "B00001IVAI", disambiguation => "", packaging => JSON::null, - }); + }; }; test 'release lookup, barcode is empty string' => sub { @@ -582,7 +582,7 @@ test 'release lookup, barcode is empty string' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'release lookup, barcode is empty string', - '/release/dd66bfdd-6097-32e3-91b6-67f47ba25d4c' => encode_json( + '/release/dd66bfdd-6097-32e3-91b6-67f47ba25d4c' => { id => "dd66bfdd-6097-32e3-91b6-67f47ba25d4c", title => "For Beginner Piano", @@ -616,7 +616,7 @@ test 'release lookup, barcode is empty string' => sub { asin => JSON::null, disambiguation => "", packaging => JSON::null, - }); + }; }; test 'release lookup, relation attributes' => sub { @@ -624,7 +624,7 @@ test 'release lookup, relation attributes' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'release lookup, relation attributes', - '/release/28fc2337-985b-3da9-ac40-ad6f28ff0d8e?inc=release-rels+artist-rels' => encode_json( + '/release/28fc2337-985b-3da9-ac40-ad6f28ff0d8e?inc=release-rels+artist-rels' => { disambiguation => '', 'text-representation' => { @@ -718,7 +718,7 @@ test 'release lookup, relation attributes' => sub { status => 'Official', id => '28fc2337-985b-3da9-ac40-ad6f28ff0d8e', barcode => '4988064173891' - }); + }; }; test 'release lookup, track artists have no tags' => sub { @@ -727,7 +727,7 @@ test 'release lookup, track artists have no tags' => sub { ws_test_json 'release lookup, track artists have no tags', '/release/4f5a6b97-a09b-4893-80d1-eae1f3bfa221?inc=artists+recordings+tags+artist-rels+recording-level-rels' - => encode_json({ + => { 'artist-credit' => [ { artist => { disambiguation => '', @@ -1123,7 +1123,7 @@ test 'release lookup, track artists have no tags' => sub { script => 'Latn' }, title => 'For Beginner Piano' - }); + }; }; test 'release lookup, pregap track' => sub { @@ -1142,7 +1142,7 @@ test 'release lookup, pregap track' => sub { ws_test_json 'release lookup, pregap track', '/release/ec0d0122-b559-4aa1-a017-7068814aae57?inc=artists+recordings+artist-credits' - => encode_json({ + => { %artist_credit, asin => undef, barcode => '0208311348266', @@ -1217,7 +1217,7 @@ test 'release lookup, pregap track' => sub { script => 'Latn' }, title => 'Soup' - }); + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm index 4014a34b824..6d4a1e090f2 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm @@ -14,7 +14,7 @@ test 'basic release group lookup' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'basic release group lookup', - '/release-group/b84625af-6229-305f-9f1b-59c0185df016' => encode_json( + '/release-group/b84625af-6229-305f-9f1b-59c0185df016' => { id => "b84625af-6229-305f-9f1b-59c0185df016", title => "サマーれげぇ!レインボー", @@ -22,7 +22,7 @@ test 'basic release group lookup' => sub { "first-release-date" => "2001-07-04", "primary-type" => "Single", "secondary-types" => [], - }); + }; }; test 'basic release group lookup, inc=annotation' => sub { @@ -32,7 +32,7 @@ test 'basic release group lookup, inc=annotation' => sub { MusicBrainz::Server::Test->prepare_test_database($c, '+webservice_annotation'); ws_test_json 'basic release group lookup, inc=annotation', - '/release-group/22b54315-6e51-350b-bb34-e6e16f7688bd?inc=annotation' => encode_json( + '/release-group/22b54315-6e51-350b-bb34-e6e16f7688bd?inc=annotation' => { id => "22b54315-6e51-350b-bb34-e6e16f7688bd", title => "My Demons", @@ -41,7 +41,7 @@ test 'basic release group lookup, inc=annotation' => sub { "first-release-date" => "2007-01-29", "primary-type" => "Album", "secondary-types" => [], - }); + }; }; test 'release group lookup with releases' => sub { @@ -49,7 +49,7 @@ test 'release group lookup with releases' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'release group lookup with releases', - '/release-group/56683a0b-45b8-3664-a231-5b68efe2e7e2?inc=releases' => encode_json( + '/release-group/56683a0b-45b8-3664-a231-5b68efe2e7e2?inc=releases' => { id => "56683a0b-45b8-3664-a231-5b68efe2e7e2", title => "Repercussions", @@ -81,7 +81,7 @@ test 'release group lookup with releases' => sub { disambiguation => "", }], disambiguation => "", - }); + }; }; test 'release group lookup with artists' => sub { @@ -89,7 +89,7 @@ test 'release group lookup with artists' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'release group lookup with artists', - '/release-group/56683a0b-45b8-3664-a231-5b68efe2e7e2?inc=artists' => encode_json( + '/release-group/56683a0b-45b8-3664-a231-5b68efe2e7e2?inc=artists' => { id => "56683a0b-45b8-3664-a231-5b68efe2e7e2", title => "Repercussions", @@ -108,7 +108,7 @@ test 'release group lookup with artists' => sub { joinphrase => "", }], disambiguation => "", - }); + }; }; test 'release group lookup with inc=artists+releases+tags+ratings' => sub { @@ -116,7 +116,7 @@ test 'release group lookup with inc=artists+releases+tags+ratings' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'release group lookup with inc=artists+releases+tags+ratings', - '/release-group/153f0a09-fead-3370-9b17-379ebd09446b?inc=artists+releases+tags+ratings' => encode_json( + '/release-group/153f0a09-fead-3370-9b17-379ebd09446b?inc=artists+releases+tags+ratings' => { id => "153f0a09-fead-3370-9b17-379ebd09446b", title => "the Love Bug", @@ -161,7 +161,7 @@ test 'release group lookup with inc=artists+releases+tags+ratings' => sub { disambiguation => "", rating => { "votes-count" => 0, value => JSON::null }, tags => [], - }); + }; }; test 'release group lookup with pseudo-releases' => sub { @@ -169,7 +169,7 @@ test 'release group lookup with pseudo-releases' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'release group lookup with pseudo-releases', - '/release-group/153f0a09-fead-3370-9b17-379ebd09446b?inc=artists+releases&status=pseudo-release' => encode_json( + '/release-group/153f0a09-fead-3370-9b17-379ebd09446b?inc=artists+releases&status=pseudo-release' => { id => "153f0a09-fead-3370-9b17-379ebd09446b", title => "the Love Bug", @@ -189,7 +189,7 @@ test 'release group lookup with pseudo-releases' => sub { }], releases => [], disambiguation => "", - }); + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm index 0830747c91f..31893fe7c4e 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm @@ -15,16 +15,16 @@ test 'basic series lookup' => sub { MusicBrainz::Server::Test->prepare_test_database($c, '+webservice'); ws_test_json 'basic series lookup', - '/series/d977f7fd-96c9-4e3e-83b5-eb484a9e6582' => encode_json({ + '/series/d977f7fd-96c9-4e3e-83b5-eb484a9e6582' => { disambiguation => '', name => 'Bach-Werke-Verzeichnis', type => 'Catalogue', id => 'd977f7fd-96c9-4e3e-83b5-eb484a9e6582', - }); + }; ws_test_json 'series lookup, inc=aliases', '/series/d977f7fd-96c9-4e3e-83b5-eb484a9e6582?inc=aliases' => - encode_json({ + { disambiguation => '', name => 'Bach-Werke-Verzeichnis', type => 'Catalogue', @@ -38,11 +38,11 @@ test 'basic series lookup' => sub { locale => JSON::null, } ], - }); + }; ws_test_json 'series lookup, inc=work-rels', '/series/d977f7fd-96c9-4e3e-83b5-eb484a9e6582?inc=work-rels' => - encode_json({ + { disambiguation => '', name => 'Bach-Werke-Verzeichnis', type => 'Catalogue', @@ -118,5 +118,5 @@ test 'basic series lookup' => sub { }, }, ], - }); + }; }; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm index b78ce028425..e993fc88bd3 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm @@ -14,19 +14,19 @@ test 'basic url lookup' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'basic url lookup', - '/url/e0a79771-e9f0-4127-b58a-f5e6869c8e96' => encode_json( + '/url/e0a79771-e9f0-4127-b58a-f5e6869c8e96' => { id => "e0a79771-e9f0-4127-b58a-f5e6869c8e96", resource => "http://www.discogs.com/artist/Paul+Allgood" - }); + }; ws_test_json 'basic url lookup (by URL)', - '/url?resource=http://www.discogs.com/artist/Paul%2BAllgood' => encode_json( + '/url?resource=http://www.discogs.com/artist/Paul%2BAllgood' => { id => "e0a79771-e9f0-4127-b58a-f5e6869c8e96", resource => "http://www.discogs.com/artist/Paul+Allgood" - }); + }; ws_test_json 'basic url lookup (with inc=artist-rels)', - '/url/e0a79771-e9f0-4127-b58a-f5e6869c8e96?inc=artist-rels' => encode_json( + '/url/e0a79771-e9f0-4127-b58a-f5e6869c8e96?inc=artist-rels' => { id => "e0a79771-e9f0-4127-b58a-f5e6869c8e96", resource => "http://www.discogs.com/artist/Paul+Allgood", @@ -50,7 +50,7 @@ test 'basic url lookup' => sub { 'source-credit' => '', 'target-credit' => '', }] - }); + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm index 72852befd6d..e7cd708c280 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm @@ -19,7 +19,7 @@ test 'basic work lookup' => sub { 'T-000.000.002-0');"); ws_test_json 'basic work lookup', - '/work/3c37b9fa-a6c1-37d2-9e90-657a116d337c' => encode_json( + '/work/3c37b9fa-a6c1-37d2-9e90-657a116d337c' => { attributes => [], id => "3c37b9fa-a6c1-37d2-9e90-657a116d337c", @@ -28,7 +28,7 @@ test 'basic work lookup' => sub { iswcs => [ "T-000.000.002-0" ], language => 'jpn', type => 'Song', - }); + }; }; test 'basic work lookup, inc=annotation' => sub { @@ -38,7 +38,7 @@ test 'basic work lookup, inc=annotation' => sub { MusicBrainz::Server::Test->prepare_test_database($c, '+webservice_annotation'); ws_test_json 'basic work lookup, inc=annotation', - '/work/482530c1-a2ab-32e8-be43-ea5240aa7913?inc=annotation' => encode_json( + '/work/482530c1-a2ab-32e8-be43-ea5240aa7913?inc=annotation' => { attributes => [], id => "482530c1-a2ab-32e8-be43-ea5240aa7913", @@ -48,7 +48,7 @@ test 'basic work lookup, inc=annotation' => sub { iswcs => [ ], language => JSON::null, type => JSON::null, - }); + }; }; test 'work lookup via iswc' => sub { @@ -62,7 +62,7 @@ test 'work lookup via iswc' => sub { " 'T-000.000.002-0');"); ws_test_json 'work lookup via iswc', - '/iswc/T-000.000.002-0' => encode_json( + '/iswc/T-000.000.002-0' => { "work-count" => 1, "work-offset" => 0, @@ -76,7 +76,7 @@ test 'work lookup via iswc' => sub { language => 'jpn', type => "Song", }] - }); + }; }; test 'work lookup with recording relationships' => sub { @@ -84,7 +84,7 @@ test 'work lookup with recording relationships' => sub { MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); ws_test_json 'work lookup with recording relationships', - '/work/3c37b9fa-a6c1-37d2-9e90-657a116d337c?inc=recording-rels' => encode_json( + '/work/3c37b9fa-a6c1-37d2-9e90-657a116d337c?inc=recording-rels' => { attributes => [], id => "3c37b9fa-a6c1-37d2-9e90-657a116d337c", @@ -131,12 +131,11 @@ test 'work lookup with recording relationships' => sub { 'source-credit' => '', 'target-credit' => '', } - ], + ], iswcs => [], language => 'jpn', type => "Song", - }); - + }; }; 1; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/js/Autocomplete.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/js/Autocomplete.pm index 0556fe2b835..c421c6a8ee8 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/js/Autocomplete.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/js/Autocomplete.pm @@ -16,7 +16,7 @@ test all => sub { MusicBrainz::Server::Test->prepare_test_database($c); ws_test 'artist autocomplete response', - '/artist?q=David&direct=true' => encode_json( + '/artist?q=David&direct=true' => [ { "annotation" => '', "area" => undef, @@ -32,10 +32,10 @@ test all => sub { "primaryAlias" => undef, "sortName" => "David Bowie", "typeID" => undef, - }, { "current" => 1, "pages" => 1 } ]); + }, { "current" => 1, "pages" => 1 } ]; ws_test 'label autocomplete response', - '/label?q=Warp&direct=true' => encode_json( + '/label?q=Warp&direct=true' => [ { "annotation" => '', "area" => undef, @@ -50,7 +50,7 @@ test all => sub { "name" => 'Warp Records', "primaryAlias" => undef, "typeID" => 4, - }, { "current" => 1, "pages" => 1 } ]); + }, { "current" => 1, "pages" => 1 } ]; }; From 4dcf338c3104b06c7a6b54106109cc1ae19d02c1 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Tue, 19 Jan 2016 20:38:19 -0600 Subject: [PATCH 06/11] Output 'target-type' in /ws/2 relationship JSON (MBS-5676) Prior to this patch, there was no way to know what property to access to get the target entity's data. --- .../Serializer/JSON/2/Relationship.pm | 1 + .../Controller/WS/2/JSON/LookupArtist.pm | 6 ++ .../Controller/WS/2/JSON/LookupRecording.pm | 4 ++ .../Controller/WS/2/JSON/LookupRelease.pm | 55 ++++++++++++------- .../Controller/WS/2/JSON/LookupSeries.pm | 3 + .../Server/Controller/WS/2/JSON/LookupURL.pm | 1 + .../Server/Controller/WS/2/JSON/LookupWork.pm | 2 + 7 files changed, 51 insertions(+), 21 deletions(-) diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relationship.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relationship.pm index a1a1d434a66..7b2eb04af61 100644 --- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relationship.pm +++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Relationship.pm @@ -41,6 +41,7 @@ sub serialize @attributes } if any { $_->type->creditable } @attributes; + $body->{'target-type'} = $entity->target_type; $body->{$entity->target_type} = serialize_entity($entity->target, $inc, $opts); $body->{'source-credit'} = $entity->source_credit // ''; $body->{'target-credit'} = $entity->target_credit // ''; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm index 86c82fb6d13..848e9efad47 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm @@ -158,6 +158,7 @@ test 'basic artist lookup, inc=url-rels' => sub { ended => JSON::false, 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'url', }, { attributes => [], @@ -175,6 +176,7 @@ test 'basic artist lookup, inc=url-rels' => sub { ended => JSON::false, 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'url', }, { attributes => [], @@ -192,6 +194,7 @@ test 'basic artist lookup, inc=url-rels' => sub { ended => JSON::false, 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'url', }, { attributes => [], @@ -209,6 +212,7 @@ test 'basic artist lookup, inc=url-rels' => sub { ended => JSON::false, 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'url', }, { attributes => [], @@ -226,6 +230,7 @@ test 'basic artist lookup, inc=url-rels' => sub { ended => JSON::false, 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'url', }, ], ipis => [], @@ -980,6 +985,7 @@ test 'artist lookup with artist relations' => sub { begin => '2001', end => JSON::null, ended => JSON::false, + 'target-type' => 'artist', } ], ipis => [], diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm index 522c181283b..1222f495539 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm @@ -308,6 +308,7 @@ test 'recording lookup with release relationships' => sub { ended => JSON::false, 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'release', } ] }; @@ -347,6 +348,7 @@ test 'recording lookup with work relationships' => sub { }, 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'work', } ], }; @@ -396,12 +398,14 @@ test 'recording lookup with work-level relationships' => sub { 'type-id' => 'd59d99ea-23d4-4a80-b066-edca32ee158f', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], title => 'Asseswaving', type => undef }, 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'work', } ], title => 'Asseswaving' }; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm index d30bba82a31..457e9cd41c8 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm @@ -671,7 +671,8 @@ test 'release lookup, relation attributes' => sub { disambiguation => '', relations => [], name => '이수만' - } + }, + 'target-type' => 'artist', }, { begin => JSON::null, @@ -711,7 +712,8 @@ test 'release lookup, relation attributes' => sub { 'attribute-values' => {}, end => JSON::null, 'target-credit' => '', - 'source-credit' => '' + 'source-credit' => '', + 'target-type' => 'release', }], title => 'LOVE & HONESTY', country => 'JP', @@ -764,29 +766,30 @@ test 'release lookup, track artists have no tags' => sub { length => 267560, number => '1', recording => { - disambiguation => '', - id => '44704dda-b877-4551-a2a8-c1f764476e65', - length => 267560, - video => JSON::false, - relations => [ - { - artist => { - disambiguation => '', - id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', - name => 'Plone', - 'sort-name' => 'Plone', - relations => [] - }, - attributes => [], - "attribute-values" => {}, - begin => undef, - direction => 'backward', - end => undef, - ended => JSON::false, + disambiguation => '', + id => '44704dda-b877-4551-a2a8-c1f764476e65', + length => 267560, + video => JSON::false, + relations => [ + { + artist => { + disambiguation => '', + id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', + name => 'Plone', + 'sort-name' => 'Plone', + relations => [] + }, + attributes => [], + "attribute-values" => {}, + begin => undef, + direction => 'backward', + end => undef, + ended => JSON::false, type => 'producer', 'type-id' => '5c0ceac3-feb4-41f0-868d-dc06f6e27fc0', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], title => 'On My Bus' @@ -820,6 +823,7 @@ test 'release lookup, track artists have no tags' => sub { 'type-id' => '5c0ceac3-feb4-41f0-868d-dc06f6e27fc0', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], title => 'Top & Low Rent' }, @@ -852,6 +856,7 @@ test 'release lookup, track artists have no tags' => sub { 'type-id' => '5c0ceac3-feb4-41f0-868d-dc06f6e27fc0', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], title => 'Plock' }, @@ -884,6 +889,7 @@ test 'release lookup, track artists have no tags' => sub { 'type-id' => '5c0ceac3-feb4-41f0-868d-dc06f6e27fc0', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], title => 'Marbles' }, @@ -916,6 +922,7 @@ test 'release lookup, track artists have no tags' => sub { 'type-id' => '5c0ceac3-feb4-41f0-868d-dc06f6e27fc0', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], title => 'Busy Working' }, @@ -948,6 +955,7 @@ test 'release lookup, track artists have no tags' => sub { 'type-id' => '5c0ceac3-feb4-41f0-868d-dc06f6e27fc0', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], title => 'The Greek Alphabet' }, @@ -980,6 +988,7 @@ test 'release lookup, track artists have no tags' => sub { 'type-id' => '5c0ceac3-feb4-41f0-868d-dc06f6e27fc0', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], title => 'Press a Key' }, @@ -1012,6 +1021,7 @@ test 'release lookup, track artists have no tags' => sub { 'type-id' => '5c0ceac3-feb4-41f0-868d-dc06f6e27fc0', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], title => 'Bibi Plone' }, @@ -1044,6 +1054,7 @@ test 'release lookup, track artists have no tags' => sub { 'type-id' => '5c0ceac3-feb4-41f0-868d-dc06f6e27fc0', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], title => 'Be Rude to Your School' }, @@ -1076,6 +1087,7 @@ test 'release lookup, track artists have no tags' => sub { 'type-id' => '5c0ceac3-feb4-41f0-868d-dc06f6e27fc0', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], title => 'Summer Plays Out' }, @@ -1103,6 +1115,7 @@ test 'release lookup, track artists have no tags' => sub { 'type-id' => '307e95dd-88b5-419b-8223-b146d4a0d439', 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', } ], 'release-events' => [ { area => { diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm index 31893fe7c4e..7f7a5d145ad 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm @@ -70,6 +70,7 @@ test 'basic series lookup' => sub { title => "Kantate, BWV 1 \"Wie sch\x{f6}n leuchtet der Morgenstern\"", type => JSON::null, }, + 'target-type' => 'work', }, { 'attribute-values' => {number => 'BWV 2'}, @@ -93,6 +94,7 @@ test 'basic series lookup' => sub { title => 'Kantate, BWV 2 "Ach Gott, vom Himmel sieh darein"', type => JSON::null, }, + 'target-type' => 'work', }, { 'attribute-values' => {number => 'BWV 3'}, @@ -116,6 +118,7 @@ test 'basic series lookup' => sub { title => 'Kantate, BWV 3 "Ach Gott, wie manches Herzeleid"', type => JSON::null, }, + 'target-type' => 'work', }, ], }; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm index e993fc88bd3..f79f110634f 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm @@ -49,6 +49,7 @@ test 'basic url lookup' => sub { end => JSON::null, 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'artist', }] }; }; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm index e7cd708c280..c54bcba0b09 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm @@ -110,6 +110,7 @@ test 'work lookup with recording relationships' => sub { ended => JSON::false, 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'recording', }, { attributes => [], @@ -130,6 +131,7 @@ test 'work lookup with recording relationships' => sub { ended => JSON::false, 'source-credit' => '', 'target-credit' => '', + 'target-type' => 'recording', } ], iswcs => [], From a64d2c7406b93d6352c1d3ffda11b64833cdac80 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Tue, 19 Jan 2016 21:28:54 -0600 Subject: [PATCH 07/11] Distinguish non-existent and not-loaded relationships (MBS-8746) Prior to this patch, there was no real way to tell if `"relations": []` meant the entity actually had no relationships, or if they just weren't loaded. That's fixed by adding a flag to linkable entities indicating whether relationships were loaded, and checking that when serializing things. --- lib/MusicBrainz/Server/Data/Relationship.pm | 3 +++ lib/MusicBrainz/Server/Entity/Role/Linkable.pm | 9 +++++++-- .../Serializer/JSON/2/Role/Relationships.pm | 5 ++++- .../Server/Controller/WS/2/JSON/LookupArtist.pm | 6 ------ .../Server/Controller/WS/2/JSON/LookupRecording.pm | 3 --- .../Server/Controller/WS/2/JSON/LookupRelease.pm | 14 -------------- .../Server/Controller/WS/2/JSON/LookupSeries.pm | 3 --- .../Server/Controller/WS/2/JSON/LookupURL.pm | 1 - .../Server/Controller/WS/2/JSON/LookupWork.pm | 2 -- .../MusicBrainz/Server/Controller/WS/js/Release.pm | 7 +++++-- 10 files changed, 19 insertions(+), 34 deletions(-) diff --git a/lib/MusicBrainz/Server/Data/Relationship.pm b/lib/MusicBrainz/Server/Data/Relationship.pm index de45b6fd434..184331a6f53 100644 --- a/lib/MusicBrainz/Server/Data/Relationship.pm +++ b/lib/MusicBrainz/Server/Data/Relationship.pm @@ -188,6 +188,9 @@ sub _load } } } + for my $obj (@objs) { + $obj->has_loaded_relationships(1); + } return @rels; } diff --git a/lib/MusicBrainz/Server/Entity/Role/Linkable.pm b/lib/MusicBrainz/Server/Entity/Role/Linkable.pm index 6dfff3d2841..7e2c100d0f0 100644 --- a/lib/MusicBrainz/Server/Entity/Role/Linkable.pm +++ b/lib/MusicBrainz/Server/Entity/Role/Linkable.pm @@ -18,6 +18,12 @@ has 'relationships' => ( } ); +has has_loaded_relationships => ( + is => 'rw', + isa => 'Bool', + default => 0, +); + sub grouped_relationships { my ($self, @types) = @_; @@ -86,8 +92,7 @@ around TO_JSON => sub { my $json = $self->$orig; - # FIXME: Need a way to distinguish between relationships not being loaded vs. not existing. - if ($self->all_relationships) { + if ($self->has_loaded_relationships) { $json->{relationships} = [map { $_->TO_JSON } $self->all_relationships]; } diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Role/Relationships.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Role/Relationships.pm index d1f72ccfeca..cd419973ea8 100644 --- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Role/Relationships.pm +++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Role/Relationships.pm @@ -11,7 +11,10 @@ around serialize => sub my ($orig, $self, $entity, $inc, $opts, $toplevel) = @_; my $ret = $self->$orig($entity, $inc, $opts, $toplevel); - return $ret unless defined $inc && $inc->has_rels; + return $ret unless + defined $inc && + $inc->has_rels && + $entity->has_loaded_relationships; my @rels = map { serialize_entity($_, $inc, $opts) } sort_by { join("\t", diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm index 848e9efad47..9f92093f0bc 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm @@ -147,7 +147,6 @@ test 'basic artist lookup, inc=url-rels' => sub { "attribute-values" => {}, direction => "forward", url => { - relations => [], id => '37ad368b-d37d-46d4-be3a-349f78355253', resource => 'http://www.imdb.com/name/nm4057169/' }, @@ -165,7 +164,6 @@ test 'basic artist lookup, inc=url-rels' => sub { "attribute-values" => {}, direction => "forward", url => { - relations => [], id => 'daa73242-f491-4d94-bbd0-b08a03a4a69b', resource => 'http://www.paulallgood.com/' }, @@ -183,7 +181,6 @@ test 'basic artist lookup, inc=url-rels' => sub { "attribute-values" => {}, direction => "forward", url => { - relations => [], id => 'e0a79771-e9f0-4127-b58a-f5e6869c8e96', resource => 'http://www.discogs.com/artist/Paul+Allgood' }, @@ -201,7 +198,6 @@ test 'basic artist lookup, inc=url-rels' => sub { "attribute-values" => {}, direction => "forward", url => { - relations => [], id => '6f0fce21-abd4-4ef7-a7cf-d9ec9830b350', resource => 'http://farm4.static.flickr.com/3652/3334818186_6e19173c33_b.jpg' }, @@ -219,7 +215,6 @@ test 'basic artist lookup, inc=url-rels' => sub { "attribute-values" => {}, direction => "forward", url => { - relations => [], id => '09ea2bb6-0280-4be1-aa7a-46e641c16451', resource => 'http://members.boardhost.com/wedlock/' }, @@ -978,7 +973,6 @@ test 'artist lookup with artist relations' => sub { name => "7人祭", "sort-name" => "7nin Matsuri", disambiguation => "", - relations => [] }, 'source-credit' => 'Maki Goto', 'target-credit' => '7nin Matsuri', diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm index 1222f495539..4464e6ae25a 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm @@ -294,7 +294,6 @@ test 'recording lookup with release relationships' => sub { disambiguation => '', id => '4ccb3e54-caab-4ad4-94a6-a598e0e52eec', packaging => JSON::null, - relations => [], quality => 'normal', status => JSON::null, 'text-representation' => { @@ -344,7 +343,6 @@ test 'recording lookup with work relationships' => sub { language => JSON::null, title => 'the Love Bug', type => JSON::null, - relations => [] }, 'source-credit' => '', 'target-credit' => '', @@ -385,7 +383,6 @@ test 'recording lookup with work-level relationships' => sub { disambiguation => 'UK dubstep artist Greg Sanders', id => '472bc127-8861-45e8-bc9e-31e8dd32de7a', name => 'Distance', - relations => [], 'sort-name' => 'Distance' }, attributes => [], diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm index 457e9cd41c8..b44bb970f3a 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm @@ -669,7 +669,6 @@ test 'release lookup, relation attributes' => sub { id => '4d5ec626-2251-4bb1-b62a-f24f471e3f2c', 'sort-name' => 'Lee, Soo-Man', disambiguation => '', - relations => [], name => '이수만' }, 'target-type' => 'artist', @@ -687,7 +686,6 @@ test 'release lookup, relation attributes' => sub { quality => 'normal', packaging => JSON::null, date => '2004-01-15', - relations => [], 'release-events' => [{ area => { id => '2db42837-c832-3c27-b4a3-08198f75693c', @@ -735,7 +733,6 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', - relations => [], 'sort-name' => 'Plone' }, joinphrase => '', @@ -777,7 +774,6 @@ test 'release lookup, track artists have no tags' => sub { id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', 'sort-name' => 'Plone', - relations => [] }, attributes => [], "attribute-values" => {}, @@ -811,7 +807,6 @@ test 'release lookup, track artists have no tags' => sub { id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', 'sort-name' => 'Plone', - relations => [] }, attributes => [], "attribute-values" => {}, @@ -844,7 +839,6 @@ test 'release lookup, track artists have no tags' => sub { id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', 'sort-name' => 'Plone', - relations => [] }, attributes => [], "attribute-values" => {}, @@ -877,7 +871,6 @@ test 'release lookup, track artists have no tags' => sub { id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', 'sort-name' => 'Plone', - relations => [] }, attributes => [], "attribute-values" => {}, @@ -910,7 +903,6 @@ test 'release lookup, track artists have no tags' => sub { id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', 'sort-name' => 'Plone', - relations => [] }, attributes => [], "attribute-values" => {}, @@ -943,7 +935,6 @@ test 'release lookup, track artists have no tags' => sub { id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', 'sort-name' => 'Plone', - relations => [] }, attributes => [], "attribute-values" => {}, @@ -976,7 +967,6 @@ test 'release lookup, track artists have no tags' => sub { id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', 'sort-name' => 'Plone', - relations => [] }, attributes => [], "attribute-values" => {}, @@ -1009,7 +999,6 @@ test 'release lookup, track artists have no tags' => sub { id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', 'sort-name' => 'Plone', - relations => [] }, attributes => [], "attribute-values" => {}, @@ -1042,7 +1031,6 @@ test 'release lookup, track artists have no tags' => sub { id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', 'sort-name' => 'Plone', - relations => [] }, attributes => [], "attribute-values" => {}, @@ -1075,7 +1063,6 @@ test 'release lookup, track artists have no tags' => sub { id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', 'sort-name' => 'Plone', - relations => [] }, attributes => [], "attribute-values" => {}, @@ -1103,7 +1090,6 @@ test 'release lookup, track artists have no tags' => sub { id => '3088b672-fba9-4b4b-8ae0-dce13babfbb4', name => 'Plone', 'sort-name' => 'Plone', - relations => [] }, attributes => [], "attribute-values" => {}, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm index 7f7a5d145ad..ceebcd20898 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupSeries.pm @@ -66,7 +66,6 @@ test 'basic series lookup' => sub { id => '13bb5d97-00db-4fd8-920c-14da7c11bdd4', iswcs => [], language => 'deu', - relations => [], title => "Kantate, BWV 1 \"Wie sch\x{f6}n leuchtet der Morgenstern\"", type => JSON::null, }, @@ -90,7 +89,6 @@ test 'basic series lookup' => sub { id => 'fa97639c-ea29-47d6-9461-16b411322bac', iswcs => [], language => 'deu', - relations => [], title => 'Kantate, BWV 2 "Ach Gott, vom Himmel sieh darein"', type => JSON::null, }, @@ -114,7 +112,6 @@ test 'basic series lookup' => sub { id => '3edf4a3f-2b11-4a61-a5cf-e193363ef55c', iswcs => [], language => 'deu', - relations => [], title => 'Kantate, BWV 3 "Ach Gott, wie manches Herzeleid"', type => JSON::null, }, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm index f79f110634f..4840be8626c 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupURL.pm @@ -40,7 +40,6 @@ test 'basic url lookup' => sub { name => 'Paul Allgood', 'sort-name' => 'Allgood, Paul', disambiguation => '', - relations => [] }, ended => JSON::false, begin => JSON::null, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm index c54bcba0b09..5bfb9c07380 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupWork.pm @@ -103,7 +103,6 @@ test 'work lookup with recording relationships' => sub { length => 296026, video => JSON::false, disambiguation => "", - relations => [] }, begin => JSON::null, end => JSON::null, @@ -124,7 +123,6 @@ test 'work lookup with recording relationships' => sub { length => 292800, video => JSON::false, disambiguation => "", - relations => [] }, begin => JSON::null, end => JSON::null, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/js/Release.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/js/Release.pm index 7efc002b744..173117ca71a 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/js/Release.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/js/Release.pm @@ -68,8 +68,11 @@ test all => sub { entity1_credit => '', }, "BoA performed vocals"); - is($data->{mediums}->[0]->{tracks}->[1]->{recording}->{relationships}, - undef, "No relationships on second track"); + is_deeply( + $data->{mediums}->[0]->{tracks}->[1]->{recording}->{relationships}, + [], + "No relationships on second track" + ); }; test 'Release group types are serialized (MBS-8212)' => sub { From 731bd4b541655270a7fe7192489029ab3b581a78 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Wed, 20 Jan 2016 00:15:02 -0600 Subject: [PATCH 08/11] Implement /ws/2/isrc/?fmt=json (MBS-7921) --- .../WebService/Serializer/JSON/2/ISRC.pm | 30 +++++++++++++++++++ .../WebService/Serializer/JSON/2/Utils.pm | 5 ++++ .../Server/Controller/WS/2/JSON/LookupISRC.pm | 26 ++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 lib/MusicBrainz/Server/WebService/Serializer/JSON/2/ISRC.pm create mode 100644 t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupISRC.pm diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/ISRC.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/ISRC.pm new file mode 100644 index 00000000000..261518ecc7c --- /dev/null +++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/ISRC.pm @@ -0,0 +1,30 @@ +package MusicBrainz::Server::WebService::Serializer::JSON::2::ISRC; + +use Moose; +use MusicBrainz::Server::WebService::Serializer::JSON::2::Utils qw( serialize_entity ); + +extends 'MusicBrainz::Server::WebService::Serializer::JSON::2'; + +sub serialize { + my ($self, $isrcs, $inc, $stash) = @_; + + return { + isrc => $isrcs->[0]->name, + recordings => [map { serialize_entity($_->recording, $inc, $stash) } @$isrcs], + }; +}; + +__PACKAGE__->meta->make_immutable; + +no Moose; + +1; + +=head1 COPYRIGHT + +This file is part of MusicBrainz, the open internet music database. +Copyright (C) 2016 MetaBrainz Foundation +Licensed under the GPL version 2, or (at your option) any later version: +http://www.gnu.org/licenses/gpl-2.0.txt + +=cut diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Utils.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Utils.pm index eb00d2a1f01..c2e057e4daf 100644 --- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Utils.pm +++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Utils.pm @@ -31,6 +31,7 @@ my %serializers = Collection Event Instrument + ISRC Label Place Medium @@ -71,6 +72,10 @@ sub serializer my $serializer; + if (ref $entity eq 'ARRAY') { + $entity = $entity->[0]; + } + for my $class (keys %serializers) { if ($entity->isa($class)) { return $serializers{$class}; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupISRC.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupISRC.pm new file mode 100644 index 00000000000..d1fd8dd045b --- /dev/null +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupISRC.pm @@ -0,0 +1,26 @@ +package t::MusicBrainz::Server::Controller::WS::2::JSON::LookupISRC; + +use JSON; +use Test::Routine; +use MusicBrainz::Server::Test ws_test_json => { + version => 2 +}; + +with 't::Mechanize', 't::Context'; + +test 'basic isrc lookup' => sub { + MusicBrainz::Server::Test->prepare_test_database(shift->c, '+webservice'); + + ws_test_json 'basic isrc lookup', '/isrc/GBAAA9900303' => { + isrc => 'GBAAA9900303', + recordings => [ + { + disambiguation => '', + id => 'bf7845cc-eac3-48a3-8b06-543b4b7ba117', + length => 289946, + title => 'Hey Boy Hey Girl', + video => JSON::false, + }, + ], + }; +}; From 7d12bab4d18ed2cfe7ad8f52244c93e41e987257 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Wed, 20 Jan 2016 00:19:52 -0600 Subject: [PATCH 09/11] Remove most PUID support from /ws/2 * Remove /ws/2/puid, since it hasn't returned a useful response in years and doesn't appear to get much of any traffic in our logs. * Remove the 'puids' property from the /ws/2 recording JSON. * Leave the 'puids' inc attribute in place, because it's still frequently included in requests. --- .../Server/Controller/WS/2/PUID.pm | 39 ------------------- .../WebService/Serializer/JSON/2/Recording.pm | 5 +-- .../Controller/UnconfirmedEmailAddresses.pm | 1 - .../Controller/WS/2/JSON/BrowseRecordings.pm | 6 --- .../Controller/WS/2/JSON/LookupRecording.pm | 1 - .../Controller/WS/2/JSON/LookupRelease.pm | 3 -- 6 files changed, 2 insertions(+), 53 deletions(-) delete mode 100644 lib/MusicBrainz/Server/Controller/WS/2/PUID.pm diff --git a/lib/MusicBrainz/Server/Controller/WS/2/PUID.pm b/lib/MusicBrainz/Server/Controller/WS/2/PUID.pm deleted file mode 100644 index e52533452e0..00000000000 --- a/lib/MusicBrainz/Server/Controller/WS/2/PUID.pm +++ /dev/null @@ -1,39 +0,0 @@ -package MusicBrainz::Server::Controller::WS::2::PUID; -use Moose; -BEGIN { extends 'MusicBrainz::Server::ControllerBase::WS::2' } - -use aliased 'MusicBrainz::Server::WebService::WebServiceStash'; -use MusicBrainz::Server::Validation qw( is_guid ); -use Readonly; - -my $ws_defs = Data::OptList::mkopt([ - puid => { - method => 'GET', - inc => [ qw(artists releases puids isrcs artist-credits aliases - _relations tags user-tags ratings user-ratings - release-groups ) ], - optional => [ qw(fmt) ] - } -]); - -with 'MusicBrainz::Server::WebService::Validator' => -{ - defs => $ws_defs, -}; - -sub puid : Chained('root') PathPart('puid') Args(1) -{ - my ($self, $c, $id) = @_; - - if (!is_guid($id)) - { - $c->stash->{error} = "Invalid puid."; - $c->detach('bad_req'); - } - - $c->detach('not_found'); -} - -__PACKAGE__->meta->make_immutable; -1; - diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm index 8678eda1aa4..76ab831f643 100644 --- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm +++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Recording.pm @@ -33,13 +33,12 @@ sub serialize $body{releases} = list_of($entity, $inc, $stash, "releases") if ($toplevel && $inc && $inc->releases); - return \%body unless defined $inc && ($inc->isrcs || $inc->puids); + return \%body unless defined $inc && $inc->isrcs; my $opts = $stash->store($entity); $body{isrcs} = [ map { $_->isrc } sort_by { $_->isrc } @{ $opts->{isrcs} } - ] if $inc->isrcs; - $body{puids} = [ ] if $inc->puids; + ] if $inc->isrcs; return \%body; }; diff --git a/t/lib/t/MusicBrainz/Server/Controller/UnconfirmedEmailAddresses.pm b/t/lib/t/MusicBrainz/Server/Controller/UnconfirmedEmailAddresses.pm index a831c675a01..123b8ad5a25 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/UnconfirmedEmailAddresses.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/UnconfirmedEmailAddresses.pm @@ -438,7 +438,6 @@ test 'Paths that allow browsing without a confirmed email address' => sub { "Controller::WS::2::Label::base", "Controller::WS::2::Label::label", "Controller::WS::2::Label::label_search", - "Controller::WS::2::PUID::puid", "Controller::WS::2::Place::base", "Controller::WS::2::Place::place", "Controller::WS::2::Place::place_search", diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm index 69bc36337f6..67facff390c 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseRecordings.pm @@ -23,7 +23,6 @@ test 'browse recordings via artist (first page)' => sub { id => "4f392ffb-d3df-4f8a-ba74-fdecbb1be877", title => "Busy Working", length => 217440, - puids => [ ], disambiguation => "", video => JSON::false, }, @@ -31,7 +30,6 @@ test 'browse recordings via artist (first page)' => sub { id => "6f9c8c32-3aae-4dad-b023-56389361cf6b", title => "Bibi Plone", length => 173960, - puids => [ ], disambiguation => "", video => JSON::false, }, @@ -39,7 +37,6 @@ test 'browse recordings via artist (first page)' => sub { id => "7e379a1d-f2bc-47b8-964e-00723df34c8a", title => "Be Rude to Your School", length => 208706, - puids => [ ], disambiguation => "", video => JSON::false, }] @@ -60,7 +57,6 @@ test 'browse recordings via artist (second page)' => sub { id => "44704dda-b877-4551-a2a8-c1f764476e65", title => "On My Bus", length => 267560, - puids => [ ], disambiguation => "", video => JSON::false, }, @@ -68,7 +64,6 @@ test 'browse recordings via artist (second page)' => sub { id => "6e89c516-b0b6-4735-a758-38e31855dcb6", title => "Plock", length => 237133, - puids => [ ], disambiguation => "", video => JSON::false, }, @@ -76,7 +71,6 @@ test 'browse recordings via artist (second page)' => sub { id => "791d9b27-ae1a-4295-8943-ded4284f2122", title => "Marbles", length => 229826, - puids => [ ], disambiguation => "", video => JSON::false, }] diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm index 4464e6ae25a..4017556f306 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm @@ -249,7 +249,6 @@ test 'recording lookup with puids and isrcs' => sub { disambiguation => "", length => 296026, video => JSON::false, - puids => [ ], isrcs => [ "JPA600102450" ], }; }; diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm index b44bb970f3a..6d53c41ad31 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm @@ -499,7 +499,6 @@ test 'release lookup with discids and puids' => sub { title => "サマーれげぇ!レインボー", length => 296026, disambiguation => "", - puids => [ ], video => JSON::false, } }, @@ -513,7 +512,6 @@ test 'release lookup with discids and puids' => sub { title => "HELLO! また会おうね (7人祭 version)", length => 213106, disambiguation => "", - puids => [ ], video => JSON::false, } }, @@ -527,7 +525,6 @@ test 'release lookup with discids and puids' => sub { title => "サマーれげぇ!レインボー (instrumental)", length => 292800, disambiguation => "", - puids => [ ], video => JSON::false, } }] From 66acde4d17624f10d5a670db7a21beae4f4583aa Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Wed, 20 Jan 2016 00:30:41 -0600 Subject: [PATCH 10/11] Hyphenate iso_3166_x_codes in /ws/2/area JSON The /ws/2 JSON output has always used hyphens instead of underscores, but these for some reason were an exception. In fact, the search server's output already uses hyphens for these, as noted in root/static/scripts/release-editor/duplicates.js --- .../WebService/Serializer/JSON/2/Area.pm | 6 +- .../scripts/release-editor/duplicates.js | 12 +-- .../Controller/WS/2/JSON/BrowseLabels.pm | 6 +- .../Controller/WS/2/JSON/BrowseReleases.pm | 48 ++++++------ .../Server/Controller/WS/2/JSON/Collection.pm | 6 +- .../Controller/WS/2/JSON/LookupArtist.pm | 48 ++++++------ .../Controller/WS/2/JSON/LookupLabel.pm | 36 ++++----- .../Controller/WS/2/JSON/LookupRecording.pm | 30 +++---- .../Controller/WS/2/JSON/LookupRelease.pm | 78 +++++++++---------- .../WS/2/JSON/LookupReleaseGroup.pm | 12 +-- 10 files changed, 138 insertions(+), 144 deletions(-) diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Area.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Area.pm index 60aa3453e05..33852c9de50 100644 --- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Area.pm +++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Area.pm @@ -17,9 +17,9 @@ sub serialize $body{name} = $entity->name; $body{"sort-name"} = $entity->name; $body{disambiguation} = $entity->comment // ""; - $body{iso_3166_1_codes} = $entity->iso_3166_1 ? [ map { $_ } @{ $entity->iso_3166_1 } ] : JSON::null; - $body{iso_3166_2_codes} = $entity->iso_3166_2 ? [ map { $_ } @{ $entity->iso_3166_2 } ] : JSON::null; - $body{iso_3166_3_codes} = $entity->iso_3166_3 ? [ map { $_ } @{ $entity->iso_3166_3 } ] : JSON::null; + $body{'iso-3166-1-codes'} = $entity->iso_3166_1 ? [ map { $_ } @{ $entity->iso_3166_1 } ] : JSON::null; + $body{'iso-3166-2-codes'} = $entity->iso_3166_2 ? [ map { $_ } @{ $entity->iso_3166_2 } ] : JSON::null; + $body{'iso-3166-3-codes'} = $entity->iso_3166_3 ? [ map { $_ } @{ $entity->iso_3166_3 } ] : JSON::null; if ($toplevel) { diff --git a/root/static/scripts/release-editor/duplicates.js b/root/static/scripts/release-editor/duplicates.js index 0c104fad7d5..e42b641541c 100644 --- a/root/static/scripts/release-editor/duplicates.js +++ b/root/static/scripts/release-editor/duplicates.js @@ -132,15 +132,9 @@ const request = require('../common/utility/request'); clean.dates = pluck(events, "date").value(); - // XXX annoying inconsistency!!! - // browse requests return iso_3166_1_codes, the search server returns - // iso-3166-1-codes. - - var areas = pluck(events, "area"); - - clean.countries = areas.pluck("iso-3166-1-codes") - .concat(areas.pluck("iso_3166_1_codes").value()) - .flatten().compact().uniq().value(); + clean.countries = pluck(events, "area") + .pluck("iso-3166-1-codes") + .flatten().compact().uniq().value(); clean.labels = pluck(labels, "label").map(function (info) { return MB.entity.Label({ gid: info.id, name: info.name }); diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm index f560fe74b3b..56530e718f0 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm @@ -30,9 +30,9 @@ test 'browse labels via release' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, "life-span" => { begin => JSON::null, end => JSON::null, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm index 386d6638d85..a075fe2b775 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm @@ -57,9 +57,9 @@ test 'browse releases via artist (paging)' => sub { "id" => "489ce91b-6658-3307-9877-795b68554c98", "name" => "United States", "sort-name" => "United States", - "iso_3166_1_codes" => ["US"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["US"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], asin => "B00001IVAI", barcode => JSON::null, @@ -101,9 +101,9 @@ test 'browse releases via label' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "600116822123", media => [ @@ -145,9 +145,9 @@ test 'browse releases via label' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "600116817020", media => [ @@ -196,9 +196,9 @@ test 'browse releases via release group' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -227,9 +227,9 @@ test 'browse releases via release group' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -271,9 +271,9 @@ test 'browse releases via recording' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4988064173891", asin => "B0000YGBSG", @@ -313,9 +313,9 @@ test 'browse releases via recording' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4988064173907", asin => "B0000YG9NS", @@ -368,9 +368,9 @@ test 'browse releases via track artist' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4988064451180", asin => "B0001FAD2O", diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm index dc5b932d4f7..5df34e10930 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm @@ -64,9 +64,9 @@ EOSQL "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", disambiguation => "", diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm index 9f92093f0bc..042c6579d3d 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm @@ -272,9 +272,9 @@ test 'artist lookup with releases' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", }, @@ -295,9 +295,9 @@ test 'artist lookup with releases' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", } @@ -346,9 +346,9 @@ test 'artist lookup with pseudo-releases' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", } @@ -448,9 +448,9 @@ test 'artist lookup with releases and discids' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }] }, { @@ -499,9 +499,9 @@ test 'artist lookup with releases and discids' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], }], ipis => [], @@ -671,9 +671,9 @@ test 'single artist release lookup' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }] } ], @@ -720,9 +720,9 @@ test 'various artists release lookup' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4988064451180", disambiguation => "", @@ -949,9 +949,9 @@ test 'artist lookup with artist relations' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, begin_area => JSON::null, end_area => JSON::null, disambiguation => "", diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm index cdc4d007065..4854c9cfbf7 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm @@ -33,9 +33,9 @@ test 'basic label lookup' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, ipis => [], }; }; @@ -67,9 +67,9 @@ test 'basic label lookup, inc=annotation' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, ipis => [], }; }; @@ -98,9 +98,9 @@ test 'label lookup, inc=aliases' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, aliases => [ { name => "Planet µ", "sort-name" => "Planet µ", locale => JSON::null, primary => JSON::null, type => JSON::null } ], @@ -132,9 +132,9 @@ test 'label lookup with releases, inc=media' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, releases => [ { id => "3b3d130a-87a8-4a47-b9fb-920f2530d134", @@ -151,9 +151,9 @@ test 'label lookup with releases, inc=media' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "600116822123", disambiguation => "", @@ -188,9 +188,9 @@ test 'label lookup with releases, inc=media' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "600116817020", disambiguation => "", diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm index 4017556f306..933ee56fdbb 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm @@ -70,9 +70,9 @@ test 'recording lookup with releases' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", disambiguation => "", @@ -93,9 +93,9 @@ test 'recording lookup with releases' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", disambiguation => "", @@ -132,9 +132,9 @@ test 'lookup recording with official singles' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", disambiguation => "", @@ -173,9 +173,9 @@ test 'lookup recording with official singles (+media)' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => '4942463511227', disambiguation => "", @@ -280,11 +280,11 @@ test 'recording lookup with release relationships' => sub { area => { disambiguation => '', id => '489ce91b-6658-3307-9877-795b68554c98', - iso_3166_1_codes => [ + 'iso-3166-1-codes' => [ 'US' ], - iso_3166_2_codes => [], - iso_3166_3_codes => [], + 'iso-3166-2-codes' => [], + 'iso-3166-3-codes' => [], name => 'United States', 'sort-name' => 'United States' }, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm index 6d53c41ad31..3c1e6751b10 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm @@ -40,9 +40,9 @@ test 'basic release lookup' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -84,9 +84,9 @@ test 'basic release lookup, inc=annotation' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "600116817020", asin => "B000KJTG6K", @@ -131,9 +131,9 @@ test 'basic release with tags' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -182,9 +182,9 @@ test 'basic release with collections' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -251,9 +251,9 @@ test 'release lookup with artists + aliases' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4988064451180", asin => "B0001FAD2O", @@ -291,9 +291,9 @@ test 'release lookup with labels and recordings' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4988064451180", asin => "B0001FAD2O", @@ -389,9 +389,9 @@ test 'release lookup with release-groups' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4988064451180", asin => "B0001FAD2O", @@ -461,9 +461,9 @@ test 'release lookup with discids and puids' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -563,9 +563,9 @@ test 'release lookup, barcode is NULL' => sub { "id" => "489ce91b-6658-3307-9877-795b68554c98", "name" => "United States", "sort-name" => "United States", - "iso_3166_1_codes" => ["US"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["US"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => JSON::null, asin => "B00001IVAI", @@ -605,9 +605,9 @@ test 'release lookup, barcode is empty string' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "", asin => JSON::null, @@ -642,11 +642,11 @@ test 'release lookup, relation attributes' => sub { 'release-events' => [{ area => { id => '2db42837-c832-3c27-b4a3-08198f75693c', - iso_3166_3_codes => [], + 'iso-3166-3-codes' => [], disambiguation => '', name => 'Japan', - iso_3166_2_codes => [], - iso_3166_1_codes => ['JP'], + 'iso-3166-2-codes' => [], + 'iso-3166-1-codes' => ['JP'], 'sort-name' => 'Japan' }, date => '2004-01-15' @@ -686,12 +686,12 @@ test 'release lookup, relation attributes' => sub { 'release-events' => [{ area => { id => '2db42837-c832-3c27-b4a3-08198f75693c', - iso_3166_3_codes => [], + 'iso-3166-3-codes' => [], name => 'Japan', - iso_3166_2_codes => [], + 'iso-3166-2-codes' => [], disambiguation => '', 'sort-name' => 'Japan', - iso_3166_1_codes => ['JP'] + 'iso-3166-1-codes' => ['JP'] }, date => '2004-01-15' }], @@ -1104,9 +1104,9 @@ test 'release lookup, track artists have no tags' => sub { area => { disambiguation => '', id => '8a754a16-0027-3a29-b6d7-2b40ea0481ed', - iso_3166_1_codes => [ 'GB' ], - iso_3166_2_codes => [], - iso_3166_3_codes => [], + 'iso-3166-1-codes' => [ 'GB' ], + 'iso-3166-2-codes' => [], + 'iso-3166-3-codes' => [], name => 'United Kingdom', 'sort-name' => 'United Kingdom' }, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm index 6d4a1e090f2..0add42bb1e5 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm @@ -72,9 +72,9 @@ test 'release group lookup with releases' => sub { "id" => "8a754a16-0027-3a29-b6d7-2b40ea0481ed", "name" => "United Kingdom", "sort-name" => "United Kingdom", - "iso_3166_1_codes" => ["GB"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["GB"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "600116822123", packaging => JSON::null, @@ -150,9 +150,9 @@ test 'release group lookup with inc=artists+releases+tags+ratings' => sub { "id" => "2db42837-c832-3c27-b4a3-08198f75693c", "name" => "Japan", "sort-name" => "Japan", - "iso_3166_1_codes" => ["JP"], - "iso_3166_2_codes" => [], - "iso_3166_3_codes" => []}, + "iso-3166-1-codes" => ["JP"], + "iso-3166-2-codes" => [], + "iso-3166-3-codes" => []}, }], barcode => "4988064451180", packaging => JSON::null, From 55e4a6e2e3cd9c6a63a53476799bdb6a8be54595 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Wed, 20 Jan 2016 00:54:35 -0600 Subject: [PATCH 11/11] Only output existent iso code properties in /ws/2/area JSON This is what the search server does, so it's more consistent this way. --- .../WebService/Serializer/JSON/2/Area.pm | 6 ++-- .../Controller/WS/2/JSON/BrowseLabels.pm | 3 +- .../Controller/WS/2/JSON/BrowseReleases.pm | 24 +++++-------- .../Server/Controller/WS/2/JSON/Collection.pm | 5 ++- .../Controller/WS/2/JSON/LookupArtist.pm | 34 +++++++----------- .../Controller/WS/2/JSON/LookupLabel.pm | 18 ++++------ .../Controller/WS/2/JSON/LookupRecording.pm | 14 +++----- .../Controller/WS/2/JSON/LookupRelease.pm | 36 ++++++------------- .../WS/2/JSON/LookupReleaseGroup.pm | 6 ++-- 9 files changed, 49 insertions(+), 97 deletions(-) diff --git a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Area.pm b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Area.pm index 33852c9de50..d676fa7005b 100644 --- a/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Area.pm +++ b/lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Area.pm @@ -17,9 +17,9 @@ sub serialize $body{name} = $entity->name; $body{"sort-name"} = $entity->name; $body{disambiguation} = $entity->comment // ""; - $body{'iso-3166-1-codes'} = $entity->iso_3166_1 ? [ map { $_ } @{ $entity->iso_3166_1 } ] : JSON::null; - $body{'iso-3166-2-codes'} = $entity->iso_3166_2 ? [ map { $_ } @{ $entity->iso_3166_2 } ] : JSON::null; - $body{'iso-3166-3-codes'} = $entity->iso_3166_3 ? [ map { $_ } @{ $entity->iso_3166_3 } ] : JSON::null; + $body{'iso-3166-1-codes'} = [$entity->iso_3166_1_codes] if $entity->iso_3166_1_codes; + $body{'iso-3166-2-codes'} = [$entity->iso_3166_2_codes] if $entity->iso_3166_2_codes; + $body{'iso-3166-3-codes'} = [$entity->iso_3166_3_codes] if $entity->iso_3166_3_codes; if ($toplevel) { diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm index 56530e718f0..225c52528dc 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseLabels.pm @@ -31,8 +31,7 @@ test 'browse labels via release' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, "life-span" => { begin => JSON::null, end => JSON::null, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm index a075fe2b775..cd05f81e211 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm @@ -58,8 +58,7 @@ test 'browse releases via artist (paging)' => sub { "name" => "United States", "sort-name" => "United States", "iso-3166-1-codes" => ["US"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], asin => "B00001IVAI", barcode => JSON::null, @@ -102,8 +101,7 @@ test 'browse releases via label' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "600116822123", media => [ @@ -146,8 +144,7 @@ test 'browse releases via label' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "600116817020", media => [ @@ -197,8 +194,7 @@ test 'browse releases via release group' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -228,8 +224,7 @@ test 'browse releases via release group' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -272,8 +267,7 @@ test 'browse releases via recording' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4988064173891", asin => "B0000YGBSG", @@ -314,8 +308,7 @@ test 'browse releases via recording' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4988064173907", asin => "B0000YG9NS", @@ -369,8 +362,7 @@ test 'browse releases via track artist' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4988064451180", asin => "B0001FAD2O", diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm index 5df34e10930..93dad03dc82 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm @@ -65,9 +65,8 @@ EOSQL "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, - }], + }, + }], barcode => "4942463511227", disambiguation => "", packaging => JSON::null, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm index 042c6579d3d..e1de78a77f2 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm @@ -273,8 +273,7 @@ test 'artist lookup with releases' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", }, @@ -296,8 +295,7 @@ test 'artist lookup with releases' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", } @@ -347,8 +345,7 @@ test 'artist lookup with pseudo-releases' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", } @@ -449,8 +446,7 @@ test 'artist lookup with releases and discids' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }] }, { @@ -500,8 +496,7 @@ test 'artist lookup with releases and discids' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], }], ipis => [], @@ -672,8 +667,7 @@ test 'single artist release lookup' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }] } ], @@ -721,8 +715,7 @@ test 'various artists release lookup' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4988064451180", disambiguation => "", @@ -945,13 +938,12 @@ test 'artist lookup with artist relations' => sub { "sort-name" => "Goto, Maki", country => "JP", "area" => { - disambiguation => '', - "id" => "2db42837-c832-3c27-b4a3-08198f75693c", - "name" => "Japan", - "sort-name" => "Japan", - "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + disambiguation => '', + "id" => "2db42837-c832-3c27-b4a3-08198f75693c", + "name" => "Japan", + "sort-name" => "Japan", + "iso-3166-1-codes" => ["JP"], + }, begin_area => JSON::null, end_area => JSON::null, disambiguation => "", diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm index 4854c9cfbf7..06492e7eba7 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm @@ -34,8 +34,7 @@ test 'basic label lookup' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, ipis => [], }; }; @@ -68,8 +67,7 @@ test 'basic label lookup, inc=annotation' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, ipis => [], }; }; @@ -99,8 +97,7 @@ test 'label lookup, inc=aliases' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, aliases => [ { name => "Planet µ", "sort-name" => "Planet µ", locale => JSON::null, primary => JSON::null, type => JSON::null } ], @@ -133,8 +130,7 @@ test 'label lookup with releases, inc=media' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, releases => [ { id => "3b3d130a-87a8-4a47-b9fb-920f2530d134", @@ -152,8 +148,7 @@ test 'label lookup with releases, inc=media' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "600116822123", disambiguation => "", @@ -189,8 +184,7 @@ test 'label lookup with releases, inc=media' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "600116817020", disambiguation => "", diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm index 933ee56fdbb..e1e0b0f1521 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm @@ -71,8 +71,7 @@ test 'recording lookup with releases' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", disambiguation => "", @@ -94,8 +93,7 @@ test 'recording lookup with releases' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", disambiguation => "", @@ -133,8 +131,7 @@ test 'lookup recording with official singles' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", disambiguation => "", @@ -174,8 +171,7 @@ test 'lookup recording with official singles (+media)' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => '4942463511227', disambiguation => "", @@ -283,8 +279,6 @@ test 'recording lookup with release relationships' => sub { 'iso-3166-1-codes' => [ 'US' ], - 'iso-3166-2-codes' => [], - 'iso-3166-3-codes' => [], name => 'United States', 'sort-name' => 'United States' }, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm index 3c1e6751b10..ab39834a829 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRelease.pm @@ -41,8 +41,7 @@ test 'basic release lookup' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -85,8 +84,7 @@ test 'basic release lookup, inc=annotation' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "600116817020", asin => "B000KJTG6K", @@ -132,8 +130,7 @@ test 'basic release with tags' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -183,8 +180,7 @@ test 'basic release with collections' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -252,8 +248,7 @@ test 'release lookup with artists + aliases' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4988064451180", asin => "B0001FAD2O", @@ -292,8 +287,7 @@ test 'release lookup with labels and recordings' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4988064451180", asin => "B0001FAD2O", @@ -390,8 +384,7 @@ test 'release lookup with release-groups' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4988064451180", asin => "B0001FAD2O", @@ -462,8 +455,7 @@ test 'release lookup with discids and puids' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4942463511227", asin => "B00005LA6G", @@ -564,8 +556,7 @@ test 'release lookup, barcode is NULL' => sub { "name" => "United States", "sort-name" => "United States", "iso-3166-1-codes" => ["US"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => JSON::null, asin => "B00001IVAI", @@ -606,8 +597,7 @@ test 'release lookup, barcode is empty string' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "", asin => JSON::null, @@ -642,10 +632,8 @@ test 'release lookup, relation attributes' => sub { 'release-events' => [{ area => { id => '2db42837-c832-3c27-b4a3-08198f75693c', - 'iso-3166-3-codes' => [], disambiguation => '', name => 'Japan', - 'iso-3166-2-codes' => [], 'iso-3166-1-codes' => ['JP'], 'sort-name' => 'Japan' }, @@ -686,9 +674,7 @@ test 'release lookup, relation attributes' => sub { 'release-events' => [{ area => { id => '2db42837-c832-3c27-b4a3-08198f75693c', - 'iso-3166-3-codes' => [], name => 'Japan', - 'iso-3166-2-codes' => [], disambiguation => '', 'sort-name' => 'Japan', 'iso-3166-1-codes' => ['JP'] @@ -1105,8 +1091,6 @@ test 'release lookup, track artists have no tags' => sub { disambiguation => '', id => '8a754a16-0027-3a29-b6d7-2b40ea0481ed', 'iso-3166-1-codes' => [ 'GB' ], - 'iso-3166-2-codes' => [], - 'iso-3166-3-codes' => [], name => 'United Kingdom', 'sort-name' => 'United Kingdom' }, diff --git a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm index 0add42bb1e5..dbbac4a831f 100644 --- a/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm +++ b/t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupReleaseGroup.pm @@ -73,8 +73,7 @@ test 'release group lookup with releases' => sub { "name" => "United Kingdom", "sort-name" => "United Kingdom", "iso-3166-1-codes" => ["GB"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "600116822123", packaging => JSON::null, @@ -151,8 +150,7 @@ test 'release group lookup with inc=artists+releases+tags+ratings' => sub { "name" => "Japan", "sort-name" => "Japan", "iso-3166-1-codes" => ["JP"], - "iso-3166-2-codes" => [], - "iso-3166-3-codes" => []}, + }, }], barcode => "4988064451180", packaging => JSON::null,