<commit_before>require 'rails_helper'
require "#{Rails.root}/lib/importers/revision_score_importer"

describe RevisionScoreImporter do
  before do
    create(:article,
           id: 45010238,
           title: 'Manspreading',
           namespace: 0)
    create(:revision,
           id: 675892696, # latest revision as of 2015-08-19
           article_id: 45010238)
    create(:revision,
           id: 641962088, # first revision, barely a stub
           article_id: 45010238)

    create(:article,
           id: 1538038,
           title: 'Performativity',
           namespace: 0)
    create(:revision,
           id: 662106477, # revision from 2015-05-13
           article_id: 1538038)
    create(:revision,
           id: 46745264, # revision from 2006-04-03
           article_id: 1538038)
  end

  it 'should save wp10 scores for revisions' do
    VCR.use_cassette 'revision_scores/by_revisions' do
      RevisionScoreImporter.update_revision_scores
      early_score = Revision.find(641962088).wp10.to_f
      later_score = Revision.find(675892696).wp10.to_f
      expect(early_score).to be > 0
      expect(later_score).to be > early_score
    end
  end

  it 'should save wp10 scores by article' do
    VCR.use_cassette 'revision_scores/by_article' do
      article_ids = [45010238, 1538038]
      RevisionScoreImporter
        .update_all_revision_scores_for_articles(article_ids)
      early_score = Revision.find(46745264).wp10.to_f
      later_score = Revision.find(662106477).wp10.to_f
      expect(early_score).to be > 0
      expect(later_score).to be > early_score
    end
  end

  it 'should handle network errors gracefully' do
    stub_request(:any, %r{http://ores.wmflabs.org/.*})
      .to_raise(Errno::ECONNREFUSED)
    RevisionScoreImporter.update_revision_scores(Revision.all)
    expect(Revision.find(662106477).wp10).to be_nil
  end
end<commit_msg>Mark ORES tests as pending<commit_after>require 'rails_helper'
require "#{Rails.root}/lib/importers/revision_score_importer"

describe RevisionScoreImporter do
  before do
    create(:article,
           id: 45010238,
           title: 'Manspreading',
           namespace: 0)
    create(:revision,
           id: 675892696, # latest revision as of 2015-08-19
           article_id: 45010238)
    create(:revision,
           id: 641962088, # first revision, barely a stub
           article_id: 45010238)

    create(:article,
           id: 1538038,
           title: 'Performativity',
           namespace: 0)
    create(:revision,
           id: 662106477, # revision from 2015-05-13
           article_id: 1538038)
    create(:revision,
           id: 46745264, # revision from 2006-04-03
           article_id: 1538038)
  end

  it 'should save wp10 scores for revisions' do
    VCR.use_cassette 'revision_scores/by_revisions' do
      pending 'This should pass unless ORES is down or overloaded.'

      RevisionScoreImporter.update_revision_scores
      early_score = Revision.find(641962088).wp10.to_f
      later_score = Revision.find(675892696).wp10.to_f
      expect(early_score).to be > 0
      expect(later_score).to be > early_score

      puts 'PASSED'
      fail 'this test passed — this time'
    end
  end

  it 'should save wp10 scores by article' do
    VCR.use_cassette 'revision_scores/by_article' do
      pending 'This should pass unless ORES is down or overloaded.'

      article_ids = [45010238, 1538038]
      RevisionScoreImporter
        .update_all_revision_scores_for_articles(article_ids)
      early_score = Revision.find(46745264).wp10.to_f
      later_score = Revision.find(662106477).wp10.to_f
      expect(early_score).to be > 0
      expect(later_score).to be > early_score

      puts 'PASSED'
      fail 'this test passed — this time'
    end
  end

  it 'should handle network errors gracefully' do
    stub_request(:any, %r{http://ores.wmflabs.org/.*})
      .to_raise(Errno::ECONNREFUSED)
    RevisionScoreImporter.update_revision_scores(Revision.all)
    expect(Revision.find(662106477).wp10).to be_nil
  end
end
{'fraction_non_alphanumeric': 0.08715028472394157, 'fraction_numerical': 0.08962614508541718, 'mean_word_length': 2.7934272300469485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5994674', 'n_tokens_mistral': 1602, 'n_tokens_neox': 1307, 'n_words': 295}