Can parse an obsidian entry to retrieve correct metadata
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
defmodule MusicLibrary.Records.ParserTest do
|
||||
use ExUnit.Case, async: true
|
||||
alias MusicLibrary.Records.{Parser, Record}
|
||||
|
||||
@obsidian_entry_path Path.expand("../../support/fixtures/marillion-marbles.md", __DIR__)
|
||||
|
||||
test "parses the content of the Obsidian album entry" do
|
||||
entry_contents = File.read!(@obsidian_entry_path)
|
||||
|
||||
assert Parser.from_entry_contents(entry_contents) ==
|
||||
{:ok,
|
||||
%Record{
|
||||
type: :album,
|
||||
musicbrainz_id: "20790e26-98e4-3ad3-a67f-b674758b942d",
|
||||
title: "Marbles",
|
||||
year: 2004,
|
||||
image:
|
||||
"https://coverartarchive.org/release-group/20790e26-98e4-3ad3-a67f-b674758b942d/front",
|
||||
genres: [
|
||||
"alternative rock",
|
||||
"art rock",
|
||||
"baroque pop",
|
||||
"pop rock",
|
||||
"progressive rock",
|
||||
"psychedelic pop",
|
||||
"rock"
|
||||
]
|
||||
}}
|
||||
end
|
||||
end
|
||||
@@ -8,7 +8,14 @@ defmodule MusicLibrary.RecordsTest do
|
||||
|
||||
import MusicLibrary.RecordsFixtures
|
||||
|
||||
@invalid_attrs %{type: nil, title: nil, image: nil, year: nil, musicbrainz_id: nil, genres: nil}
|
||||
@invalid_attrs %{
|
||||
type: nil,
|
||||
title: nil,
|
||||
image: nil,
|
||||
year: nil,
|
||||
musicbrainz_id: nil,
|
||||
genres: nil
|
||||
}
|
||||
|
||||
test "list_records/0 returns all records" do
|
||||
record = record_fixture()
|
||||
@@ -21,7 +28,14 @@ defmodule MusicLibrary.RecordsTest do
|
||||
end
|
||||
|
||||
test "create_record/1 with valid data creates a record" do
|
||||
valid_attrs = %{type: :album, title: "some title", image: "some image", year: 42, musicbrainz_id: "7488a646-e31f-11e4-aace-600308960662", genres: ["option1", "option2"]}
|
||||
valid_attrs = %{
|
||||
type: :album,
|
||||
title: "some title",
|
||||
image: "some image",
|
||||
year: 42,
|
||||
musicbrainz_id: "7488a646-e31f-11e4-aace-600308960662",
|
||||
genres: ["option1", "option2"]
|
||||
}
|
||||
|
||||
assert {:ok, %Record{} = record} = Records.create_record(valid_attrs)
|
||||
assert record.type == :album
|
||||
@@ -38,7 +52,15 @@ defmodule MusicLibrary.RecordsTest do
|
||||
|
||||
test "update_record/2 with valid data updates the record" do
|
||||
record = record_fixture()
|
||||
update_attrs = %{type: :ep, title: "some updated title", image: "some updated image", year: 43, musicbrainz_id: "7488a646-e31f-11e4-aace-600308960668", genres: ["option1"]}
|
||||
|
||||
update_attrs = %{
|
||||
type: :ep,
|
||||
title: "some updated title",
|
||||
image: "some updated image",
|
||||
year: 43,
|
||||
musicbrainz_id: "7488a646-e31f-11e4-aace-600308960668",
|
||||
genres: ["option1"]
|
||||
}
|
||||
|
||||
assert {:ok, %Record{} = record} = Records.update_record(record, update_attrs)
|
||||
assert record.type == :ep
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
type: musicRelease
|
||||
subType: Album
|
||||
title: Marbles
|
||||
englishTitle: Marbles
|
||||
year: 2004
|
||||
dataSource: MusicBrainz API
|
||||
url: https://musicbrainz.org/release-group/20790e26-98e4-3ad3-a67f-b674758b942d
|
||||
id: 20790e26-98e4-3ad3-a67f-b674758b942d
|
||||
genres:
|
||||
- alternative rock
|
||||
- art rock
|
||||
- baroque pop
|
||||
- pop rock
|
||||
- progressive rock
|
||||
- psychedelic pop
|
||||
- rock
|
||||
artists:
|
||||
- Marillion
|
||||
image: https://coverartarchive.org/release-group/20790e26-98e4-3ad3-a67f-b674758b942d/front
|
||||
rating: 8.8
|
||||
personalRating: 0
|
||||
tags:
|
||||
- mediaDB/music/Album
|
||||
---
|
||||
Reference in New Issue
Block a user