Updated tests

This commit is contained in:
Kieran Eglin 2025-03-05 15:20:32 -08:00
parent cc6b91ba03
commit e84b1dc66d
No known key found for this signature in database
GPG key ID: 193984967FCF432D
8 changed files with 26 additions and 26 deletions

View file

@ -41,7 +41,7 @@ defmodule Pinchflat.Sources do
case source.cookie_behaviour do
:disabled -> false
:all_operations -> true
:indexing_only -> operation == :indexing
:when_needed -> operation == :indexing
end
end

View file

@ -86,13 +86,13 @@
help="Unchecking still indexes media but it won't be downloaded until you enable this option"
/>
<.input
field={f[:cookie_behaviour]}
options={friendly_cookie_behaviours()}
type="select"
label="Cookie Behaviour"
help="Uses your YouTube cookies for this source (if configured). 'When Needed' tries to minimize cookie usage except for certain indexing and downloading tasks. See docs"
/>
<.input
field={f[:cookie_behaviour]}
options={friendly_cookie_behaviours()}
type="select"
label="Cookie Behaviour"
help="Uses your YouTube cookies for this source (if configured). 'When Needed' tries to minimize cookie usage except for certain indexing and downloading tasks. See docs"
/>
<section x-show="advancedMode">
<.input

View file

@ -163,7 +163,7 @@ defmodule Pinchflat.Downloading.MediaDownloaderTest do
assert {:ok, _} = MediaDownloader.download_for_media_item(media_item)
end
test "does not set use_cookies if the source only uses cookies when indexing" do
test "does not set use_cookies if the source uses cookies when needed" do
expect(YtDlpRunnerMock, :run, 3, fn
_url, :get_downloadable_status, _opts, _ot, addl ->
assert {:use_cookies, false} in addl
@ -177,7 +177,7 @@ defmodule Pinchflat.Downloading.MediaDownloaderTest do
{:ok, ""}
end)
source = source_fixture(%{cookie_behaviour: :indexing_only})
source = source_fixture(%{cookie_behaviour: :when_needed})
media_item = media_item_fixture(%{source_id: source.id})
assert {:ok, _} = MediaDownloader.download_for_media_item(media_item)

View file

@ -167,7 +167,7 @@ defmodule Pinchflat.FastIndexing.FastIndexingHelpersTest do
assert [%MediaItem{}] = FastIndexingHelpers.index_and_kickoff_downloads(source)
end
test "does not set use_cookies if the source only uses cookies when indexing" do
test "does not set use_cookies if the source uses cookies when needed" do
expect(HTTPClientMock, :get, fn _url -> {:ok, "<yt:videoId>test_1</yt:videoId>"} end)
stub(YtDlpRunnerMock, :run, fn _url, :get_media_attributes, _opts, _ot, addl ->
@ -176,7 +176,7 @@ defmodule Pinchflat.FastIndexing.FastIndexingHelpersTest do
{:ok, media_attributes_return_fixture()}
end)
source = source_fixture(%{cookie_behaviour: :indexing_only})
source = source_fixture(%{cookie_behaviour: :when_needed})
assert [%MediaItem{}] = FastIndexingHelpers.index_and_kickoff_downloads(source)
end

View file

@ -110,13 +110,13 @@ defmodule Pinchflat.Metadata.MetadataFileHelpersTest do
Helpers.download_and_store_thumbnail_for(media_item)
end
test "does not set use_cookies if the source only uses cookies when indexing" do
test "does not set use_cookies if the source uses cookies when needed" do
expect(YtDlpRunnerMock, :run, fn _url, :download_thumbnail, _opts, _ot, addl ->
assert {:use_cookies, false} in addl
{:ok, ""}
end)
source = source_fixture(%{cookie_behaviour: :indexing_only})
source = source_fixture(%{cookie_behaviour: :when_needed})
media_item = Repo.preload(media_item_fixture(%{source_id: source.id}), :source)
Helpers.download_and_store_thumbnail_for(media_item)

