<commit_before>require 'minitest/unit'
require 'minitest/pride'
require 'minitest/autorun'
require 'sidekiq-scheduler'
require 'mocha'
require 'multi_json'
require 'mock_redis'

require 'sidekiq'
require 'sidekiq/util'
if Sidekiq.respond_to?(:logger)
  Sidekiq.logger.level = Logger::ERROR
else
  Sidekiq::Util.logger.level = Logger::ERROR
end

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

require 'sidekiq/redis_connection'

#Setup redis mock to avoid having a dependency
# with redis server during tests
class MiniTest::Spec
  before :each do
    redis = MockRedis.new
    client = Object.new(:client)

    redis.stubs(:client).returns(client)
    client.stubs(:location).returns('MockRedis')

    Sidekiq::RedisConnection.stubs(:create).returns(ConnectionPool.new({}) { redis })
  end
end

class SomeJob<commit_msg>Less stubbing and mocking, just a plain MockRedis ConnectioPool<commit_after>require 'minitest/unit'
require 'minitest/pride'
require 'minitest/autorun'
require 'sidekiq-scheduler'
require 'mocha'
require 'multi_json'
require 'mock_redis'

require 'sidekiq'
require 'sidekiq/util'
if Sidekiq.respond_to?(:logger)
  Sidekiq.logger.level = Logger::ERROR
else
  Sidekiq::Util.logger.level = Logger::ERROR
end

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

require 'sidekiq/redis_connection'

#Setup redis mock to avoid having a dependency
# with redis server during tests
$redis = ConnectionPool.new(:timeout => 1, :size => 1) { MockRedis.new }
Sidekiq.redis = $redis

class MiniTest::Spec
  before :each do
    $redis.with_connection { |conn| conn.flushdb }
  end
end

class SomeJob
{'fraction_non_alphanumeric': 0.1256637168141593, 'fraction_numerical': 0.0011799410029498525, 'mean_word_length': 5.4, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1636527', 'n_tokens_mistral': 586, 'n_tokens_neox': 582, 'n_words': 140}