defmodule Medicode.CodeFeedbacksFixtures do | |
@moduledoc """ | |
This module defines test helpers for creating %CodeFeedback{} | |
entities via the `Medicode.Feedback` context. | |
""" | |
import Medicode.AccountsFixtures | |
import Medicode.CodeVectorsFixtures | |
@doc """ | |
Generate a code feedback. | |
""" | |
def code_feedback_fixture(attrs \\ %{}) do | |
user_id = | |
cond do | |
Map.has_key?(attrs, :user_id) -> attrs.user_id | |
Map.has_key?(attrs, :user) -> attrs.user | |
true -> user_fixture().id | |
end | |
code_vector = | |
cond do | |
Map.has_key?(attrs, :code_vector) -> attrs.code_vector | |
true -> code_vector_fixture() | |
end | |
# NOTE: The text and text_vector values are inaccurate. The text_vector | |
# value does not represent the text value. | |
attrs | |
|> Enum.into(%{ | |
user_id: user_id, | |
code_vector_id: code_vector.id, | |
response: true, | |
text: "My code vector text", | |
text_vector: code_vector.description_vector | |
}) | |
|> Medicode.Feedback.insert_and_return() | |
end | |
end | |