|
|
@ -118,7 +118,8 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
bids,
|
|
|
|
bids,
|
|
|
|
author_roles,
|
|
|
|
author_roles,
|
|
|
|
publisher.id,
|
|
|
|
publisher.id,
|
|
|
|
nil
|
|
|
|
nil,
|
|
|
|
|
|
|
|
actor: user
|
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -146,7 +147,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book)
|
|
|
|
assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book)
|
|
|
|
assert alternatives_names = []
|
|
|
|
assert ^alternatives_names = []
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
test "book has related book so they has one alternative name", %{user: user} do
|
|
|
|
test "book has related book so they has one alternative name", %{user: user} do
|
|
|
@ -187,7 +188,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book)
|
|
|
|
assert {:ok, alternatives_names} = Metadata.get_book_alternative_editions(book)
|
|
|
|
assert alternatives_names = [related_book]
|
|
|
|
assert get_ids(alternatives_names) == [related_book.id]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -201,7 +202,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
%{order: 1, author_id: author.id, role: ""}
|
|
|
|
%{order: 1, author_id: author.id, role: ""}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, book} =
|
|
|
|
{:ok, _book} =
|
|
|
|
Metadata.create_book(
|
|
|
|
Metadata.create_book(
|
|
|
|
"Book",
|
|
|
|
"Book",
|
|
|
|
"An description",
|
|
|
|
"An description",
|
|
|
@ -217,7 +218,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
actor: user
|
|
|
|
actor: user
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert {:ok, books} = Metadata.get_author_books(author)
|
|
|
|
assert {:ok, _books} = Metadata.get_author_books(author)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
test "get the list contains aliases' books", %{user: user} do
|
|
|
|
test "get the list contains aliases' books", %{user: user} do
|
|
|
@ -256,7 +257,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
describe "get a book by book id" do
|
|
|
|
describe "get a book by book id" do
|
|
|
|
test "get by bid", %{user: user} do
|
|
|
|
test "get by bid" do
|
|
|
|
expected_book = generate(book())
|
|
|
|
expected_book = generate(book())
|
|
|
|
|
|
|
|
|
|
|
|
[%Metadata.BookId{type: type, bid: bid} | _] = expected_book.bids
|
|
|
|
[%Metadata.BookId{type: type, bid: bid} | _] = expected_book.bids
|
|
|
|