View file

@ -259,7 +259,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
perform_job(SourceMetadataStorageWorker, %{id: source.id})
end
test "does not set use_cookies if the source only uses cookies when indexing" do
test "does not set use_cookies if the source uses cookies when needed" do
expect(YtDlpRunnerMock, :run, 2, fn
_url, :get_source_details, _opts, _ot, _addl ->
{:ok, source_details_return_fixture()}
@ -270,7 +270,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
end)
profile = media_profile_fixture(%{download_source_images: true})
source = source_fixture(media_profile_id: profile.id, cookie_behaviour: :indexing_only)
source = source_fixture(media_profile_id: profile.id, cookie_behaviour: :when_needed)
perform_job(SourceMetadataStorageWorker, %{id: source.id})
end
@ -343,7 +343,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
perform_job(SourceMetadataStorageWorker, %{id: source.id})
end
test "does not set use_cookies if the source only uses cookies when indexing" do
test "does not set use_cookies if the source uses cookies when needed" do
expect(YtDlpRunnerMock, :run, 2, fn
_url, :get_source_details, _opts, _ot, addl ->
assert {:use_cookies, false} in addl
@ -353,7 +353,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
{:ok, "{}"}
end)
source = source_fixture(%{series_directory: nil, cookie_behaviour: :indexing_only})
source = source_fixture(%{series_directory: nil, cookie_behaviour: :when_needed})
perform_job(SourceMetadataStorageWorker, %{id: source.id})
end

View file

@ -316,13 +316,13 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do
SlowIndexingHelpers.index_and_enqueue_download_for_media_items(source)
end
test "sets use_cookies if the source only uses cookies when indexing" do
test "sets use_cookies if the source uses cookies when needed" do
expect(YtDlpRunnerMock, :run, fn _url, :get_media_attributes_for_collection, _opts, _ot, addl_opts ->
assert {:use_cookies, true} in addl_opts
{:ok, source_attributes_return_fixture()}
end)
source = source_fixture(%{cookie_behaviour: :indexing_only})
source = source_fixture(%{cookie_behaviour: :when_needed})
SlowIndexingHelpers.index_and_enqueue_download_for_media_items(source)
end

View file

@ -71,13 +71,13 @@ defmodule Pinchflat.SourcesTest do
refute Sources.use_cookies?(source, :downloading)
end
test "returns true if the action is indexing and the source is set to :indexing_only" do
source = source_fixture(%{cookie_behaviour: :indexing_only})
test "returns true if the action is indexing and the source is set to :when_needed" do
source = source_fixture(%{cookie_behaviour: :when_needed})
assert Sources.use_cookies?(source, :indexing)
end
test "returns false if the action is downloading and the source is set to :indexing_only" do
source = source_fixture(%{cookie_behaviour: :indexing_only})
test "returns false if the action is downloading and the source is set to :when_needed" do
source = source_fixture(%{cookie_behaviour: :when_needed})
refute Sources.use_cookies?(source, :downloading)
end
end
@ -421,7 +421,7 @@ defmodule Pinchflat.SourcesTest do
assert {:ok, %Source{}} = Sources.create_source(valid_attrs)
end
test "does not set use_cookies if the source only uses cookies when indexing" do
test "does not set use_cookies if the source uses cookies when needed" do
expect(YtDlpRunnerMock, :run, fn _url, :get_source_details, _opts, _ot, addl ->
refute Keyword.get(addl, :use_cookies)
@ -431,7 +431,7 @@ defmodule Pinchflat.SourcesTest do
valid_attrs = %{
media_profile_id: media_profile_fixture().id,
original_url: "https://www.youtube.com/channel/abc123",
cookie_behaviour: :indexing_only
cookie_behaviour: :when_needed
}
assert {:ok, %Source{}} = Sources.create_source(valid_attrs)