Namespace MusicBrainz fixtures
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
defmodule MusicLibrary.Records.RecordTest do
|
defmodule MusicLibrary.Records.RecordTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: true
|
||||||
|
|
||||||
import MusicLibrary.ReleaseGroupsFixtures
|
import MusicLibrary.Fixtures.ReleaseGroup
|
||||||
alias MusicLibrary.Records.Record
|
alias MusicLibrary.Records.Record
|
||||||
|
|
||||||
doctest Record
|
doctest Record
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ defmodule MusicLibrary.RecordsTest do
|
|||||||
alias MusicLibrary.Records.SearchIndex
|
alias MusicLibrary.Records.SearchIndex
|
||||||
alias MusicBrainz.APIBehaviourMock
|
alias MusicBrainz.APIBehaviourMock
|
||||||
import MusicLibrary.RecordsFixtures
|
import MusicLibrary.RecordsFixtures
|
||||||
import MusicLibrary.ReleaseGroupsFixtures
|
import MusicLibrary.Fixtures.ReleaseGroup
|
||||||
import MusicBrainz.Fixtures.Release
|
import MusicBrainz.Fixtures.Release
|
||||||
import Mox
|
import Mox
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
|||||||
use MusicLibraryWeb.ConnCase
|
use MusicLibraryWeb.ConnCase
|
||||||
|
|
||||||
import MusicLibrary.RecordsFixtures
|
import MusicLibrary.RecordsFixtures
|
||||||
import MusicLibrary.ReleaseGroupsFixtures
|
import MusicLibrary.Fixtures.ReleaseGroup
|
||||||
import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1]
|
import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1]
|
||||||
import Mox
|
import Mox
|
||||||
alias MusicLibrary.Records.{Cover, Record}
|
alias MusicLibrary.Records.{Cover, Record}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ defmodule MusicLibraryWeb.StatsLive.IndexTest do
|
|||||||
alias MusicBrainz.APIBehaviourMock
|
alias MusicBrainz.APIBehaviourMock
|
||||||
import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1]
|
import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1]
|
||||||
import MusicLibrary.RecordsFixtures
|
import MusicLibrary.RecordsFixtures
|
||||||
import MusicLibrary.ReleaseGroupsFixtures
|
import MusicLibrary.Fixtures.ReleaseGroup
|
||||||
|
import MusicBrainz.Fixtures.Release
|
||||||
import Mox
|
import Mox
|
||||||
|
|
||||||
setup :verify_on_exit!
|
setup :verify_on_exit!
|
||||||
|
|||||||
@@ -7,4 +7,20 @@ defmodule MusicBrainz.Fixtures.Release do
|
|||||||
|> Jason.decode!()
|
|> Jason.decode!()
|
||||||
|> Map.get("releases")
|
|> Map.get("releases")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def release(:mystery_of_time) do
|
||||||
|
Path.join([@fixtures_folder, "release - avantasia - the mystery of time.json"])
|
||||||
|
|> File.read!()
|
||||||
|
|> JSON.decode!()
|
||||||
|
end
|
||||||
|
|
||||||
|
def release(:marbles) do
|
||||||
|
Path.join([@fixtures_folder, "release - marillion - marbles.json"])
|
||||||
|
|> File.read!()
|
||||||
|
|> JSON.decode!()
|
||||||
|
end
|
||||||
|
|
||||||
|
def release_id(name) do
|
||||||
|
release(name) |> Map.get("id")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+2
-18
@@ -1,5 +1,5 @@
|
|||||||
defmodule MusicLibrary.ReleaseGroupsFixtures do
|
defmodule MusicLibrary.Fixtures.ReleaseGroup do
|
||||||
@fixtures_folder Path.join([File.cwd!(), "test/support/fixtures"])
|
@fixtures_folder Path.join([File.cwd!(), "test/support/fixtures/music_brainz"])
|
||||||
|
|
||||||
alias MusicBrainz.ReleaseGroupSearchResult
|
alias MusicBrainz.ReleaseGroupSearchResult
|
||||||
|
|
||||||
@@ -43,23 +43,7 @@ defmodule MusicLibrary.ReleaseGroupsFixtures do
|
|||||||
|> JSON.decode!()
|
|> JSON.decode!()
|
||||||
end
|
end
|
||||||
|
|
||||||
def release(:mystery_of_time) do
|
|
||||||
Path.join([@fixtures_folder, "release - avantasia - the mystery of time.json"])
|
|
||||||
|> File.read!()
|
|
||||||
|> JSON.decode!()
|
|
||||||
end
|
|
||||||
|
|
||||||
def release(:marbles) do
|
|
||||||
Path.join([@fixtures_folder, "release - marillion - marbles.json"])
|
|
||||||
|> File.read!()
|
|
||||||
|> JSON.decode!()
|
|
||||||
end
|
|
||||||
|
|
||||||
def release_group_id(name) do
|
def release_group_id(name) do
|
||||||
release_group(name) |> Map.get("id")
|
release_group(name) |> Map.get("id")
|
||||||
end
|
end
|
||||||
|
|
||||||
def release_id(name) do
|
|
||||||
release(name) |> Map.get("id")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@ -5,7 +5,7 @@ defmodule MusicLibrary.RecordsFixtures do
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
alias MusicLibrary.Records.Record
|
alias MusicLibrary.Records.Record
|
||||||
alias MusicLibrary.ReleaseGroupsFixtures
|
alias MusicLibrary.Fixtures.ReleaseGroup
|
||||||
|
|
||||||
@genres [
|
@genres [
|
||||||
"progressive rock",
|
"progressive rock",
|
||||||
@@ -62,7 +62,7 @@ defmodule MusicLibrary.RecordsFixtures do
|
|||||||
cover_url: "https://coverartarchive.org/release-group/#{record_musicbrainz_id}/front",
|
cover_url: "https://coverartarchive.org/release-group/#{record_musicbrainz_id}/front",
|
||||||
cover_data: File.read!(@marbles_cover_data_path),
|
cover_data: File.read!(@marbles_cover_data_path),
|
||||||
musicbrainz_id: record_musicbrainz_id,
|
musicbrainz_id: record_musicbrainz_id,
|
||||||
musicbrainz_data: ReleaseGroupsFixtures.release_group(:marbles),
|
musicbrainz_data: ReleaseGroup.release_group(:marbles),
|
||||||
title: Enum.random(@titles),
|
title: Enum.random(@titles),
|
||||||
type: :album,
|
type: :album,
|
||||||
format: Record.formats() |> Enum.random(),
|
format: Record.formats() |> Enum.random(),
|
||||||
|
|||||||
Reference in New Issue
Block a user