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