diff --git a/lib/qa/authorities/discogs/generic_authority.rb b/lib/qa/authorities/discogs/generic_authority.rb index a634a3ab..bafc0366 100644 --- a/lib/qa/authorities/discogs/generic_authority.rb +++ b/lib/qa/authorities/discogs/generic_authority.rb @@ -101,30 +101,22 @@ def check_for_msg_response(release_resp, master_resp) # @param [Hash] the http response from discogs # @example returns parsed discogs data with context - # { + # [{ # "uri": "https://api.discogs.com/releases/4212473", # "id": "4212473", # "label": "Frank Sinatra And The Modernaires - Sorry / Why Remind Me", - # } - # "context": { - # "Image URL": [ - # "https://img.discogs.com/2e-YoNr0dvmMgbzEN0hjHD6X0sU=/fit-in/600x580/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-4212473-1358693671-5430.jpeg.jpg" - # ], - # "Year": [ - # "1950" - # ], - # "Record Labels": [ - # "Columbia" - # ], - # "Formats": [ - # "Shellac", - # "10\"", - # "78 RPM" - # ], - # "Type": [ - # "release" - # ] - # } + # "context": [{ + # "Image URL": ["https://img.discogs.com/2e-YoNr0d=/fit-in/600x580/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-4212473.jpg"] + # }, { + # "Year": ["1950"] + # }, { + # "Record Labels": ["Columbia"] + # }, { + # "Formats": ["Shellac", "10\"", "78 RPM"] + # }, { + # "Type": ["release"] + # }] + # }] def parse_authority_response(response) response['results'].map do |result| { 'uri' => build_uri(result), @@ -141,11 +133,11 @@ def build_uri(result) # @param [Hash] the results hash from the JSON returned by Discogs def assemble_search_context(result) - { "Image URL" => get_context_for_string(result['cover_image']), - "Year" => get_context_for_string(result['year']), - "Record Labels" => get_context_for_array(result['label']), - "Formats" => get_context_for_array(result['format']), - "Type" => get_context_for_string(result['type']) } + [{ "Image URL" => get_context_for_string(result['cover_image']) }, + { "Year" => get_context_for_string(result['year']) }, + { "Record Labels" => get_context_for_array(result['label']) }, + { "Formats" => get_context_for_array(result['format']) }, + { "Type" => get_context_for_string(result['type']) }] end # checks if the param is null, returns appropriate value diff --git a/spec/lib/authorities/discogs/generic_authority_spec.rb b/spec/lib/authorities/discogs/generic_authority_spec.rb index 8176b46c..a38f029a 100644 --- a/spec/lib/authorities/discogs/generic_authority_spec.rb +++ b/spec/lib/authorities/discogs/generic_authority_spec.rb @@ -276,10 +276,10 @@ expect(results.first["uri"]).to eq("https://www.discogs.com/Melody-Gardot-Who-Will-Comfort-Me-Over-The-Rainbow/release/1750352") expect(results.first["id"]).to eq "1750352" expect(results.first["label"]).to eq "Melody Gardot - Who Will Comfort Me / Over The Rainbow" - expect(results.first["context"]["Year"]).to eq ['2009'] - expect(results.first["context"]["Formats"][0]).to eq "Vinyl" - expect(results.first["context"]["Record Labels"][1]).to eq "Universal Music Classics & Jazz" - expect(results.first["context"]["Type"][0]).to eq "release" + expect(results.first["context"][1]["Year"]).to eq ["2009"] + expect(results.first["context"][3]["Formats"][0]).to eq "Vinyl" + expect(results.first["context"][2]["Record Labels"][1]).to eq "Universal Music Classics & Jazz" + expect(results.first["context"][4]["Type"][0]).to eq "release" end end @@ -299,9 +299,9 @@ expect(results.first['uri']).to eq "https://www.discogs.com/Wes-Montgomery-Bumpin-On-Sunset-Tequila/master/606116" expect(results.first['id']).to eq "606116" expect(results.first['label']).to eq "Wes Montgomery - Bumpin' On Sunset / Tequila" - expect(results.first['context']["Year"]).to eq ['1966'] - expect(results.first['context']["Formats"][2]).to eq "45 RPM" - expect(results.first["context"]["Type"][0]).to eq "master" + expect(results.first['context'][1]["Year"]).to eq ['1966'] + expect(results.first['context'][3]["Formats"][2]).to eq "45 RPM" + expect(results.first["context"][4]["Type"][0]).to eq "master" end end