Skip to content

Commit

Permalink
Only output existent iso code properties in /ws/2/area JSON
Browse files Browse the repository at this point in the history
This is what the search server does, so it's more consistent this way.
  • Loading branch information
mwiencek committed Jan 20, 2016
1 parent 66acde4 commit 55e4a6e
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 97 deletions.
6 changes: 3 additions & 3 deletions lib/MusicBrainz/Server/WebService/Serializer/JSON/2/Area.pm
Expand Up @@ -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)
{
Expand Down
Expand Up @@ -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,
Expand Down
24 changes: 8 additions & 16 deletions t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/BrowseReleases.pm
Expand Up @@ -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,
Expand Down Expand Up @@ -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 => [
Expand Down Expand Up @@ -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 => [
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/Collection.pm
Expand Up @@ -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,
Expand Down
34 changes: 13 additions & 21 deletions t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupArtist.pm
Expand Up @@ -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",
},
Expand All @@ -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",
}
Expand Down Expand Up @@ -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",
}
Expand Down Expand Up @@ -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" => []},
},
}]
},
{
Expand Down Expand Up @@ -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 => [],
Expand Down Expand Up @@ -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" => []},
},
}]
}
],
Expand Down Expand Up @@ -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 => "",
Expand Down Expand Up @@ -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 => "",
Expand Down
18 changes: 6 additions & 12 deletions t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupLabel.pm
Expand Up @@ -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 => [],
};
};
Expand Down Expand Up @@ -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 => [],
};
};
Expand Down Expand Up @@ -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 }
],
Expand Down Expand Up @@ -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",
Expand All @@ -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 => "",
Expand Down Expand Up @@ -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 => "",
Expand Down
14 changes: 4 additions & 10 deletions t/lib/t/MusicBrainz/Server/Controller/WS/2/JSON/LookupRecording.pm
Expand Up @@ -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 => "",
Expand All @@ -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 => "",
Expand Down Expand Up @@ -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 => "",
Expand Down Expand Up @@ -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 => "",
Expand Down Expand Up @@ -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'
},
Expand Down

0 comments on commit 55e4a6e

Please sign in to comment.