* Updated package.json (and made an excuse to make a branch) * Video filepath parser (#6) * Restructured files; Added parser placeholder * More restructuring * Added basic parser for hydrating template strings * Improved docs * More docs * Initial implementation of media profiles (#7) * [WIP] Added basic video download method * [WIP] Very-WIP first steps at parsing options and downloading * Made my options safe by default and removed special safe versions * Ran html generator for mediaprofile model - leaving as-is for now * Addressed a bunch of TODO comments * Add "channel" type Media Source (#8) * [WIP] Working on fetching channel metadata in yt-dlp backend * Finished first draft of methods to do with querying channels * Renamed CommandRunnerMock to have a more descriptive name * Ran the phx generator for the channel model * Renamed Downloader namespace to MediaClient * [WIP] saving before attempting LiveView * LiveView did not work out but here's a working controller how about * Index a channel (#9) * Ran a MediaItem generator; Reformatted to my liking * [WIP] added basic index function * setup oban * Added basic Oban job for indexing * Added in workers for indexing; hooked them into record creation flow * Added a task model with a phx generator * Tied together tasks with jobs and channels * Download indexed videos (#10) * 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 * Ran linting
78 lines
2.6 KiB
Elixir
78 lines
2.6 KiB
Elixir
defmodule Pinchflat.ProfilesTest do
|
|
use Pinchflat.DataCase
|
|
|
|
alias Pinchflat.Profiles
|
|
alias Pinchflat.Profiles.MediaProfile
|
|
import Pinchflat.ProfilesFixtures
|
|
|
|
@invalid_attrs %{name: nil, output_path_template: nil}
|
|
|
|
describe "list_media_profiles/0" do
|
|
test "it returns all media_profiles" do
|
|
media_profile = media_profile_fixture()
|
|
assert Profiles.list_media_profiles() == [media_profile]
|
|
end
|
|
end
|
|
|
|
describe "get_media_profile!/1" do
|
|
test "it returns the media_profile with given id" do
|
|
media_profile = media_profile_fixture()
|
|
assert Profiles.get_media_profile!(media_profile.id) == media_profile
|
|
end
|
|
end
|
|
|
|
describe "create_media_profile/1" do
|
|
test "creation with valid data creates a media_profile" do
|
|
valid_attrs = %{name: "some name", output_path_template: "some output_path_template"}
|
|
|
|
assert {:ok, %MediaProfile{} = media_profile} = Profiles.create_media_profile(valid_attrs)
|
|
assert media_profile.name == "some name"
|
|
assert media_profile.output_path_template == "some output_path_template"
|
|
end
|
|
|
|
test "creation with invalid data returns error changeset" do
|
|
assert {:error, %Ecto.Changeset{}} = Profiles.create_media_profile(@invalid_attrs)
|
|
end
|
|
end
|
|
|
|
describe "update_media_profile/2" do
|
|
test "updating with valid data updates the media_profile" do
|
|
media_profile = media_profile_fixture()
|
|
|
|
update_attrs = %{
|
|
name: "some updated name",
|
|
output_path_template: "some updated output_path_template"
|
|
}
|
|
|
|
assert {:ok, %MediaProfile{} = media_profile} =
|
|
Profiles.update_media_profile(media_profile, update_attrs)
|
|
|
|
assert media_profile.name == "some updated name"
|
|
assert media_profile.output_path_template == "some updated output_path_template"
|
|
end
|
|
|
|
test "updating with invalid data returns error changeset" do
|
|
media_profile = media_profile_fixture()
|
|
|
|
assert {:error, %Ecto.Changeset{}} =
|
|
Profiles.update_media_profile(media_profile, @invalid_attrs)
|
|
|
|
assert media_profile == Profiles.get_media_profile!(media_profile.id)
|
|
end
|
|
end
|
|
|
|
describe "delete_media_profile/1" do
|
|
test "deletion deletes the media_profile" do
|
|
media_profile = media_profile_fixture()
|
|
assert {:ok, %MediaProfile{}} = Profiles.delete_media_profile(media_profile)
|
|
assert_raise Ecto.NoResultsError, fn -> Profiles.get_media_profile!(media_profile.id) end
|
|
end
|
|
end
|
|
|
|
describe "change_media_profile/1" do
|
|
test "it returns a media_profile changeset" do
|
|
media_profile = media_profile_fixture()
|
|
assert %Ecto.Changeset{} = Profiles.change_media_profile(media_profile)
|
|
end
|
|
end
|
|
end
|