<commit_before>require 'test_helper'



class RegisterEngineTest < ActiveSupport::TestCase
  class BentoSearch::DummyEngine
    include BentoSearch::SearchEngine
  end
    
  def teardown
    BentoSearch.reset_engine_registrations!
  end
  
  test "can register and retrieve engine" do
    BentoSearch.register_engine("test_engine") do |conf|
      conf.engine = "BentoSearch::DummyEngine"      
      conf.api_key = "dummy"
    end
    
    engine = BentoSearch.get_engine("test_engine")
    
    assert_kind_of BentoSearch::DummyEngine, engine    
    assert_equal "dummy", engine.configuration.api_key
    
  end
  
  test "can register with engine name assumed in BentoSearch::" do
    BentoSearch.register_engine("test_engine") do |conf|
      conf.engine = "DummyEngine"      
      conf.api_key = "dummy"
    end
    
    assert_kind_of BentoSearch::DummyEngine, BentoSearch.get_engine("test_engine")
  end
  
  test "raises for no engine class" do
    assert_raises(ArgumentError) do
      BentoSearch.register_engine("test_engine") do |conf|              
        conf.api_key = "dummy"
      end
    end
  end
  
  
  test "raises on unregistered engine access" do
    assert_raise(ArgumentError) { BentoSearch.get_engine("not_registered")}
  end
  
end
  <commit_msg>oops, forgot to commit change to NoSuchEngine raise<commit_after>require 'test_helper'



class RegisterEngineTest < ActiveSupport::TestCase
  class BentoSearch::DummyEngine
    include BentoSearch::SearchEngine
  end
    
  def teardown
    BentoSearch.reset_engine_registrations!
  end
  
  test "can register and retrieve engine" do
    BentoSearch.register_engine("test_engine") do |conf|
      conf.engine = "BentoSearch::DummyEngine"      
      conf.api_key = "dummy"
    end
    
    engine = BentoSearch.get_engine("test_engine")
    
    assert_kind_of BentoSearch::DummyEngine, engine    
    assert_equal "dummy", engine.configuration.api_key
    
  end
  
  test "can register with engine name assumed in BentoSearch::" do
    BentoSearch.register_engine("test_engine") do |conf|
      conf.engine = "DummyEngine"      
      conf.api_key = "dummy"
    end
    
    assert_kind_of BentoSearch::DummyEngine, BentoSearch.get_engine("test_engine")
  end
  
  test "raises for no engine class" do
    assert_raises(ArgumentError) do
      BentoSearch.register_engine("test_engine") do |conf|              
        conf.api_key = "dummy"
      end
    end
  end
  
  
  test "raises on unregistered engine access" do
    assert_raise(BentoSearch::NoSuchEngine) { BentoSearch.get_engine("not_registered")}
  end
  
end
  
{'fraction_non_alphanumeric': 0.07789716039907905, 'fraction_numerical': 0.0, 'mean_word_length': 3.1778846153846154, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4649124', 'n_tokens_mistral': 821, 'n_tokens_neox': 812, 'n_words': 183}