Updated tests

This commit is contained in:
Kieran Eglin 2024-08-20 09:25:58 -07:00
parent bdd8f15244
commit 712d997b15
No known key found for this signature in database
GPG key ID: 193984967FCF432D
6 changed files with 15 additions and 12 deletions

View file

@ -101,7 +101,7 @@ defmodule Pinchflat.FastIndexing.FastIndexingHelpersTest do
id: "video2", id: "video2",
title: "Video 2", title: "Video 2",
webpage_url: "https://example.com/shorts/video2", webpage_url: "https://example.com/shorts/video2",
was_live: true, live_status: "is_live",
description: "desc2", description: "desc2",
aspect_ratio: 1.67, aspect_ratio: 1.67,
duration: 345.67, duration: 345.67,

View file

@ -43,11 +43,12 @@ defmodule Pinchflat.Metadata.MetadataParserTest do
test "it extracts the livestream flag", %{metadata: metadata} do test "it extracts the livestream flag", %{metadata: metadata} do
result = Parser.parse_for_media_item(metadata) result = Parser.parse_for_media_item(metadata)
assert result.livestream == metadata["was_live"] assert metadata["live_status"] == "not_live"
refute result.livestream
end end
test "the livestream flag defaults to false", %{metadata: metadata} do test "the livestream flag defaults to false", %{metadata: metadata} do
metadata = Map.put(metadata, "was_live", nil) metadata = Map.put(metadata, "live_status", nil)
result = Parser.parse_for_media_item(metadata) result = Parser.parse_for_media_item(metadata)

View file

@ -173,7 +173,7 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do
Phoenix.json_library().encode!(%{ Phoenix.json_library().encode!(%{
id: "video3", id: "video3",
title: "Video 3", title: "Video 3",
was_live: false, live_status: "not_live",
description: "desc3", description: "desc3",
# Only focusing on these because these are passed to functions that # Only focusing on these because these are passed to functions that
# could fail if they're not present # could fail if they're not present
@ -289,7 +289,7 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do
id: "video2", id: "video2",
title: "Video 2", title: "Video 2",
webpage_url: "https://example.com/shorts/video2", webpage_url: "https://example.com/shorts/video2",
was_live: true, live_status: "is_live",
description: "desc2", description: "desc2",
aspect_ratio: 1.67, aspect_ratio: 1.67,
duration: 345.67, duration: 345.67,

View file

@ -138,7 +138,9 @@ defmodule Pinchflat.YtDlp.MediaTest do
describe "indexing_output_template/0" do describe "indexing_output_template/0" do
test "contains all the greatest hits" do test "contains all the greatest hits" do
attrs = ~w(id title was_live webpage_url description aspect_ratio duration upload_date timestamp playlist_index)a attrs =
~w(id title live_status webpage_url description aspect_ratio duration upload_date timestamp playlist_index)a
formatted_attrs = "%(.{#{Enum.join(attrs, ",")}})j" formatted_attrs = "%(.{#{Enum.join(attrs, ",")}})j"
assert formatted_attrs == Media.indexing_output_template() assert formatted_attrs == Media.indexing_output_template()
@ -152,7 +154,7 @@ defmodule Pinchflat.YtDlp.MediaTest do
"title" => "Trying to Wheelie Without the Rear Brake", "title" => "Trying to Wheelie Without the Rear Brake",
"description" => "I'm not sure what I expected.", "description" => "I'm not sure what I expected.",
"webpage_url" => "https://www.youtube.com/watch?v=TiZPUDkDYbk", "webpage_url" => "https://www.youtube.com/watch?v=TiZPUDkDYbk",
"was_live" => false, "live_status" => "not_live",
"aspect_ratio" => 1.0, "aspect_ratio" => 1.0,
"duration" => 60, "duration" => 60,
"upload_date" => "20210101", "upload_date" => "20210101",
@ -239,7 +241,7 @@ defmodule Pinchflat.YtDlp.MediaTest do
assert %Media{duration_seconds: nil} = Media.response_to_struct(response) assert %Media{duration_seconds: nil} = Media.response_to_struct(response)
end end
test "sets livestream to false if the was_live field isn't present" do test "sets livestream to false if the live_status field isn't present" do
response = %{ response = %{
"webpage_url" => "https://www.youtube.com/watch?v=TiZPUDkDYbk", "webpage_url" => "https://www.youtube.com/watch?v=TiZPUDkDYbk",
"aspect_ratio" => 1.0, "aspect_ratio" => 1.0,

View file

@ -93,7 +93,7 @@ defmodule Pinchflat.MediaFixtures do
id: "video1", id: "video1",
title: "Video 1", title: "Video 1",
webpage_url: "https://example.com/video1", webpage_url: "https://example.com/video1",
was_live: false, live_status: "not_live",
description: "desc1", description: "desc1",
aspect_ratio: 1.67, aspect_ratio: 1.67,
duration: 123.45, duration: 123.45,

View file

@ -81,7 +81,7 @@ defmodule Pinchflat.SourcesFixtures do
id: "video1", id: "video1",
title: "Video 1", title: "Video 1",
webpage_url: "https://example.com/video1", webpage_url: "https://example.com/video1",
was_live: false, live_status: "not_live",
description: "desc1", description: "desc1",
aspect_ratio: 1.67, aspect_ratio: 1.67,
duration: 12.34, duration: 12.34,
@ -91,7 +91,7 @@ defmodule Pinchflat.SourcesFixtures do
id: "video2", id: "video2",
title: "Video 2", title: "Video 2",
webpage_url: "https://example.com/video2", webpage_url: "https://example.com/video2",
was_live: true, live_status: "is_live",
description: "desc2", description: "desc2",
aspect_ratio: 1.67, aspect_ratio: 1.67,
duration: 345.67, duration: 345.67,
@ -101,7 +101,7 @@ defmodule Pinchflat.SourcesFixtures do
id: "video3", id: "video3",
title: "Video 3", title: "Video 3",
webpage_url: "https://example.com/video3", webpage_url: "https://example.com/video3",
was_live: false, live_status: "not_live",
description: "desc3", description: "desc3",
aspect_ratio: 1.0, aspect_ratio: 1.0,
duration: 678.90, duration: 678.90,