<commit_before>require_relative 'app_controller_test_base'

class TipperControllerTest < AppControllerTestBase

  def self.hex_prefix
    '25E'
  end

  # - - - - - - - - - - - - - - - - - -

  test '3D4',
  'V1: traffic_light_tip uses 7 saver-service calls' do
    in_kata { post_run_tests }
    count_before = saver.log.size
    get '/tipper/traffic_light_tip', params: {
      'format'    => 'js',
      'id'        => kata.id,
      'was_index' => 0,
      'now_index' => 1
    }
    assert_response :success
    count_after = saver.log.size
    #puts [count_before,count_after] # [14,21]
    assert_equal 7, (count_after-count_before)
    assert_equal 1, kata.schema.version
  end

  # - - - - - - - - - - - - - - - - - -

  test '3D5',
  'V1: traffic_light_tip2 uses only one saver-service call' do
    in_kata { post_run_tests }
    count_before = saver.log.size
    get '/tipper/traffic_light_tip2', params: {
         format: :js,
        version: 1,
             id: kata.id,
      was_index: 0,
      now_index: 1
    }
    assert_response :success
    count_after = saver.log.size
    #puts [count_before,count_after] # [14,15]
    assert_equal 1, (count_after-count_before)
    assert_equal 1, kata.schema.version
  end

  # - - - - - - - - - - - - - - - - - -

  test '3D6',
  'V0: traffic_light_tip2 uses only one saver-service call' do
    in_kata(version:0) { post_run_tests }
    count_before = saver.log.size
    get '/tipper/traffic_light_tip2', params: {
         format: :js,
        version: 0,
             id: kata.id,
      was_index: 0,
      now_index: 1
    }
    assert_response :success
    count_after = saver.log.size
    #puts [count_before,count_after] # [15,16]
    assert_equal 1, (count_after-count_before)
    assert_equal 0, kata.schema.version
  end

end<commit_msg>Refactoring; simplify app-controller tipper tests<commit_after>require_relative 'app_controller_test_base'

class TipperControllerTest < AppControllerTestBase

  def self.hex_prefix
    '25E'
  end

  # - - - - - - - - - - - - - - - - - -

  test '3D4',
  'old traffic_light_tip uses 6 saver-service calls' do
    [0,1].each do |version|
      in_kata(version:version) do |kata|
        post_run_tests
        count_before = saver.log.size
        get '/tipper/traffic_light_tip', params:tip_params(version,kata)
        assert_response :success
        count_after = saver.log.size
        diagnostic = [version,count_before,count_after]        
        assert_equal 6, (count_after-count_before), diagnostic
      end
    end
  end

  # - - - - - - - - - - - - - - - - - -

  test '3D5',
  'new traffic_light_tip2 uses only one saver-service call' do
    [0,1].each do |version|
      in_kata(version:version) do |kata|
        post_run_tests
        count_before = saver.log.size
        get '/tipper/traffic_light_tip2', params:tip_params(version,kata)
        assert_response :success
        count_after = saver.log.size
        diagnostic = [version,count_before,count_after]
        assert_equal 1, (count_after-count_before), diagnostic
      end
    end
  end

  # - - - - - - - - - - - - - - - - - -

  def tip_params(version, kata)
    {
         format: :js,
        version: version,
             id: kata.id,
      was_index: 0,
      now_index: 1
    }
  end

end
{'fraction_non_alphanumeric': 0.12172854534388314, 'fraction_numerical': 0.018259281801582473, 'mean_word_length': 2.118595825426945, 'pattern_counts': {'":': 0, '<': 5, '<?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': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6066549', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1178, 'n_words': 226}