|
|
@ -138,5 +138,70 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.BookTransformerTest do
|
|
|
|
dbi_server_id: "889a323e-d104-4b5d-b276-dad5a9b1da99"
|
|
|
|
dbi_server_id: "889a323e-d104-4b5d-b276-dad5a9b1da99"
|
|
|
|
} = book
|
|
|
|
} = book
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "a json has dbi_server_id as nil, then book's map has not :dbi_server_id key" do
|
|
|
|
|
|
|
|
json_body = %{
|
|
|
|
|
|
|
|
"attributes" => %{
|
|
|
|
|
|
|
|
"dbi_server_id" => nil,
|
|
|
|
|
|
|
|
"cover_image_url" => "/images/book_cover.png",
|
|
|
|
|
|
|
|
"description" => "A cool book.",
|
|
|
|
|
|
|
|
"format" => "Paper",
|
|
|
|
|
|
|
|
"inserted_at" => "2025-03-20T14:44:36.162986Z",
|
|
|
|
|
|
|
|
"language" => "English",
|
|
|
|
|
|
|
|
"page_count" => 1000,
|
|
|
|
|
|
|
|
"published" => "2025-03-05",
|
|
|
|
|
|
|
|
"publisher_id" => "11349865-1b7b-454a-b999-6c4059888a78",
|
|
|
|
|
|
|
|
"title" => "Book",
|
|
|
|
|
|
|
|
"updated_at" => "2025-04-01T18:14:25.754055Z"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"id" => "1bbe8861-9d9d-4684-bda6-b6ec238d8d08",
|
|
|
|
|
|
|
|
"links" => %{},
|
|
|
|
|
|
|
|
"meta" => %{},
|
|
|
|
|
|
|
|
"relationships" => %{
|
|
|
|
|
|
|
|
"author_roles" => %{
|
|
|
|
|
|
|
|
"links" => %{
|
|
|
|
|
|
|
|
"related" =>
|
|
|
|
|
|
|
|
"http://localhost:4000/api/v1/json/books/1bbe8861-9d9d-4684-bda6-b6ec238d8d08/author_roles"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"meta" => %{}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"bids" => %{
|
|
|
|
|
|
|
|
"links" => %{
|
|
|
|
|
|
|
|
"related" =>
|
|
|
|
|
|
|
|
"http://localhost:4000/api/v1/json/books/1bbe8861-9d9d-4684-bda6-b6ec238d8d08/bids"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"meta" => %{}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"book_editions_registry" => %{"links" => %{}, "meta" => %{}},
|
|
|
|
|
|
|
|
"dbi_server" => %{"links" => %{}, "meta" => %{}},
|
|
|
|
|
|
|
|
"publisher" => %{
|
|
|
|
|
|
|
|
"links" => %{
|
|
|
|
|
|
|
|
"related" =>
|
|
|
|
|
|
|
|
"http://localhost:4000/api/v1/json/books/1bbe8861-9d9d-4684-bda6-b6ec238d8d08/publisher"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"meta" => %{}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"type" => "book"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert {:ok, book} = BookTransformer.from_json(json_body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert %{
|
|
|
|
|
|
|
|
id: "1bbe8861-9d9d-4684-bda6-b6ec238d8d08",
|
|
|
|
|
|
|
|
cover_image_url: "/images/book_cover.png",
|
|
|
|
|
|
|
|
description: "A cool book.",
|
|
|
|
|
|
|
|
format: "Paper",
|
|
|
|
|
|
|
|
inserted_at: "2025-03-20T14:44:36.162986Z",
|
|
|
|
|
|
|
|
language: "English",
|
|
|
|
|
|
|
|
page_count: 1000,
|
|
|
|
|
|
|
|
published: "2025-03-05",
|
|
|
|
|
|
|
|
publisher_id: "11349865-1b7b-454a-b999-6c4059888a78",
|
|
|
|
|
|
|
|
title: "Book",
|
|
|
|
|
|
|
|
updated_at: "2025-04-01T18:14:25.754055Z",
|
|
|
|
|
|
|
|
} = book
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refute Map.has_key?(book, :dbi_server_id)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|