elixir_rss/test/fetch_rss_test.exs

35 lines
1.5 KiB
Elixir
Raw Normal View History

2024-10-13 01:50:00 +00:00
defmodule HttpTest do
2024-10-11 03:04:34 +00:00
use ExUnit.Case
2024-10-13 01:50:00 +00:00
doctest ElixirRss
2024-10-11 03:04:34 +00:00
test "fetch url" do
2024-10-21 02:49:48 +00:00
assert ElixirRss.Fetcher.fetch("https://shillerben.com") |> elem(0) == :ok
end
test "parse RSS to model" do
items = File.read("test/slashdotMain.xml")
|> elem(1)
|> ElixirRss.Fetcher.parse_rss_to_model()
first = Enum.at(items, 0)
assert Map.keys(first) == ["description", "title"]
titles = Enum.map(items, &(Map.get(&1, "title")))
assert titles == [
"North Carolina Maker of High-Purity Quartz Back Operating After Hurricane",
"California Newspaper Creates AI-Powered 'News Assistant' for Kamala Harris Info",
"Microsoft's Take On Kernel Access and Safe Deployment After CrowdStrike Incident",
"Who's Winning America's 'Tech War' With China?",
"The Radio-Obsessed Civilian Shaping Ukraine's Drone Defense",
"AI Disclaimers in Political Ads Backfire on Candidates, Study Finds",
"Halcyon Announces Anti-Ransomware Protection for Enterprise Linux Environments",
"Amazon Expands Same-Day Prescription Delivery to Nearly Half the US Next Year",
"'Running Clang in the Browser Using WebAssembly'",
"Boeing Plans to Cut 17,000 Jobs - 10% of Its Workforce",
"PC Shipments Stuck in Neutral Despite AI Buzz",
"Imgur Is No Longer Classifying Memes With Adult Humor As Mature",
"NASA Confirms Plans To Develop Lunar Time Standard",
"The Crackdown on Compounded GLP-1 Meds Has Begun",
"Physicists Generated Sound Waves That Travel In One Direction Only",
]
2024-10-11 03:04:34 +00:00
end
end