ammocpr/test/ammoprices/scraping/scrape_job_test.exs
Graham McIntire 9eb85faebd
Add 4 new retailer scrapers for broader price coverage
Add True Shot Ammo (Shopify JSON), Palmetto State Armory (Magento HTML),
Bulk Ammo (Magento HTML), and Natchez Shooters Supply (GraphQL API).

Extends scraper infrastructure with HttpClient.post_json/3 and an
optional fetch/2 callback on the Scraper behaviour for scrapers that
need custom HTTP flows (e.g. GraphQL POST requests).
2026-03-12 10:00:59 -05:00

59 lines
1.5 KiB
Elixir

defmodule Ammoprices.Scraping.ScrapeJobTest do
use Ammoprices.DataCase
use Oban.Testing, repo: Ammoprices.Repo
import Ammoprices.Fixtures
alias Ammoprices.Scraping.ScrapeJob
@fixture_html File.read!("test/fixtures/lucky_gunner/9mm.html")
setup do
retailer_fixture(%{name: "Lucky Gunner", slug: "lucky-gunner", base_url: "https://www.luckygunner.com"})
retailer_fixture(%{name: "SGAmmo", slug: "sgammo", base_url: "https://www.sgammo.com"})
retailer_fixture(%{
name: "Target Sports USA",
slug: "target-sports-usa",
base_url: "https://www.targetsportsusa.com"
})
retailer_fixture(%{
name: "True Shot Ammo",
slug: "true-shot-ammo",
base_url: "https://trueshotammo.com"
})
retailer_fixture(%{
name: "Palmetto State Armory",
slug: "palmetto-state-armory",
base_url: "https://palmettostatearmory.com"
})
retailer_fixture(%{
name: "Bulk Ammo",
slug: "bulk-ammo",
base_url: "https://www.bulkammo.com"
})
retailer_fixture(%{
name: "Natchez Shooters Supply",
slug: "natchez",
base_url: "https://www.natchezss.com"
})
caliber_fixture(%{name: "9mm Luger", slug: "9mm-luger", category: "handgun", aliases: ["9mm", "9x19"]})
Req.Test.stub(Ammoprices.Scraping.HttpClient, fn conn ->
Req.Test.html(conn, @fixture_html)
end)
:ok
end
describe "perform/1" do
test "executes scrape for all enabled scrapers and calibers" do
assert :ok = perform_job(ScrapeJob, %{})
end
end
end