<commit_before>require 'webmock'
include WebMock::API

class GorgmailApiMocker

  def initialize

    #stub_request(:get, /https:\/\/www.ovh.com\/cgi-bin\/sms\/http2sms.cgi.*/).to_return(:status => 200, :body => {"status"=>100, "smsIds"=>["69265512"], "creditLeft"=>"230.50"}.to_json, :headers => {})
  end

  def url(path_array)
    URI::join(Rails.application.secrets.gorgmail_api_url, *path_array)
  end

  def mock_search_query(request,result)
    if result
      response={
          :status => 200,
          :body => {uuid: result}.to_json,
          :headers => {}
      }
    else
      response={
          :status => 404,
          :body => {error:{status: 404, message: "Email not found"}}.to_json,
          :headers => {}
      }
    end
    WebMock.stub_request(:get, url(["/search/", request])).to_return(response)
  end

  def mock_unavailable_search_query(request)
    WebMock.stub_request(:get, url(["/search/", request])).to_timeout
  end

end<commit_msg>Fix gorgmail URI mocker<commit_after>require 'webmock'
include WebMock::API

class GorgmailApiMocker

  def initialize

    #stub_request(:get, /https:\/\/www.ovh.com\/cgi-bin\/sms\/http2sms.cgi.*/).to_return(:status => 200, :body => {"status"=>100, "smsIds"=>["69265512"], "creditLeft"=>"230.50"}.to_json, :headers => {})
  end

  def url(path_array)
    URI::join(Rails.application.secrets.gorgmail_api_url, *path_array)
  end

  def mock_search_query(request,result)
    if result
      response={
          :status => 200,
          :body => {uuid: result}.to_json,
          :headers => {}
      }
    else
      response={
          :status => 404,
          :body => {error:{status: 404, message: "Email not found"}}.to_json,
          :headers => {}
      }
    end
    WebMock.stub_request(:get, url(["search/", request])).to_return(response)
  end

  def mock_unavailable_search_query(request)
    WebMock.stub_request(:get, url(["search/", request])).to_timeout
  end

end
{'fraction_non_alphanumeric': 0.16853932584269662, 'fraction_numerical': 0.0296220633299285, 'mean_word_length': 3.098326359832636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2476589', 'n_tokens_mistral': 735, 'n_tokens_neox': 678, 'n_words': 116}