Class: Typingpool::Test::Script

Inherits:
Typingpool::Test show all
Includes:
Utility::Test::Script
Defined in:
lib/typingpool/test/script.rb

Instance Method Summary collapse

Methods included from Utility::Test::Script

#assign_default, #audio_files, #call_script, #config_path, #copy_fixtures_to_project_dir, #copy_tp_assign_fixtures, #make_fixture_transcripts_dir, #path_to_script, #project_time, #project_transcript_count, #readymade_project_path, #reconfigure_for_s3, #reconfigure_for_testing, #reconfigure_for_transcripts_dir, #reconfigure_project, #reconfigure_project_csv, #restore_project_dir_from_fixtures, #script_with_vcr, #simulate_failed_audio_upload_in, #split_reviews, #tp_assign, #tp_assign_with_vcr, #tp_collect_with_fixture, #tp_config_with_input, #tp_finish, #tp_finish_inside_sandbox, #tp_finish_inside_sandbox_with_vcr, #tp_finish_outside_sandbox, #tp_finish_outside_sandbox_with_vcr, #tp_finish_with_vcr, #tp_make, #tp_make_with_vcr, #tp_review_with_fixture, #vcr_args, #with_fixtures_in_project_dir, #with_temp_readymade_project, #with_temp_transcripts_dir, #write_config, #write_testing_config_for_transcripts_dir

Methods included from Utility::Test

#add_goodbye_message, #amazon_credentials?, #audio_dir, #broken_url_eventually?, #cleared_vcr_fixture_path_for, #config, #delete_vcr_fixture, #dummy_config, #fixtures_dir, #project_default, #s3_credentials?, #sftp_credentials?, #vcr_core_host_matcher, #vcr_dir, #vcr_load, #vcr_stop, #with_vcr, #working_url_eventually?, #works_eventually?

Methods inherited from Typingpool::Test

#skip_during_vcr_playback, #skip_if_no_amazon_credentials, #skip_if_no_s3_credentials, #skip_if_no_sftp_credentials, #skip_if_no_upload_credentials, #skip_with_message

Instance Method Details

#assert_all_assets_have_upload_status(assignment_csv, type, status) ⇒ Object



44
45
46
47
48
# File 'lib/typingpool/test/script.rb', line 44

def assert_all_assets_have_upload_status(assignment_csv, type, status)
  recorded_uploads = assignment_csv.map{|assignment| assignment["#{type}_uploaded"] }
  refute_empty(recorded_uploads)
  assert_equal(recorded_uploads.count, recorded_uploads.select{|uploaded| uploaded == status }.count)
end

#assert_assignment_csv_has_transcription_count(count, project, which_csv = 'assignment.csv') ⇒ Object



36
37
38
# File 'lib/typingpool/test/script.rb', line 36

def assert_assignment_csv_has_transcription_count(count, project, which_csv='assignment.csv')
  assert_equal(count, project_transcript_count(project, which_csv))
end

#assert_has_partial_transcript(project) ⇒ Object



32
33
34
# File 'lib/typingpool/test/script.rb', line 32

def assert_has_partial_transcript(project)
  assert_has_transcript(project, 'transcript_in_progress.html')
end

#assert_has_transcript(project, transcript_file = 'transcript.html') ⇒ Object



25
26
27
28
29
30
# File 'lib/typingpool/test/script.rb', line 25

def assert_has_transcript(project, transcript_file='transcript.html')
  transcript_path = File.join(project.local, transcript_file)
  assert(File.exist?(transcript_path))
  assert(not((transcript = IO.read(transcript_path)).empty?))
  transcript
end

#assert_html_has_audio_count(count, html) ⇒ Object



40
41
42
# File 'lib/typingpool/test/script.rb', line 40

def assert_html_has_audio_count(count, html)
  assert_equal(count, Nokogiri::HTML(html).css('audio').size)
end

#assert_script_abort_match(args, regex) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/typingpool/test/script.rb', line 50

def assert_script_abort_match(args, regex)
  with_temp_transcripts_dir do |dir|
    exception = assert_raises(Typingpool::Error::Shell) do
      yield([*args, '--config', config_path(dir)])
    end
    assert_match(regex, exception.message)
  end #with_temp_transcripts_dir do...
end

#do_laterObject

Overrides method in Utility::Test::Script



13
14
15
# File 'lib/typingpool/test/script.rb', line 13

def do_later
  Minitest.after_run{ yield }
end

#write_s3_config_with_bad_password(dir, config = Config.file(config_path(dir))) ⇒ Object



17
18
19
20
21
22
# File 'lib/typingpool/test/script.rb', line 17

def write_s3_config_with_bad_password(dir, config=Config.file(config_path(dir)))
  bad_password = 'f'
  refute_equal(config.to_hash['amazon']['secret'], bad_password)
  config.to_hash['amazon']['secret'] = bad_password
  write_config(dir, reconfigure_for_s3(config), '.config_s3_bad')
end