defmodule MedicalTranscription.TranscriptionsFixtures do | |
@moduledoc """ | |
This module defines test helpers for creating | |
entities via the `MedicalTranscription.Transcriptions` context. | |
""" | |
import MedicalTranscription.AccountsFixtures | |
@doc """ | |
Generate a transcription. | |
""" | |
def transcription_fixture(attrs \\ %{}) do | |
user_id = | |
cond do | |
Map.has_key?(attrs, :user_id) -> attrs.user_id | |
Map.has_key?(attrs, :user) -> attrs.user.id | |
true -> user_fixture().id | |
end | |
{:ok, transcription} = | |
attrs | |
|> Enum.into(%{ | |
user_id: user_id, | |
filename: "some filename", | |
recording_length_in_seconds: 42 | |
}) | |
|> MedicalTranscription.Transcriptions.create_transcription() | |
transcription | |
end | |
end | |