Extract release_groups_fixtures
This commit is contained in:
@@ -3,6 +3,7 @@ defmodule MusicLibraryWeb.RecordIndexTest do
|
|||||||
|
|
||||||
import Phoenix.LiveViewTest
|
import Phoenix.LiveViewTest
|
||||||
import MusicLibrary.RecordsFixtures
|
import MusicLibrary.RecordsFixtures
|
||||||
|
import MusicLibrary.ReleaseGroupsFixtures
|
||||||
import Mox
|
import Mox
|
||||||
alias MusicLibrary.Records.Record
|
alias MusicLibrary.Records.Record
|
||||||
alias MusicBrainz.APIBehaviourMock
|
alias MusicBrainz.APIBehaviourMock
|
||||||
@@ -271,23 +272,7 @@ defmodule MusicLibraryWeb.RecordIndexTest do
|
|||||||
test "it imports a record when selected", %{conn: conn} do
|
test "it imports a record when selected", %{conn: conn} do
|
||||||
{:ok, import_live, _html} = live(conn, ~p"/records/import")
|
{:ok, import_live, _html} = live(conn, ~p"/records/import")
|
||||||
|
|
||||||
mock_results =
|
mock_results = release_group_search_results()
|
||||||
[
|
|
||||||
%{
|
|
||||||
id: "20790e26-98e4-3ad3-a67f-b674758b942d",
|
|
||||||
type: :album,
|
|
||||||
title: "Marbles",
|
|
||||||
artists: "Marillion",
|
|
||||||
release: "2004-05-03"
|
|
||||||
},
|
|
||||||
%{
|
|
||||||
id: "bf20ac32-a793-3bb4-beff-f7b9bffaca38",
|
|
||||||
type: :album,
|
|
||||||
title: "Marbles Live",
|
|
||||||
artists: "Marillion",
|
|
||||||
release: "2005-10-24"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
expect(APIBehaviourMock, :search_release_group, fn "Marillion Marbles",
|
expect(APIBehaviourMock, :search_release_group, fn "Marillion Marbles",
|
||||||
limit: 10,
|
limit: 10,
|
||||||
@@ -310,82 +295,7 @@ defmodule MusicLibraryWeb.RecordIndexTest do
|
|||||||
first_result = hd(mock_results)
|
first_result = hd(mock_results)
|
||||||
first_result_id = first_result.id
|
first_result_id = first_result.id
|
||||||
|
|
||||||
release_group = %{
|
release_group = release_group()
|
||||||
"artist-credit" => [
|
|
||||||
%{
|
|
||||||
"artist" => %{
|
|
||||||
"disambiguation" => "British progressive rock band",
|
|
||||||
"genres" => [
|
|
||||||
%{
|
|
||||||
"count" => 10,
|
|
||||||
"disambiguation" => "",
|
|
||||||
"id" => "ae9b8279-3959-48d8-8a88-741a7f6d4a48",
|
|
||||||
"name" => "progressive rock"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"id" => "1932f5b6-0b7b-4050-b1df-833ca89e5f44",
|
|
||||||
"name" => "Marillion",
|
|
||||||
"sort-name" => "Marillion",
|
|
||||||
"type" => "Group",
|
|
||||||
"type-id" => "e431f5f6-b5d2-343d-8b36-72607fffb74b"
|
|
||||||
},
|
|
||||||
"joinphrase" => "",
|
|
||||||
"name" => "Marillion"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"disambiguation" => "",
|
|
||||||
"first-release-date" => "2004-05-03",
|
|
||||||
"genres" => [
|
|
||||||
%{
|
|
||||||
"count" => 1,
|
|
||||||
"disambiguation" => "",
|
|
||||||
"id" => "ceeaa283-5d7b-4202-8d1d-e25d116b2a18",
|
|
||||||
"name" => "alternative rock"
|
|
||||||
},
|
|
||||||
%{
|
|
||||||
"count" => 1,
|
|
||||||
"disambiguation" => "",
|
|
||||||
"id" => "b7ef058e-6d83-4ca4-8123-9724bff4648b",
|
|
||||||
"name" => "art rock"
|
|
||||||
},
|
|
||||||
%{
|
|
||||||
"count" => 1,
|
|
||||||
"disambiguation" => "",
|
|
||||||
"id" => "150eb95a-7739-4fde-a5fe-b62ca576a928",
|
|
||||||
"name" => "baroque pop"
|
|
||||||
},
|
|
||||||
%{
|
|
||||||
"count" => 1,
|
|
||||||
"disambiguation" => "",
|
|
||||||
"id" => "797e2e85-5ffd-495c-a757-8b4079052f0e",
|
|
||||||
"name" => "pop rock"
|
|
||||||
},
|
|
||||||
%{
|
|
||||||
"count" => 2,
|
|
||||||
"disambiguation" => "",
|
|
||||||
"id" => "ae9b8279-3959-48d8-8a88-741a7f6d4a48",
|
|
||||||
"name" => "progressive rock"
|
|
||||||
},
|
|
||||||
%{
|
|
||||||
"count" => 1,
|
|
||||||
"disambiguation" => "",
|
|
||||||
"id" => "2aeb5340-c474-4677-b9a6-35ddac9b6a58",
|
|
||||||
"name" => "psychedelic pop"
|
|
||||||
},
|
|
||||||
%{
|
|
||||||
"count" => 2,
|
|
||||||
"disambiguation" => "",
|
|
||||||
"id" => "0e3fc579-2d24-4f20-9dae-736e1ec78798",
|
|
||||||
"name" => "rock"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"id" => "20790e26-98e4-3ad3-a67f-b674758b942d",
|
|
||||||
"primary-type" => "Album",
|
|
||||||
"primary-type-id" => "f529b476-6e62-324f-b0aa-1f3e33d313fc",
|
|
||||||
"secondary-type-ids" => [],
|
|
||||||
"secondary-types" => [],
|
|
||||||
"title" => "Marbles"
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(APIBehaviourMock, :get_release_group, fn ^first_result_id ->
|
expect(APIBehaviourMock, :get_release_group, fn ^first_result_id ->
|
||||||
{:ok, release_group}
|
{:ok, release_group}
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
defmodule MusicLibrary.ReleaseGroupsFixtures do
|
||||||
|
def release_group_search_results do
|
||||||
|
[
|
||||||
|
%{
|
||||||
|
id: "20790e26-98e4-3ad3-a67f-b674758b942d",
|
||||||
|
type: :album,
|
||||||
|
title: "Marbles",
|
||||||
|
artists: "Marillion",
|
||||||
|
release: "2004-05-03"
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
id: "bf20ac32-a793-3bb4-beff-f7b9bffaca38",
|
||||||
|
type: :album,
|
||||||
|
title: "Marbles Live",
|
||||||
|
artists: "Marillion",
|
||||||
|
release: "2005-10-24"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def release_group_id do
|
||||||
|
release_group() |> Map.get("id")
|
||||||
|
end
|
||||||
|
|
||||||
|
def release_group do
|
||||||
|
%{
|
||||||
|
"artist-credit" => [
|
||||||
|
%{
|
||||||
|
"artist" => %{
|
||||||
|
"disambiguation" => "British progressive rock band",
|
||||||
|
"genres" => [
|
||||||
|
%{
|
||||||
|
"count" => 10,
|
||||||
|
"disambiguation" => "",
|
||||||
|
"id" => "ae9b8279-3959-48d8-8a88-741a7f6d4a48",
|
||||||
|
"name" => "progressive rock"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id" => "1932f5b6-0b7b-4050-b1df-833ca89e5f44",
|
||||||
|
"name" => "Marillion",
|
||||||
|
"sort-name" => "Marillion",
|
||||||
|
"type" => "Group",
|
||||||
|
"type-id" => "e431f5f6-b5d2-343d-8b36-72607fffb74b"
|
||||||
|
},
|
||||||
|
"joinphrase" => "",
|
||||||
|
"name" => "Marillion"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"disambiguation" => "",
|
||||||
|
"first-release-date" => "2004-05-03",
|
||||||
|
"genres" => [
|
||||||
|
%{
|
||||||
|
"count" => 1,
|
||||||
|
"disambiguation" => "",
|
||||||
|
"id" => "ceeaa283-5d7b-4202-8d1d-e25d116b2a18",
|
||||||
|
"name" => "alternative rock"
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
"count" => 1,
|
||||||
|
"disambiguation" => "",
|
||||||
|
"id" => "b7ef058e-6d83-4ca4-8123-9724bff4648b",
|
||||||
|
"name" => "art rock"
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
"count" => 1,
|
||||||
|
"disambiguation" => "",
|
||||||
|
"id" => "150eb95a-7739-4fde-a5fe-b62ca576a928",
|
||||||
|
"name" => "baroque pop"
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
"count" => 1,
|
||||||
|
"disambiguation" => "",
|
||||||
|
"id" => "797e2e85-5ffd-495c-a757-8b4079052f0e",
|
||||||
|
"name" => "pop rock"
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
"count" => 2,
|
||||||
|
"disambiguation" => "",
|
||||||
|
"id" => "ae9b8279-3959-48d8-8a88-741a7f6d4a48",
|
||||||
|
"name" => "progressive rock"
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
"count" => 1,
|
||||||
|
"disambiguation" => "",
|
||||||
|
"id" => "2aeb5340-c474-4677-b9a6-35ddac9b6a58",
|
||||||
|
"name" => "psychedelic pop"
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
"count" => 2,
|
||||||
|
"disambiguation" => "",
|
||||||
|
"id" => "0e3fc579-2d24-4f20-9dae-736e1ec78798",
|
||||||
|
"name" => "rock"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id" => "20790e26-98e4-3ad3-a67f-b674758b942d",
|
||||||
|
"primary-type" => "Album",
|
||||||
|
"primary-type-id" => "f529b476-6e62-324f-b0aa-1f3e33d313fc",
|
||||||
|
"secondary-type-ids" => [],
|
||||||
|
"secondary-types" => [],
|
||||||
|
"title" => "Marbles"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user