pinchflat/test/pinchflat_web/controllers/media_profile_controller_test.exs
Kieran a5e7c48f70
Download video(s) (first iteration) (#5)
* 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
2024-01-30 20:15:59 -08:00

90 lines
2.9 KiB
Elixir

defmodule PinchflatWeb.MediaProfileControllerTest do
use PinchflatWeb.ConnCase
import Pinchflat.ProfilesFixtures
@create_attrs %{name: "some name", output_path_template: "some output_path_template"}
@update_attrs %{
name: "some updated name",
output_path_template: "some updated output_path_template"
}
@invalid_attrs %{name: nil, output_path_template: nil}
describe "index" do
test "lists all media_profiles", %{conn: conn} do
conn = get(conn, ~p"/media_profiles")
assert html_response(conn, 200) =~ "Listing Media profiles"
end
end
describe "new media_profile" do
test "renders form", %{conn: conn} do
conn = get(conn, ~p"/media_profiles/new")
assert html_response(conn, 200) =~ "New Media profile"
end
end
describe "create media_profile" do
test "redirects to show when data is valid", %{conn: conn} do
conn = post(conn, ~p"/media_profiles", media_profile: @create_attrs)
assert %{id: id} = redirected_params(conn)
assert redirected_to(conn) == ~p"/media_profiles/#{id}"
conn = get(conn, ~p"/media_profiles/#{id}")
assert html_response(conn, 200) =~ "Media profile #{id}"
end
test "renders errors when data is invalid", %{conn: conn} do
conn = post(conn, ~p"/media_profiles", media_profile: @invalid_attrs)
assert html_response(conn, 200) =~ "New Media profile"
end
end
describe "edit media_profile" do
setup [:create_media_profile]
test "renders form for editing chosen media_profile", %{
conn: conn,
media_profile: media_profile
} do
conn = get(conn, ~p"/media_profiles/#{media_profile}/edit")
assert html_response(conn, 200) =~ "Edit Media profile"
end
end
describe "update media_profile" do
setup [:create_media_profile]
test "redirects when data is valid", %{conn: conn, media_profile: media_profile} do
conn = put(conn, ~p"/media_profiles/#{media_profile}", media_profile: @update_attrs)
assert redirected_to(conn) == ~p"/media_profiles/#{media_profile}"
conn = get(conn, ~p"/media_profiles/#{media_profile}")
assert html_response(conn, 200) =~ "some updated name"
end
test "renders errors when data is invalid", %{conn: conn, media_profile: media_profile} do
conn = put(conn, ~p"/media_profiles/#{media_profile}", media_profile: @invalid_attrs)
assert html_response(conn, 200) =~ "Edit Media profile"
end
end
describe "delete media_profile" do
setup [:create_media_profile]
test "deletes chosen media_profile", %{conn: conn, media_profile: media_profile} do
conn = delete(conn, ~p"/media_profiles/#{media_profile}")
assert redirected_to(conn) == ~p"/media_profiles"
assert_error_sent 404, fn ->
get(conn, ~p"/media_profiles/#{media_profile}")
end
end
end
defp create_media_profile(_) do
media_profile = media_profile_fixture()
%{media_profile: media_profile}
end
end