<commit_before>require 'test/unit'
require File.dirname(__FILE__) + '/../conf/include'
require 'author_detective.rb'

require 'time'

class MediaWikiApiTest < Test::Unit::TestCase
  def setup
    @db = SQLite3::Database.new(":memory:")
    @db.execute('CREATE TABLE irc_wikimedia_org_en_wikipedia ( id integer primary key autoincrement,
      article_name varchar(128) not null,
      desc varchar(8),
      revision_id integer,
      old_id integer,
      user varchar(64),
      byte_diff integer,
      ts timestamp(20),
      description text)')
    @detective = AuthorDetective.new(@db)
    @info = [1,
      '<NAME>',
      'M',
      '392473902',
      '391225974',
      'SD5',
      '+226',
      Time.parse('2010-02-10T22:17:39Z'),
      "fixes, added persondata, typos fixed: august 24 \342\206\222 August 24 using [[Project:AWB|AWB]]"
    ]

   @info2 = [1,
      '<NAME>',
      'M',
      '392473902',
      '391225974',
      'Alice',
      '+226',
      Time.parse('2010-02-10T22:17:39Z'),
      "fixes, added persondata, typos fixed: august 24 \342\206\222 August 24 using [[Project:AWB|AWB]]"
    ]
  end
  
  def test_find_account_history
    account_history = @detective.find_account_history(@info)
    assert_equal([1233505878, 32334381, "rollbacker", 0], [account_history[0], account_history[1], account_history[10], account_history[11]])
  end
  
  def test_investigate
    @detective.setup_table()
    rownum = @detective.investigate(@info)
    assert_equal('1', rownum)
  end
  
  def test_setup_table
    #to test the sql of the table definition<commit_msg>All tests working now<commit_after>require 'test/unit'
require File.dirname(__FILE__) + '/../conf/include'
require 'author_detective.rb'

require 'time'

class MediaWikiApiTest < Test::Unit::TestCase
  def setup
    @db = SQLite3::Database.new(":memory:")
    @db.execute('CREATE TABLE irc_wikimedia_org_en_wikipedia ( id integer primary key autoincrement,
      article_name varchar(128) not null,
      desc varchar(8),
      revision_id integer,
      old_id integer,
      user varchar(64),
      byte_diff integer,
      ts timestamp(20),
      description text)')
    @detective = AuthorDetective.new(@db)
    @info = [1,
      '<NAME>',
      'M',
      '392473902',
      '391225974',
      'SD5',
      '+226',
      Time.parse('2010-02-10T22:17:39Z'),
      "fixes, added persondata, typos fixed: august 24 \342\206\222 August 24 using [[Project:AWB|AWB]]"
    ]

   @info2 = [1,
      '<NAME>',
      'M',
      '392473902',
      '391225974',
      'Alice',
      '+226',
      Time.parse('2010-02-10T22:17:39Z'),
      "fixes, added persondata, typos fixed: august 24 \342\206\222 August 24 using [[Project:AWB|AWB]]"
    ]
  end
  
  def test_find_account_history
    account_history = @detective.find_account_history(@info)
    assert_equal([1233505878, 32334381, "rollbacker", 0], [account_history[0], account_history[1], account_history[10], account_history[11]])
  end
  
  def test_investigate
    @detective.setup_table()
    rownum = @detective.investigate(@info)
    assert_equal(1 , rownum)
  end
  
  def test_setup_table
    #to test the sql of the table definition
{'fraction_non_alphanumeric': 0.13362748187834855, 'fraction_numerical': 0.08509297195083518, 'mean_word_length': 3.2039735099337747, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 7, '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': '2336714', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1101, 'n_words': 238}