diff --git a/config/test.exs b/config/test.exs index ca7664b..2b65e42 100644 --- a/config/test.exs +++ b/config/test.exs @@ -5,12 +5,12 @@ use Mix.Config # The MIX_TEST_PARTITION environment variable can be used # to provide built-in test partitioning in CI environment. # Run `mix help test` for more information. -config :podcast_feed, PodcastFeed.Repo, - username: "postgres", - password: "postgres", - database: "podcast_feed_test#{System.get_env("MIX_TEST_PARTITION")}", - hostname: "localhost", - pool: Ecto.Adapters.SQL.Sandbox +# config :podcast_feed, PodcastFeed.Repo, +# username: "postgres", +# password: "postgres", +# database: "podcast_feed_test#{System.get_env("MIX_TEST_PARTITION")}", +# hostname: "localhost", +# pool: Ecto.Adapters.SQL.Sandbox # We don't run a server during test. If one is required, # you can enable the server option below. diff --git a/lib/podcast_feed.ex b/lib/podcast_feed.ex index 62ed9c1..2afd95a 100644 --- a/lib/podcast_feed.ex +++ b/lib/podcast_feed.ex @@ -8,9 +8,8 @@ defmodule PodcastFeed do """ alias PodcastFeed.Provider.Archive - def archive() do - Archive.Parser.feed('https://ia601402.us.archive.org/8/items/incontri-a-piano-terra/incontri-a-piano-terra_files.xml') #FIXME: should be dynamic - |> IO.inspect + def archive(identifier) do + Archive.Parser.by_identifier(identifier) end end diff --git a/lib/podcast_feed/Utility/Format.ex b/lib/podcast_feed/Utility/Format.ex new file mode 100644 index 0000000..1b7d0a7 --- /dev/null +++ b/lib/podcast_feed/Utility/Format.ex @@ -0,0 +1,7 @@ +defmodule PodcastFeed.Utility.Format do + + def compile(subject, replacements) do + replacements + |> Enum.reduce(subject, fn {replacement_key, replacement_value}, subject -> String.replace(subject, "{#{replacement_key}}", replacement_value) end) + end +end \ No newline at end of file diff --git a/lib/podcast_feed/provider/archive/parser.ex b/lib/podcast_feed/provider/archive/parser.ex index 2c0ded3..9a365c7 100644 --- a/lib/podcast_feed/provider/archive/parser.ex +++ b/lib/podcast_feed/provider/archive/parser.ex @@ -1,130 +1,95 @@ defmodule PodcastFeed.Provider.Archive.Parser do - def feed(url) do - url - |> fetch_xml() - |> parse() - |> IO.inspect() - |> filter_mp3() - |> compose() + alias PodcastFeed.Utility.Format + + @extra_metadata_url "https://archive.org/download/{identifier}/metadata.json" + @metadata_url "http://archive.org/metadata/{identifier}" + @download_url "https://archive.org/download/{identifier}/{filename}" + + def by_identifier(identifier) do + extra_metadata_json = fetch_extra_metadata(identifier) + metadata_json = fetch_metadata(identifier) + parse(identifier, metadata_json, extra_metadata_json) end - defp fetch_xml(url) do - {:ok, {_, _, xml}} = :httpc.request(:get, {url, []}, [], [body_format: :binary]) - xml + defp fetch_extra_metadata(identifier) do + extra_metadata_url = Format.compile(@extra_metadata_url, identifier: identifier) + {:ok, 200, _headers, client_ref} = :hackney.get(extra_metadata_url, [], "", [follow_redirect: true]) + {:ok, extra_metadata_json} = :hackney.body(client_ref) + extra_metadata_json |> String.split("\n") |> Enum.join() |> Poison.decode!() end - defp parse(xml) do - xml |> XmlToMap.naive_map() |> Map.get("files") |> Map.get("file") |> Enum.map(fn f -> Map.get(f, "#content") |> Map.put("filename", Map.get(f, "-name")) end) + defp fetch_metadata(identifier) do + metadata_url = Format.compile(@metadata_url, identifier: identifier) + metadata_url |> IO.inspect + {:ok, 200, _headers, client_ref} = :hackney.get(metadata_url, [], "", [follow_redirect: true, connect_timeout: 30000, recv_timeout: 30000]) + {:ok, metadata_json} = :hackney.body(client_ref) + metadata_json |> Poison.decode!() end - defp filter_mp3(files) do - files |> Enum.filter(fn f -> Map.get(f, "format") =~ ~r/MP3/i end) + def parse(identifier, %{"metadata" => metadata, "files" => files}, extra) do + _image = files |> fetch_image(identifier) + + %{podcast: podcast_data(metadata, extra), items: items_data(files, identifier)} end - defp compose(files) do - files - |> Enum.map(&to_feed_item/1) + defp fetch_image(files, identifier) do + filename = files + |> Enum.filter(fn f -> f["source"] == "original" end) + |> Enum.filter(fn f -> f["format"] == "JPEG" end) #FIXME:! jpg, png, gif + |> List.first() + |> Map.get("name") + + Format.compile(@download_url, identifier: identifier, filename: filename) |> URI.encode() end - # - # Episode Name 2 - # - # http://podcast.example.com/episode2.mp4 - # - # Sat, 02 Jan 2016 16:00:00 PDT - # - # The full length episode 2 description - # - # - # - # http://podcast.example.com/episode2.mp4 - # - # 19:07 - # - # The full length episode 2 description - # - # - # - # comma,separated,key,words - # - # no - # -# %{ -# "album" => "Incontri al Piano Terra", -# "artist" => "APE Milano", -# "crc32" => "f1820595", -# "creator" => "APE Milano", -# "format" => "VBR MP3", -# "genre" => "podcast", -# "height" => "0", -# "length" => "3943.31", -# "md5" => "9ca26043a3e82e6f86c3a9309b88f4f5", -# "mtime" => "1590154757", -# "sha1" => "dcacfa46fcad1d656312784ad06886b5614c6420", -# "size" => "47148690", -# "title" => "Presentazione di Montagna femminile plurale con N1DM", -# "track" => "03", -# "width" => "0" -# } - - defp to_feed_item(file) do + defp podcast_data(metadata, extra) do %{ - title: file |> Map.get("title"), - link: "http://archive.org/download/incontri-a-piano-terra/" <> (file |> Map.get("filename")) |> URI.encode(), #FIXME:! identifier should by dynamic - pubDate: file |> Map.get("mtime") |> Integer.parse() |> elem(0) |> DateTime.from_unix!(:second), + title: metadata["title"], + description: metadata["description"], + webmaster: metadata["uploader"], + managingEditor: metadata["uploader"], + owner: %{ + name: metadata["creator"], + email: metadata["uploader"], + }, + keywords: metadata["subject"], + pubDate: metadata["publicdate"] |> NaiveDateTime.from_iso8601!() |> DateTime.from_naive!("Etc/UTC"), + lastBuildDate: metadata["addeddate"] |> NaiveDateTime.from_iso8601!() |> DateTime.from_naive!("Etc/UTC"), + author: metadata["creator"], + language: metadata["language"], + image: %{ + url: extra["image"]["url"], + title: extra["image"]["title"], + link: extra["image"]["link"], + }, + link: extra["link"], + category: extra["category"], + explicit: extra["explicit"], + } + end + + defp items_data(files, identifier) do + files + |> filter_audio_files() + |> Enum.map(fn f -> to_feed_item(f, identifier) end) + end + + defp filter_audio_files(files) do + files |> Enum.filter(fn f -> Map.get(f, "format") =~ ~r/MP3/i end) #FIXME:! mp3, ogg, boh + end + + defp to_feed_item(file, identifier) do + filename = Map.get(file, "name") + %{ + title: file["title"], description: "", - length: (file |> Map.get("length") |> Float.parse() |> elem(0)) * 100, - guid: "", - duration: "", + pubDate: file |> Map.get("mtime") |> Integer.parse() |> elem(0) |> DateTime.from_unix!(:second), + link: Format.compile(@download_url, identifier: identifier, filename: filename) |> URI.encode(), + length: (file |> Map.get("length") |> Float.parse() |> elem(0)) * 100 |> trunc(), summary: "", - image: "", + # image: "", #FIXME:! take the image from other files keywords: file |> Map.take(["album", "artist", "genre"]) |> Map.values(), explicit: "no", } end end - -# -# -# -# http://www.YourSite.com -# en-us -# ©2013 -# your@email.com (Your Name) -# your@email.com (Your Name) -# -# http://www.YourSite.com/ImageSize300X300.jpg -# Title or description of your logo -# http://www.YourSite.com -# -# -# Your Name -# your@email.com -# -# -# -# -# separate, by, comma, and, space -# no -# -# -# Sun, 01 Jan 2012 00:00:00 EST -# Verbose title of the podcast -# College, school, or department owning the podcast -# Verbose description of the podcast. -# Duplicate of above verbose description. -# Short description of the podcast - 255 character max. -# Thu, 02 Feb 2012 00:00:00 EST -# -# Verbose title of the episode -# Verbose description of the episode. -# Duplicate of above verbose description. -# Short description of the episode - 255 character max. -# -# -# http://www.YourSite.com/FILE.EXT -# H:MM:SS -# Thu, 02 Feb 2012 00:00:00 EST -# -# -# diff --git a/lib/podcast_feed/repo.ex b/lib/podcast_feed/repo.ex index 8113f15..db6e953 100644 --- a/lib/podcast_feed/repo.ex +++ b/lib/podcast_feed/repo.ex @@ -1,5 +1,5 @@ -defmodule PodcastFeed.Repo do - # use Ecto.Repo, - # otp_app: :podcast_feed, - # adapter: Ecto.Adapters.Postgres -end +# defmodule PodcastFeed.Repo do +# # use Ecto.Repo, +# # otp_app: :podcast_feed, +# # adapter: Ecto.Adapters.Postgres +# end diff --git a/lib/podcast_feed_web/controllers/feed_controller.ex b/lib/podcast_feed_web/controllers/feed_controller.ex index 043752a..6927dd4 100644 --- a/lib/podcast_feed_web/controllers/feed_controller.ex +++ b/lib/podcast_feed_web/controllers/feed_controller.ex @@ -2,9 +2,9 @@ defmodule PodcastFeedWeb.FeedController do use PodcastFeedWeb, :controller def apeMilano(conn, _params) do - items = PodcastFeed.archive() + %{podcast: podcast, items: items} = PodcastFeed.archive("incontri-a-piano-terra") conn |> put_resp_content_type("text/xml") - |> render("feed.xml", items: items) + |> render("feed.xml", podcast: podcast, items: items) end end diff --git a/lib/podcast_feed_web/endpoint.ex b/lib/podcast_feed_web/endpoint.ex index 98c7443..8601e3d 100644 --- a/lib/podcast_feed_web/endpoint.ex +++ b/lib/podcast_feed_web/endpoint.ex @@ -32,7 +32,7 @@ defmodule PodcastFeedWeb.Endpoint do socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket plug Phoenix.LiveReloader plug Phoenix.CodeReloader - plug Phoenix.Ecto.CheckRepoStatus, otp_app: :podcast_feed + # plug Phoenix.Ecto.CheckRepoStatus, otp_app: :podcast_feed end plug Phoenix.LiveDashboard.RequestLogger, diff --git a/lib/podcast_feed_web/templates/feed/feed.xml.eex b/lib/podcast_feed_web/templates/feed/feed.xml.eex index c345519..41b4c98 100644 --- a/lib/podcast_feed_web/templates/feed/feed.xml.eex +++ b/lib/podcast_feed_web/templates/feed/feed.xml.eex @@ -1,35 +1,34 @@ - http://www.ape-alveare.it/ - en-us + <%= @podcast.link %> + <%= @podcast.language %> ©2022 - your@email.com (Your Name) - your@email.com (Your Name) + <%= @podcast.webmaster %> + <%= @podcast.webmaster %> - http://www.ape-alveare.it/wp-content/themes/yootheme/cache/2018_logo_Ape_righe_trasparenza-d1aae6b9.png - Ape-Milano-logo - http://www.ape-alveare.it/ + <%= @podcast.image.url %> + <%= @podcast.image.title %> + <%= @podcast.image.link %> - Ape Milano - your@email.com + <%= @podcast.owner.name %> + <%= @podcast.owner.email %> - - + + - separate, by, comma, and, space - no - + <%= "FIXME!!!" %> + <%= @podcast.explicit %> + - Sun, 01 Jan 2012 00:00:00 EST - Verbose title of the podcast + <%= @podcast.pubDate |> Calendar.DateTime.Format.rfc2822 %> + <%= @podcast.title %> College, school, or department owning the podcast - Verbose description of the podcast. - Duplicate of above verbose description. - Short description of the podcast - 255 character max. - Thu, 02 Feb 2012 00:00:00 EST - + <%= @podcast.description %> + <%= @podcast.description %> + <%= @podcast.description %> + <%= @podcast.pubDate |> Calendar.DateTime.Format.rfc2822 %> <%= for item <- @items do %> <%= item.title %> @@ -43,6 +42,6 @@ <%= item.keywords %> <%= item.explicit %> - <%= end %> + <% end %> - + \ No newline at end of file diff --git a/lib/podcast_feed_web/views/feed_view.ex b/lib/podcast_feed_web/views/feed_view.ex index a07b348..bdb693c 100644 --- a/lib/podcast_feed_web/views/feed_view.ex +++ b/lib/podcast_feed_web/views/feed_view.ex @@ -2,6 +2,7 @@ defmodule PodcastFeedWeb.FeedView do use PodcastFeedWeb, :view def format_length(length) do + length |> IO.inspect parsed = length / 100 / 60 min = parsed |> trunc sec = parsed - min |> Float.floor(2) |> Float.to_string() |> String.split(".") |> Enum.at(1) diff --git a/mix.exs b/mix.exs index bd773a4..1a014e8 100644 --- a/mix.exs +++ b/mix.exs @@ -47,7 +47,9 @@ defmodule PodcastFeed.MixProject do {:plug_cowboy, "~> 2.0"}, {:elixir_xml_to_map, "~> 1.0"}, {:calendar, "~> 1.0.0"}, - {:distillery, "~> 2.0"} + {:distillery, "~> 2.0"}, + {:poison, "~> 3.1"}, + {:hackney, "~> 1.15"}, ] end @@ -62,7 +64,8 @@ defmodule PodcastFeed.MixProject do setup: ["deps.get", "ecto.setup", "cmd npm install --prefix assets"], "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], "ecto.reset": ["ecto.drop", "ecto.setup"], - test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"] + # test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"] + test: ["test"] ] end end diff --git a/mix.lock b/mix.lock index 064f5c3..0cfdc71 100644 --- a/mix.lock +++ b/mix.lock @@ -31,6 +31,7 @@ "plug": {:hex, :plug, "1.10.1", "c56a6d9da7042d581159bcbaef873ba9d87f15dce85420b0d287bca19f40f9bd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "b5cd52259817eb8a31f2454912ba1cff4990bca7811918878091cb2ab9e52cb8"}, "plug_cowboy": {:hex, :plug_cowboy, "2.2.1", "fcf58aa33227a4322a050e4783ee99c63c031a2e7f9a2eb7340d55505e17f30f", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3b43de24460d87c0971887286e7a20d40462e48eb7235954681a20cee25ddeb6"}, "plug_crypto": {:hex, :plug_crypto, "1.1.2", "bdd187572cc26dbd95b87136290425f2b580a116d3fb1f564216918c9730d227", [:mix], [], "hexpm", "6b8b608f895b6ffcfad49c37c7883e8df98ae19c6a28113b02aa1e9c5b22d6b5"}, + "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"}, "postgrex": {:hex, :postgrex, "0.15.4", "5d691c25fc79070705a2ff0e35ce0822b86a0ee3c6fdb7a4fb354623955e1aed", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "306515b9d975fcb2478dc337a1d27dc3bf8af7cd71017c333fe9db3a3d211b0a"}, "ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm", "451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm", "13104d7897e38ed7f044c4de953a6c28597d1c952075eb2e328bc6d6f2bfc496"}, diff --git a/test/podcast_feed/provider/archive/parser_test.exs b/test/podcast_feed/provider/archive/parser_test.exs new file mode 100644 index 0000000..760a6ee --- /dev/null +++ b/test/podcast_feed/provider/archive/parser_test.exs @@ -0,0 +1,55 @@ +defmodule PodcastFeed.Provider.Archive.ParserTest do + use ExUnit.Case + + alias PodcastFeed.Provider.Archive.Parser + + setup_all do + valid_json = "{\"created\":1590247789,\"d1\":\"ia601402.us.archive.org\",\"d2\":\"ia801402.us.archive.org\",\"dir\":\"/8/items/incontri-a-piano-terra\",\"files\":[{\"name\": \"metadata.json\",\"source\": \"original\",\"mtime\": \"1590258296\",\"size\": \"315\",\"md5\": \"a0c0e219cf3f13e54f2a4b3efef8e5c8\",\"crc32\": \"2d181b5c\",\"sha1\": \"8244b579a759edddd01c905dd11f8565e83d0898\",\"format\": \"JSON\"},{\"name\": \"cover.jpg\",\"source\": \"original\",\"mtime\": \"1590258445\",\"size\": \"10650\",\"md5\": \"15687b23e11f0099abbfe64eb1685c31\",\"crc32\": \"fbb1516a\",\"sha1\": \"98fa929c7554241cfa92bea8eba69b39c5d47603\",\"format\": \"JPEG\",\"rotation\": \"0\"},{\"name\":\"Confini mobili sulle alpi.mp3\",\"source\":\"original\",\"mtime\":\"1590135989\",\"size\":\"46933494\",\"md5\":\"e832ee9381a4f8af2d9727e2f49126ae\",\"crc32\":\"d709dd90\",\"sha1\":\"89c820a2dfd63cfbbf7aeefd191c653756b33fe3\",\"format\":\"VBR MP3\",\"length\":\"3902.35\",\"height\":\"0\",\"width\":\"0\",\"title\":\"Confini mobili sulle alpi (italian limes)\",\"creator\":\"APE Milano\",\"album\":\"Incontri a Piano Terra\",\"track\":\"02\",\"artist\":\"APE Milano\",\"genre\":\"podcast\"},{\"name\":\"Confini mobili sulle alpi.png\",\"source\":\"derivative\",\"format\":\"PNG\",\"original\":\"Confini mobili sulle alpi.mp3\",\"mtime\":\"1590137809\",\"size\":\"34656\",\"md5\":\"63893f9b00402a107682b5317e808523\",\"crc32\":\"b59ff609\",\"sha1\":\"a396716431cd0acedd243030093d0b31d792cfb3\"},{\"name\":\"Confini mobili sulle alpi_spectrogram.png\",\"source\":\"derivative\",\"format\":\"Spectrogram\",\"original\":\"Confini mobili sulle alpi.mp3\",\"mtime\":\"1590137854\",\"size\":\"273188\",\"md5\":\"557337665c6d9f962b2e91d169f25e1b\",\"crc32\":\"08b4b57c\",\"sha1\":\"88e088f9c4954aa8f0849b7e0d69cee8d7d42327\"}],\"files_count\":31,\"item_last_updated\":1590160774,\"item_size\":244544362,\"metadata\":{\"identifier\":\"incontri-a-piano-terra\",\"mediatype\":\"audio\",\"collection\":\"opensource_audio\",\"creator\":\"APE Milano\",\"description\":\"Qualche registrazione delle attivit\\u00e0 sociali che promuoviamo al Piano Terra di Milano\",\"language\":\"ita\",\"licenseurl\":\"https://creativecommons.org/licenses/by-nc-nd/4.0/\",\"scanner\":\"Internet Archive HTML5 Uploader 1.6.4\",\"subject\":[\"ape milano\",\"podcast\",\"montagna\"],\"title\":\"Incontri a Piano Terra\",\"uploader\":\"milanoape@gmail.com\",\"publicdate\":\"2020-05-22 08:30:21\",\"addeddate\":\"2020-05-22 08:30:21\",\"curation\":\"[curator]validator@archive.org[/curator][date]20200522085526[/date][comment]checked for malware[/comment]\"},\"server\":\"ia601402.us.archive.org\",\"uniq\":122833277,\"workable_servers\":[\"ia601402.us.archive.org\",\"ia801402.us.archive.org\"]}" + extra = "{\"link\": \"http://www.ape-alveare.it/\",\"image\": {\"url\": \"http://www.ape-alveare.it/wp-content/themes/yootheme/cache/2018_logo_Ape_righe_trasparenza-d1aae6b9.png\",\"title\": \"APE Milano\",\"link\": \"http://www.ape-alveare.it/\"},\"category\": \"Montagna\",\"explicit\": \"no\" }" + + {:ok, json: valid_json, extra: extra} + end + + test "Test that podcast data are correctly converted", state do + %{podcast: podcast} = Parser.parse("incontri-a-piano-terra", Poison.decode!(state[:json]), Poison.decode!(state[:extra])) + assert %{ + title: "Incontri a Piano Terra", + description: "Qualche registrazione delle attività sociali che promuoviamo al Piano Terra di Milano", + webmaster: "milanoape@gmail.com", + managingEditor: "milanoape@gmail.com", + owner: %{ + name: "APE Milano", + email: "milanoape@gmail.com", + }, + keywords: ["ape milano", "podcast", "montagna"], + pubDate: ~U[2020-05-22 08:30:21Z], + lastBuildDate: ~U[2020-05-22 08:30:21Z], + author: "APE Milano", + language: "ita", + image: %{ + url: "http://www.ape-alveare.it/wp-content/themes/yootheme/cache/2018_logo_Ape_righe_trasparenza-d1aae6b9.png", + title: "APE Milano", + link: "http://www.ape-alveare.it/", + }, + link: "http://www.ape-alveare.it/", + category: "Montagna", + explicit: "no", + } == podcast + end + + test "Test that items data are correctly converted", state do + %{items: items} = Parser.parse("incontri-a-piano-terra", Poison.decode!(state[:json]), Poison.decode!(state[:extra])) + assert [ + %{ + title: "Confini mobili sulle alpi (italian limes)", + description: "", + pubDate: ~U[2020-05-22 08:26:29Z], + link: "https://archive.org/download/incontri-a-piano-terra/Confini%20mobili%20sulle%20alpi.mp3", + length: 390235, + summary: "", + keywords: ["Incontri a Piano Terra", "APE Milano", "podcast"], + explicit: "no", + } + ] == items + end +end \ No newline at end of file diff --git a/test/podcast_feed/utility/format_test.exs b/test/podcast_feed/utility/format_test.exs new file mode 100644 index 0000000..12c4949 --- /dev/null +++ b/test/podcast_feed/utility/format_test.exs @@ -0,0 +1,9 @@ +defmodule PodcastFeed.Utility.FormatTest do + use ExUnit.Case + + alias PodcastFeed.Utility.Format + + test "Test placeholder are replaced" do + assert "http://foo/bar" == Format.compile("http://{host}/{path}", host: "foo", path: "bar") + end +end \ No newline at end of file diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex index 7dd9fb2..e32c5f3 100644 --- a/test/support/channel_case.ex +++ b/test/support/channel_case.ex @@ -29,11 +29,11 @@ defmodule PodcastFeedWeb.ChannelCase do end setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(PodcastFeed.Repo) + # :ok = Ecto.Adapters.SQL.Sandbox.checkout(PodcastFeed.Repo) - unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, {:shared, self()}) - end + # unless tags[:async] do + # Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, {:shared, self()}) + # end :ok end diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index 7581661..632ea27 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -32,11 +32,11 @@ defmodule PodcastFeedWeb.ConnCase do end setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(PodcastFeed.Repo) + # :ok = Ecto.Adapters.SQL.Sandbox.checkout(PodcastFeed.Repo) - unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, {:shared, self()}) - end + # unless tags[:async] do + # Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, {:shared, self()}) + # end {:ok, conn: Phoenix.ConnTest.build_conn()} end diff --git a/test/support/data_case.ex b/test/support/data_case.ex index 06802db..d6dc3a4 100644 --- a/test/support/data_case.ex +++ b/test/support/data_case.ex @@ -20,19 +20,19 @@ defmodule PodcastFeed.DataCase do quote do alias PodcastFeed.Repo - import Ecto - import Ecto.Changeset - import Ecto.Query + # import Ecto + # import Ecto.Changeset + # import Ecto.Query import PodcastFeed.DataCase end end setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(PodcastFeed.Repo) + # :ok = Ecto.Adapters.SQL.Sandbox.checkout(PodcastFeed.Repo) - unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, {:shared, self()}) - end + # unless tags[:async] do + # Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, {:shared, self()}) + # end :ok end @@ -46,10 +46,10 @@ defmodule PodcastFeed.DataCase do """ def errors_on(changeset) do - Ecto.Changeset.traverse_errors(changeset, fn {message, opts} -> - Regex.replace(~r"%{(\w+)}", message, fn _, key -> - opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string() - end) - end) + # Ecto.Changeset.traverse_errors(changeset, fn {message, opts} -> + # Regex.replace(~r"%{(\w+)}", message, fn _, key -> + # opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string() + # end) + # end) end end diff --git a/test/test_helper.exs b/test/test_helper.exs index 3597be3..5e46dbb 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,2 +1,2 @@ ExUnit.start() -Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, :manual) +# Ecto.Adapters.SQL.Sandbox.mode(PodcastFeed.Repo, :manual) \ No newline at end of file