<commit_before>require 'test_helper'

class OntologySearchTest < ActiveSupport::TestCase 

  context 'OntologySearch' do
    setup do
      @os = OntologySearch.new

      @o1 = FactoryGirl.create(:ontology)
      @o2 = FactoryGirl.create(:ontology)
      @o3 = FactoryGirl.create(:ontology)

      @ontologies = [@o1, @o2, @o3]

      @e1 = FactoryGirl.create(:entity)
      @e2 = FactoryGirl.create(:entity)
      @e3 = FactoryGirl.create(:entity)

      @entities = [@e1, @e2, @e3]

      @l1 = FactoryGirl.create(:logic)
      @l2 = FactoryGirl.create(:logic)
      @l3 = FactoryGirl.create(:logic)

      @logics = [@l1, @l2, @l3]

      @o1.entities.push @e1
      @o2.entities.push @e2
      @o3.entities.push @e3

      @o1.logic = @l1
      @o2.logic = @l2
      @o3.logic = @l3

      @e2.name = @o1.name
      @l3.name = @o1.name

      @ontologies.map(&:save)
      @entities.map(&:save)
      @logics.map(&:save)
      ::Sunspot.session = ::Sunspot.session.original_session
      Ontology.reindex
    end

    teardown do
      ::Sunspot.session = ::Sunspot::Rails::StubSessionProxy.new(::Sunspot.session)     
    end

    #context 'keyword list' do
    #  should 'be generated correctly for ontologies' do
    #    @ontologies.each do |o|
    #      (0..(o.name.size-1)).each do |i|
    #        prefix = o.name[0..i]
    #        results = @os.make_global_keyword_list prefix
    #
    #        assert results.size != 0<commit_msg>Use Tims fix for starting sunspot:solr in test environment for now.<commit_after>require 'test_helper'

class OntologySearchTest < ActiveSupport::TestCase 

  context 'OntologySearch' do
    setup do
      @os = OntologySearch.new

      @o1 = FactoryGirl.create(:ontology)
      @o2 = FactoryGirl.create(:ontology)
      @o3 = FactoryGirl.create(:ontology)

      @ontologies = [@o1, @o2, @o3]

      @e1 = FactoryGirl.create(:entity)
      @e2 = FactoryGirl.create(:entity)
      @e3 = FactoryGirl.create(:entity)

      @entities = [@e1, @e2, @e3]

      @l1 = FactoryGirl.create(:logic)
      @l2 = FactoryGirl.create(:logic)
      @l3 = FactoryGirl.create(:logic)

      @logics = [@l1, @l2, @l3]

      @o1.entities.push @e1
      @o2.entities.push @e2
      @o3.entities.push @e3

      @o1.logic = @l1
      @o2.logic = @l2
      @o3.logic = @l3

      @e2.name = @o1.name
      @l3.name = @o1.name

      @ontologies.map(&:save)
      @entities.map(&:save)
      @logics.map(&:save)
#     ::Sunspot.session = ::Sunspot.session.original_session
      Ontology.reindex
    end

#   teardown do
#     ::Sunspot.session = ::Sunspot::Rails::StubSessionProxy.new(::Sunspot.session)     
#   end

    #context 'keyword list' do
    #  should 'be generated correctly for ontologies' do
    #    @ontologies.each do |o|
    #      (0..(o.name.size-1)).each do |i|
    #        prefix = o.name[0..i]
    #        results = @os.make_global_keyword_list prefix
    #
    #        assert results.size != 0
{'fraction_non_alphanumeric': 0.1451831750339213, 'fraction_numerical': 0.025780189959294438, 'mean_word_length': 2.381880733944954, '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': '2867145', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1064, 'n_words': 199}