Rename APIBehaviourMock -> APIMock
This commit is contained in:
@@ -4,7 +4,7 @@ defmodule LastFm.ConfigTest do
|
||||
describe "resolve/1" do
|
||||
test "reads data from application configuration" do
|
||||
assert %LastFm.Config{
|
||||
api: LastFm.APIBehaviourMock,
|
||||
api: LastFm.APIMock,
|
||||
api_key: api_key,
|
||||
user: user,
|
||||
auto_refresh: false,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule MusicBrainzTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias MusicBrainz.APIBehaviourMock
|
||||
alias MusicBrainz.APIMock
|
||||
import MusicLibrary.Fixtures.ReleaseGroup
|
||||
import Mox
|
||||
|
||||
@@ -11,9 +11,7 @@ defmodule MusicBrainzTest do
|
||||
test "it returns results with correct limit and offset" do
|
||||
mock_results = release_group_search_results()
|
||||
|
||||
expect(APIBehaviourMock, :search_release_group, fn "Marillion",
|
||||
[limit: 20, offset: 10],
|
||||
_config ->
|
||||
expect(APIMock, :search_release_group, fn "Marillion", [limit: 20, offset: 10], _config ->
|
||||
{:ok, mock_results}
|
||||
end)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ defmodule MusicLibrary.ArtistsTest do
|
||||
use MusicLibrary.DataCase
|
||||
|
||||
alias MusicLibrary.Artists
|
||||
alias LastFm.APIBehaviourMock
|
||||
alias LastFm.APIMock
|
||||
import MusicLibrary.Fixtures.Records
|
||||
import LastFm.Fixtures.Artist
|
||||
import Mox
|
||||
@@ -48,8 +48,7 @@ defmodule MusicLibrary.ArtistsTest do
|
||||
|
||||
expected_info = get_info()
|
||||
|
||||
expect(APIBehaviourMock, :get_artist_info, fn {:musicbrainz_id, ^artist_musicbrainz_id},
|
||||
_config ->
|
||||
expect(APIMock, :get_artist_info, fn {:musicbrainz_id, ^artist_musicbrainz_id}, _config ->
|
||||
{:ok, expected_info}
|
||||
end)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ defmodule MusicLibrary.RecordsTest do
|
||||
|
||||
alias MusicLibrary.Records
|
||||
alias MusicLibrary.Records.SearchIndex
|
||||
alias MusicBrainz.APIBehaviourMock
|
||||
alias MusicBrainz.APIMock
|
||||
import MusicLibrary.Fixtures.Records
|
||||
import MusicLibrary.Fixtures.ReleaseGroup
|
||||
import MusicBrainz.Fixtures.Release
|
||||
@@ -63,11 +63,11 @@ defmodule MusicLibrary.RecordsTest do
|
||||
assert record.release_ids == []
|
||||
assert record.included_release_group_ids == []
|
||||
|
||||
expect(APIBehaviourMock, :get_release_group, fn ^release_group_id, _config ->
|
||||
expect(APIMock, :get_release_group, fn ^release_group_id, _config ->
|
||||
{:ok, release_group(:lockdown_trilogy)}
|
||||
end)
|
||||
|
||||
expect(APIBehaviourMock, :get_releases, fn ^release_group_id, _opts, _config ->
|
||||
expect(APIMock, :get_releases, fn ^release_group_id, _opts, _config ->
|
||||
{:ok, %{"releases" => release_group(:lockdown_trilogy)["releases"]}}
|
||||
end)
|
||||
|
||||
@@ -189,17 +189,17 @@ defmodule MusicLibrary.RecordsTest do
|
||||
release_group = release_group(:marbles)
|
||||
release_group_id = release_group_id(:marbles)
|
||||
|
||||
expect(APIBehaviourMock, :get_release_group, fn ^release_group_id, _config ->
|
||||
expect(APIMock, :get_release_group, fn ^release_group_id, _config ->
|
||||
{:ok, release_group}
|
||||
end)
|
||||
|
||||
expect(APIBehaviourMock, :get_releases, fn ^release_group_id, _opts, _config ->
|
||||
expect(APIMock, :get_releases, fn ^release_group_id, _opts, _config ->
|
||||
{:ok, %{"releases" => release_group["releases"]}}
|
||||
end)
|
||||
|
||||
cover_data = File.read!(marbles_cover_fixture())
|
||||
|
||||
expect(APIBehaviourMock, :get_cover_art, fn {:musicbrainz_id, ^release_group_id}, _config ->
|
||||
expect(APIMock, :get_cover_art, fn {:musicbrainz_id, ^release_group_id}, _config ->
|
||||
{:ok, cover_data}
|
||||
end)
|
||||
|
||||
@@ -243,21 +243,21 @@ defmodule MusicLibrary.RecordsTest do
|
||||
release_group = release_group(:marbles)
|
||||
release_group_id = release_group_id(:marbles)
|
||||
|
||||
expect(APIBehaviourMock, :get_release, fn ^release_id, _config ->
|
||||
expect(APIMock, :get_release, fn ^release_id, _config ->
|
||||
{:ok, release}
|
||||
end)
|
||||
|
||||
expect(APIBehaviourMock, :get_release_group, fn ^release_group_id, _config ->
|
||||
expect(APIMock, :get_release_group, fn ^release_group_id, _config ->
|
||||
{:ok, release_group}
|
||||
end)
|
||||
|
||||
expect(APIBehaviourMock, :get_releases, fn ^release_group_id, _opts, _config ->
|
||||
expect(APIMock, :get_releases, fn ^release_group_id, _opts, _config ->
|
||||
{:ok, %{"releases" => release_group["releases"]}}
|
||||
end)
|
||||
|
||||
cover_data = File.read!(marbles_cover_fixture())
|
||||
|
||||
expect(APIBehaviourMock, :get_cover_art, fn {:musicbrainz_id, ^release_group_id}, _config ->
|
||||
expect(APIMock, :get_cover_art, fn {:musicbrainz_id, ^release_group_id}, _config ->
|
||||
{:ok, cover_data}
|
||||
end)
|
||||
|
||||
@@ -299,7 +299,7 @@ defmodule MusicLibrary.RecordsTest do
|
||||
|
||||
cover_url = record.cover_url
|
||||
|
||||
expect(APIBehaviourMock, :get_cover_art, fn {:url, ^cover_url}, _config ->
|
||||
expect(APIMock, :get_cover_art, fn {:url, ^cover_url}, _config ->
|
||||
{:ok, raven_cover_data}
|
||||
end)
|
||||
|
||||
@@ -317,7 +317,7 @@ defmodule MusicLibrary.RecordsTest do
|
||||
barcode = "5052205070023"
|
||||
releases = releases(:queen_greatest_hits)
|
||||
|
||||
expect(APIBehaviourMock, :search_release_by_barcode, fn ^barcode, _config ->
|
||||
expect(APIMock, :search_release_by_barcode, fn ^barcode, _config ->
|
||||
{:ok, releases}
|
||||
end)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ defmodule MusicLibraryWeb.ArtistLive.ShowTest do
|
||||
import LastFm.Fixtures.Artist
|
||||
import Mox
|
||||
|
||||
alias LastFm.APIBehaviourMock
|
||||
alias LastFm.APIMock
|
||||
|
||||
setup :verify_on_exit!
|
||||
|
||||
@@ -28,8 +28,7 @@ defmodule MusicLibraryWeb.ArtistLive.ShowTest do
|
||||
conn: conn,
|
||||
artist_musicbrainz_id: artist_musicbrainz_id
|
||||
} do
|
||||
expect(APIBehaviourMock, :get_artist_info, fn {:musicbrainz_id, ^artist_musicbrainz_id},
|
||||
_config ->
|
||||
expect(APIMock, :get_artist_info, fn {:musicbrainz_id, ^artist_musicbrainz_id}, _config ->
|
||||
{:ok, get_info()}
|
||||
end)
|
||||
|
||||
@@ -45,8 +44,7 @@ defmodule MusicLibraryWeb.ArtistLive.ShowTest do
|
||||
conn: conn,
|
||||
artist_musicbrainz_id: artist_musicbrainz_id
|
||||
} do
|
||||
expect(APIBehaviourMock, :get_artist_info, fn {:musicbrainz_id, ^artist_musicbrainz_id},
|
||||
_config ->
|
||||
expect(APIMock, :get_artist_info, fn {:musicbrainz_id, ^artist_musicbrainz_id}, _config ->
|
||||
{:error, :timeout}
|
||||
end)
|
||||
|
||||
@@ -74,8 +72,7 @@ defmodule MusicLibraryWeb.ArtistLive.ShowTest do
|
||||
record_with_artist("Porcupine Tree", %{purchased_at: DateTime.utc_now()})
|
||||
|
||||
# for this test, we don't care about the artist info, but we mock it to avoid false test failures
|
||||
expect(APIBehaviourMock, :get_artist_info, fn {:musicbrainz_id, ^artist_musicbrainz_id},
|
||||
_config ->
|
||||
expect(APIMock, :get_artist_info, fn {:musicbrainz_id, ^artist_musicbrainz_id}, _config ->
|
||||
{:error, :timeout}
|
||||
end)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1]
|
||||
import Mox
|
||||
alias MusicLibrary.Records.{Cover, Record}
|
||||
alias MusicBrainz.APIBehaviourMock
|
||||
alias MusicBrainz.APIMock
|
||||
|
||||
setup :verify_on_exit!
|
||||
|
||||
@@ -244,9 +244,9 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
test "it imports a record when selected", %{conn: conn} do
|
||||
mock_results = release_group_search_results()
|
||||
|
||||
expect(APIBehaviourMock, :search_release_group, fn "Marillion Marbles",
|
||||
[limit: 10, offset: 0],
|
||||
_config ->
|
||||
expect(APIMock, :search_release_group, fn "Marillion Marbles",
|
||||
[limit: 10, offset: 0],
|
||||
_config ->
|
||||
{:ok, mock_results}
|
||||
end)
|
||||
|
||||
@@ -267,17 +267,17 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
|
||||
release_group = release_group(:marbles)
|
||||
|
||||
expect(APIBehaviourMock, :get_release_group, fn ^first_result_id, _config ->
|
||||
expect(APIMock, :get_release_group, fn ^first_result_id, _config ->
|
||||
{:ok, release_group}
|
||||
end)
|
||||
|
||||
expect(APIBehaviourMock, :get_releases, fn ^first_result_id, _opts, _config ->
|
||||
expect(APIMock, :get_releases, fn ^first_result_id, _opts, _config ->
|
||||
{:ok, %{"releases" => release_group["releases"]}}
|
||||
end)
|
||||
|
||||
cover_data = File.read!(marbles_cover_fixture())
|
||||
|
||||
expect(APIBehaviourMock, :get_cover_art, fn {:musicbrainz_id, ^first_result_id}, _config ->
|
||||
expect(APIMock, :get_cover_art, fn {:musicbrainz_id, ^first_result_id}, _config ->
|
||||
{:ok, cover_data}
|
||||
end)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ defmodule MusicLibraryWeb.StatsLive.IndexTest do
|
||||
use MusicLibraryWeb.ConnCase
|
||||
|
||||
alias MusicLibrary.{Records, Repo, Wishlist}
|
||||
alias MusicBrainz.APIBehaviourMock
|
||||
alias MusicBrainz.APIMock
|
||||
import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1]
|
||||
import MusicLibrary.Fixtures.Records
|
||||
import MusicLibrary.Fixtures.ReleaseGroup
|
||||
@@ -186,22 +186,22 @@ defmodule MusicLibraryWeb.StatsLive.IndexTest do
|
||||
release_group = release_group(:mystery_of_time)
|
||||
release_group_id = release_group_id(:mystery_of_time)
|
||||
|
||||
expect(APIBehaviourMock, :get_release, fn ^release_id, _config ->
|
||||
expect(APIMock, :get_release, fn ^release_id, _config ->
|
||||
{:ok, release}
|
||||
end)
|
||||
|
||||
expect(APIBehaviourMock, :get_release_group, fn ^release_group_id, _config ->
|
||||
expect(APIMock, :get_release_group, fn ^release_group_id, _config ->
|
||||
{:ok, release_group}
|
||||
end)
|
||||
|
||||
expect(APIBehaviourMock, :get_releases, fn ^release_group_id, _opts, _config ->
|
||||
expect(APIMock, :get_releases, fn ^release_group_id, _opts, _config ->
|
||||
{:ok, %{"releases" => release_group["releases"]}}
|
||||
end)
|
||||
|
||||
# Doesn't matter if we use a different cover
|
||||
cover_data = File.read!(marbles_cover_fixture())
|
||||
|
||||
expect(APIBehaviourMock, :get_cover_art, fn {:musicbrainz_id, ^release_group_id}, _config ->
|
||||
expect(APIMock, :get_cover_art, fn {:musicbrainz_id, ^release_group_id}, _config ->
|
||||
{:ok, cover_data}
|
||||
end)
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
Mox.defmock(MusicBrainz.APIBehaviourMock, for: MusicBrainz.APIBehaviour)
|
||||
Mox.defmock(MusicBrainz.APIMock, for: MusicBrainz.APIBehaviour)
|
||||
|
||||
music_brainz_config =
|
||||
Application.get_env(:music_library, MusicBrainz)
|
||||
|> Keyword.put(:api, MusicBrainz.APIBehaviourMock)
|
||||
|> Keyword.put(:api, MusicBrainz.APIMock)
|
||||
|
||||
Application.put_env(:music_library, MusicBrainz, music_brainz_config)
|
||||
|
||||
Mox.defmock(LastFm.APIBehaviourMock, for: LastFm.APIBehaviour)
|
||||
Mox.defmock(LastFm.APIMock, for: LastFm.APIBehaviour)
|
||||
|
||||
last_fm_config =
|
||||
Application.get_env(:music_library, LastFm)
|
||||
|> Keyword.put(:api, LastFm.APIBehaviourMock)
|
||||
|> Keyword.put(:api, LastFm.APIMock)
|
||||
|
||||
Application.put_env(:music_library, LastFm, last_fm_config)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user