<commit_before>ExUnit.start

defmodule Funnel.TestCase do
  use ExUnit.CaseTemplate

  # Enable code reloading on test cases
  setup do
    :ok
  end
end

defimpl Funnel.Transport, for: PID do
  def write(receiver, message) do
    send(receiver, {:chunk, message})
    {:ok, receiver}
  end
end

defimpl Funnel.Transport, for: Dynamo.Connection.Test do
  def write(conn, %{:id => _, :item => item}) do
    conn.chunk(item)
  end
end

defmodule Funnel.Es.Asserts do
  import ExUnit.Assertions, only: [assert: 1, assert: 2]

  def assert_query_creation(query, index \\ "funnel", token \\ "token") do
    {status, response} = Funnel.Es.register(index, token, query)
    {:ok, body} = JSEX.decode response
    assert status == 201
    body
  end

  def assert_query_update(query, uuid, index \\ "funnel") do
    {status, response} = Funnel.Es.register(index, "token", uuid, query)
    {:ok, body} = JSEX.decode response
    assert status == 200
    body
  end

  def assert_query_find(index) do
    hash = HashDict.new
    hash = Dict.put(hash, :index_id, index)
    {status, response} = Funnel.Es.find("token", hash)
    {:ok, response} = JSEX.decode response<commit_msg>Remove Dynamo test connection protocol<commit_after>ExUnit.start

defmodule Funnel.TestCase do
  use ExUnit.CaseTemplate

  # Enable code reloading on test cases
  setup do
    :ok
  end
end

defimpl Funnel.Transport, for: PID do
  def write(receiver, message) do
    send(receiver, {:chunk, message})
    {:ok, receiver}
  end
end

defmodule Funnel.Es.Asserts do
  import ExUnit.Assertions, only: [assert: 1, assert: 2]

  def assert_query_creation(query, index \\ "funnel", token \\ "token") do
    {status, response} = Funnel.Es.register(index, token, query)
    {:ok, body} = JSEX.decode response
    assert status == 201
    body
  end

  def assert_query_update(query, uuid, index \\ "funnel") do
    {status, response} = Funnel.Es.register(index, "token", uuid, query)
    {:ok, body} = JSEX.decode response
    assert status == 200
    body
  end

  def assert_query_find(index) do
    hash = HashDict.new
    hash = Dict.put(hash, :index_id, index)
    {status, response} = Funnel.Es.find("token", hash)
    {:ok, response} = JSEX.decode response
{'fraction_non_alphanumeric': 0.11920827710301395, 'fraction_numerical': 0.007197480881691408, 'mean_word_length': 3.492929292929293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2717929', 'n_tokens_mistral': 782, 'n_tokens_neox': 754, 'n_words': 221}