<commit_before># encoding: utf-8

require 'minitest_helper'
require 'json'

module Sidekiq
  describe 'WebApiExtension' do
    include Rack::Test::Methods

    def app
      Sidekiq::Web
    end

    before { Sidekiq.redis(&:flushdb) }

    describe 'GET /api/statistic.json' do
      describe 'without jobs' do
        it 'returns empty workers statistic' do
          get '/api/statistic.json'

          response = JSON.parse(last_response.body)
          response['workers'].must_equal []
        end
      end

      describe 'for perfomed jobs' do
        it 'returns workers statistic' do
          middlewared {}
          get '/api/statistic.json'

          response = JSON.parse(last_response.body)
          response['workers'].wont_equal []
          response['workers'].first.keys.must_equal %w[name last_job_status number_of_calls runtime]
        end
      end

      describe 'for any range' do
        before do
          middlewared {}
        end

        describe 'for date range with empty statistic' do<commit_msg>Update test for new codebase<commit_after># encoding: utf-8

require 'minitest_helper'
require 'json'

module Sidekiq
  describe 'WebApiExtension' do
    include Rack::Test::Methods

    def app
      Sidekiq::Web
    end

    before { Sidekiq.redis(&:flushdb) }

    describe 'GET /api/statistic.json' do
      describe 'without jobs' do
        it 'returns empty workers statistic' do
          get '/api/statistic.json'

          response = JSON.parse(last_response.body)
          response['workers'].must_equal []
        end
      end

      describe 'for perfomed jobs' do
        it 'returns workers statistic' do
          middlewared {}
          get '/api/statistic.json'

          response = JSON.parse(last_response.body)
          response['workers'].wont_equal []
          response['workers'].first.keys.must_equal %w[name last_job_status number_of_calls queue runtime]
        end
      end

      describe 'for any range' do
        before do
          middlewared {}
        end

        describe 'for date range with empty statistic' do
{'fraction_non_alphanumeric': 0.08591885441527446, 'fraction_numerical': 0.0009546539379474941, 'mean_word_length': 2.2246153846153844, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1680297', 'n_tokens_mistral': 601, 'n_tokens_neox': 580, 'n_words': 166}