* Clarified documentation * more comments * [WIP] hooked up basic video downloading; starting work on metadata * Added metadata model and parsing Adding the metadata model made me realize that, in many cases, yt-dlp returns undesired input in stdout, breaking parsing. In order to get the metadata model working, I had to change the way in which the app interacts with yt-dlp. Now, output is written as a file to disk which is immediately re-read and returned. * Added tests for video download worker * Hooked up video downloading to the channel indexing pipeline * Adds tasks for media items * Updated video metadata parser to extract the title
43 lines
866 B
Elixir
43 lines
866 B
Elixir
defmodule Pinchflat.TestingHelperMethods do
|
|
@moduledoc false
|
|
|
|
use ExUnit.CaseTemplate
|
|
|
|
def now do
|
|
DateTime.utc_now()
|
|
end
|
|
|
|
def now_plus(offset, unit) when unit in [:minute, :minutes] do
|
|
DateTime.add(now(), offset, :minute)
|
|
end
|
|
|
|
def assert_changed(checker_fun, action_fn) do
|
|
before_res = checker_fun.()
|
|
action_fn.()
|
|
after_res = checker_fun.()
|
|
|
|
assert before_res != after_res
|
|
end
|
|
|
|
def assert_changed([from: from, to: to], checker_fun, action_fn) do
|
|
before_res = checker_fun.()
|
|
action_fn.()
|
|
after_res = checker_fun.()
|
|
|
|
assert before_res == from
|
|
assert after_res == to
|
|
end
|
|
|
|
def render_metadata(metadata_name) do
|
|
json_filepath =
|
|
Path.join([
|
|
File.cwd!(),
|
|
"test",
|
|
"support",
|
|
"files",
|
|
"#{metadata_name}.json"
|
|
])
|
|
|
|
File.read!(json_filepath)
|
|
end
|
|
end
|