|
|
@ -14,7 +14,22 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
bids = bids()
|
|
|
|
bids = bids()
|
|
|
|
publisher = generate(publisher())
|
|
|
|
publisher = generate(publisher())
|
|
|
|
|
|
|
|
|
|
|
|
assert {:ok, book} = Metadata.create_book("Book", "An description", "English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id, nil, nil, actor: user)
|
|
|
|
assert {:ok, book} =
|
|
|
|
|
|
|
|
Metadata.create_book(
|
|
|
|
|
|
|
|
"Book",
|
|
|
|
|
|
|
|
"An description",
|
|
|
|
|
|
|
|
"English",
|
|
|
|
|
|
|
|
"Paperback",
|
|
|
|
|
|
|
|
256,
|
|
|
|
|
|
|
|
~D[2025-03-04],
|
|
|
|
|
|
|
|
bids,
|
|
|
|
|
|
|
|
author_roles,
|
|
|
|
|
|
|
|
publisher.id,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
actor: user
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert book.book_editions_registry_id != nil
|
|
|
|
assert book.book_editions_registry_id != nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -24,7 +39,23 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
publisher = generate(publisher())
|
|
|
|
publisher = generate(publisher())
|
|
|
|
|
|
|
|
|
|
|
|
assert {:ok, registry} = Metadata.create_book_editions_registry(actor: user)
|
|
|
|
assert {:ok, registry} = Metadata.create_book_editions_registry(actor: user)
|
|
|
|
assert {:ok, book} = Metadata.create_book("Book", "An description","English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id, nil, registry.id, actor: user)
|
|
|
|
|
|
|
|
|
|
|
|
assert {:ok, book} =
|
|
|
|
|
|
|
|
Metadata.create_book(
|
|
|
|
|
|
|
|
"Book",
|
|
|
|
|
|
|
|
"An description",
|
|
|
|
|
|
|
|
"English",
|
|
|
|
|
|
|
|
"Paperback",
|
|
|
|
|
|
|
|
256,
|
|
|
|
|
|
|
|
~D[2025-03-04],
|
|
|
|
|
|
|
|
bids,
|
|
|
|
|
|
|
|
author_roles,
|
|
|
|
|
|
|
|
publisher.id,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
registry.id,
|
|
|
|
|
|
|
|
actor: user
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert book.book_editions_registry_id == registry.id
|
|
|
|
assert book.book_editions_registry_id == registry.id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -33,10 +64,37 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
bids = bids()
|
|
|
|
bids = bids()
|
|
|
|
publisher = generate(publisher())
|
|
|
|
publisher = generate(publisher())
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, related_book} = Metadata.create_book("Book", "An description", "English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id, nil, nil, actor: user)
|
|
|
|
{:ok, related_book} =
|
|
|
|
|
|
|
|
Metadata.create_book(
|
|
|
|
|
|
|
|
"Book",
|
|
|
|
|
|
|
|
"An description",
|
|
|
|
|
|
|
|
"English",
|
|
|
|
|
|
|
|
"Paperback",
|
|
|
|
|
|
|
|
256,
|
|
|
|
|
|
|
|
~D[2025-03-04],
|
|
|
|
|
|
|
|
bids,
|
|
|
|
|
|
|
|
author_roles,
|
|
|
|
|
|
|
|
publisher.id,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
actor: user
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert {:ok, book} =
|
|
|
|
assert {:ok, book} =
|
|
|
|
Metadata.add_book_to_related_editions_registry("Book2", "An description2", "English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id, related_book.id, nil, actor: user)
|
|
|
|
Metadata.add_book_to_related_editions_registry(
|
|
|
|
|
|
|
|
"Book2",
|
|
|
|
|
|
|
|
"An description2",
|
|
|
|
|
|
|
|
"English",
|
|
|
|
|
|
|
|
"Paperback",
|
|
|
|
|
|
|
|
256,
|
|
|
|
|
|
|
|
~D[2025-03-04],
|
|
|
|
|
|
|
|
bids,
|
|
|
|
|
|
|
|
author_roles,
|
|
|
|
|
|
|
|
publisher.id,
|
|
|
|
|
|
|
|
related_book.id,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
actor: user
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert related_book.book_editions_registry_id == book.book_editions_registry_id
|
|
|
|
assert related_book.book_editions_registry_id == book.book_editions_registry_id
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -47,7 +105,18 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
publisher = generate(publisher())
|
|
|
|
publisher = generate(publisher())
|
|
|
|
|
|
|
|
|
|
|
|
assert {:error, _} =
|
|
|
|
assert {:error, _} =
|
|
|
|
Metadata.add_book_to_related_editions_registry("Book2", "An description2", "English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id, nil)
|
|
|
|
Metadata.add_book_to_related_editions_registry(
|
|
|
|
|
|
|
|
"Book2",
|
|
|
|
|
|
|
|
"An description2",
|
|
|
|
|
|
|
|
"English",
|
|
|
|
|
|
|
|
"Paperback",
|
|
|
|
|
|
|
|
256,
|
|
|
|
|
|
|
|
~D[2025-03-04],
|
|
|
|
|
|
|
|
bids,
|
|
|
|
|
|
|
|
author_roles,
|
|
|
|
|
|
|
|
publisher.id,
|
|
|
|
|
|
|
|
nil
|
|
|
|
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -57,7 +126,22 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
bids = bids()
|
|
|
|
bids = bids()
|
|
|
|
publisher = generate(publisher())
|
|
|
|
publisher = generate(publisher())
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, book} = Metadata.create_book("Book", "An description", "English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id, nil, nil, actor: user)
|
|
|
|
{:ok, book} =
|
|
|
|
|
|
|
|
Metadata.create_book(
|
|
|
|
|
|
|
|
"Book",
|
|
|
|
|
|
|
|
"An description",
|
|
|
|
|
|
|
|
"English",
|
|
|
|
|
|
|
|
"Paperback",
|
|
|
|
|
|
|
|
256,
|
|
|
|
|
|
|
|
~D[2025-03-04],
|
|
|
|
|
|
|
|
bids,
|
|
|
|
|
|
|
|
author_roles,
|
|
|
|
|
|
|
|
publisher.id,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
actor: user
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
@ -67,10 +151,37 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
bids = bids()
|
|
|
|
bids = bids()
|
|
|
|
publisher = generate(publisher())
|
|
|
|
publisher = generate(publisher())
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, related_book} = Metadata.create_book("Book", "An description", "English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id, nil, nil, actor: user)
|
|
|
|
{:ok, related_book} =
|
|
|
|
|
|
|
|
Metadata.create_book(
|
|
|
|
|
|
|
|
"Book",
|
|
|
|
|
|
|
|
"An description",
|
|
|
|
|
|
|
|
"English",
|
|
|
|
|
|
|
|
"Paperback",
|
|
|
|
|
|
|
|
256,
|
|
|
|
|
|
|
|
~D[2025-03-04],
|
|
|
|
|
|
|
|
bids,
|
|
|
|
|
|
|
|
author_roles,
|
|
|
|
|
|
|
|
publisher.id,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
actor: user
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, book} =
|
|
|
|
{:ok, book} =
|
|
|
|
Metadata.add_book_to_related_editions_registry("Book2", "An description2", "English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id, related_book.id, nil, actor: user)
|
|
|
|
Metadata.add_book_to_related_editions_registry(
|
|
|
|
|
|
|
|
"Book2",
|
|
|
|
|
|
|
|
"An description2",
|
|
|
|
|
|
|
|
"English",
|
|
|
|
|
|
|
|
"Paperback",
|
|
|
|
|
|
|
|
256,
|
|
|
|
|
|
|
|
~D[2025-03-04],
|
|
|
|
|
|
|
|
bids,
|
|
|
|
|
|
|
|
author_roles,
|
|
|
|
|
|
|
|
publisher.id,
|
|
|
|
|
|
|
|
related_book.id,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
actor: user
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
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 alternatives_names = [related_book]
|
|
|
@ -87,17 +198,45 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|
|
|
%{order: 1, author_id: author.id, role: ""}
|
|
|
|
%{order: 1, author_id: author.id, role: ""}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, book} = Metadata.create_book("Book", "An description", "English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id, nil, nil, actor: user)
|
|
|
|
{:ok, book} =
|
|
|
|
|
|
|
|
Metadata.create_book(
|
|
|
|
|
|
|
|
"Book",
|
|
|
|
|
|
|
|
"An description",
|
|
|
|
|
|
|
|
"English",
|
|
|
|
|
|
|
|
"Paperback",
|
|
|
|
|
|
|
|
256,
|
|
|
|
|
|
|
|
~D[2025-03-04],
|
|
|
|
|
|
|
|
bids,
|
|
|
|
|
|
|
|
author_roles,
|
|
|
|
|
|
|
|
publisher.id,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
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
|
|
|
|
{:ok, author} = Metadata.create_author("Author", "An description", nil, nil, actor: user)
|
|
|
|
{:ok, author} = Metadata.create_author("Author", "An description", nil, nil, actor: user)
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, alias1} =
|
|
|
|
{:ok, alias1} =
|
|
|
|
Metadata.add_author_to_related_alias_registry("Author2", "An description2", author.id, nil, actor: user)
|
|
|
|
Metadata.add_author_to_related_alias_registry(
|
|
|
|
|
|
|
|
"Author2",
|
|
|
|
|
|
|
|
"An description2",
|
|
|
|
|
|
|
|
author.id,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
actor: user
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, alias2} =
|
|
|
|
{:ok, alias2} =
|
|
|
|
Metadata.add_author_to_related_alias_registry("Author3", "An description3", author.id, nil, actor: user)
|
|
|
|
Metadata.add_author_to_related_alias_registry(
|
|
|
|
|
|
|
|
"Author3",
|
|
|
|
|
|
|
|
"An description3",
|
|
|
|
|
|
|
|
author.id,
|
|
|
|
|
|
|
|
nil,
|
|
|
|
|
|
|
|
actor: user
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
book = generate(book(authors: [author]))
|
|
|
|
book = generate(book(authors: [author]))
|
|
|
|
book2 = generate(book(authors: [alias1]))
|
|
|
|
book2 = generate(book(authors: [alias1]))
|
|
|
|