diff --git a/lib/qa/authorities/discogs/generic_authority.rb b/lib/qa/authorities/discogs/generic_authority.rb index bafc0366..f7f7f30d 100644 --- a/lib/qa/authorities/discogs/generic_authority.rb +++ b/lib/qa/authorities/discogs/generic_authority.rb @@ -102,20 +102,25 @@ 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-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"] - # }] + # "uri": "https://www.discogs.com/Frank-Sinatra-And-The-Modernaires-Sorry-Why-Remind-Me/release/4212473", + # "id": "4212473", + # "label": "Frank Sinatra And The Modernaires - Sorry / Why Remind Me", + # "context": [{ + # "property": "Image URL", + # "values": ["https://img.discogs.com/1358693671-5430.jpeg.jpg"] + # }, { + # "property": "Year", + # "values": ["1950"] + # }, { + # "property": "Record Labels", + # "values": ["Columbia"] + # }, { + # "property": "Formats", + # "values": ["Shellac", "10\"", "78 RPM"] + # }, { + # "property": "Type", + # "values": ["release"] + # }] # }] def parse_authority_response(response) response['results'].map do |result| @@ -133,11 +138,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']) }] + [{ "property" => "Image URL", "values" => get_context_for_string(result['cover_image']) }, + { "property" => "Year", "values" => get_context_for_string(result['year']) }, + { "property" => "Record Labels", "values" => get_context_for_array(result['label']) }, + { "property" => "Formats", "values" => get_context_for_array(result['format']) }, + { "property" => "Type", "values" => 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 a38f029a..f6584a7d 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"][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" + expect(results.first["context"][1]["values"]).to eq ["2009"] + expect(results.first["context"][3]["values"][0]).to eq "Vinyl" + expect(results.first["context"][2]["values"][1]).to eq "Universal Music Classics & Jazz" + expect(results.first["context"][4]["values"][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'][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" + expect(results.first['context'][1]["values"]).to eq ['1966'] + expect(results.first['context'][3]["values"][2]).to eq "45 RPM" + expect(results.first["context"][4]["values"][0]).to eq "master" end end