typingpool 0.8.11 → 0.8.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/bin/tp-assign +5 -4
  3. data/bin/tp-collect +16 -6
  4. data/bin/tp-finish +5 -4
  5. data/bin/tp-make +5 -4
  6. data/bin/tp-review +52 -26
  7. data/lib/typingpool/test.rb +4 -126
  8. data/lib/typingpool/test/fixtures/tp_collect_id.txt +1 -1
  9. data/lib/typingpool/test/fixtures/tp_collect_sandbox-assignment.csv +7 -8
  10. data/lib/typingpool/test/fixtures/tp_review2a_id.txt +1 -0
  11. data/lib/typingpool/test/fixtures/tp_review2a_sandbox-assignment.csv +7 -0
  12. data/lib/typingpool/test/fixtures/tp_review2b_id.txt +1 -0
  13. data/lib/typingpool/test/fixtures/tp_review2b_sandbox-assignment.csv +7 -0
  14. data/lib/typingpool/test/fixtures/tp_review3_id.txt +1 -0
  15. data/lib/typingpool/test/fixtures/tp_review3_sandbox-assignment.csv +7 -0
  16. data/lib/typingpool/test/fixtures/tp_review_id.txt +1 -1
  17. data/lib/typingpool/test/fixtures/tp_review_sandbox-assignment.csv +7 -8
  18. data/lib/typingpool/test/fixtures/vcr/tp-collect-1.yml +3176 -1814
  19. data/lib/typingpool/test/fixtures/vcr/tp-collect-2.yml +116 -2641
  20. data/lib/typingpool/test/fixtures/vcr/tp-collect-3.yml +119 -2693
  21. data/lib/typingpool/test/fixtures/vcr/tp-review-1.yml +353 -355
  22. data/lib/typingpool/test/fixtures/vcr/tp-review-2.yml +161 -242
  23. data/lib/typingpool/test/fixtures/vcr/tp-review-3.yml +4716 -0
  24. data/lib/typingpool/test/fixtures/vcr/tp-review-4.yml +741 -0
  25. data/lib/typingpool/test/fixtures/vcr/tp-review-5.yml +248 -0
  26. data/lib/typingpool/test/fixtures/vcr/tp-review-6.yml +233 -0
  27. data/lib/typingpool/test/fixtures/vcr/tp-review-7.yml +4479 -0
  28. data/lib/typingpool/test/fixtures/vcr/tp-review-8.yml +188 -0
  29. data/lib/typingpool/test/fixtures/vcr/tp-review-9.yml +187 -0
  30. data/lib/typingpool/test/script.rb +13 -320
  31. data/lib/typingpool/utility/test.rb +175 -0
  32. data/lib/typingpool/utility/test/script.rb +342 -0
  33. data/lib/typingpool/version.rb +1 -1
  34. data/test/make_amazon_question_fixture.rb +1 -1
  35. data/test/make_tp_collect_fixture_1.rb +18 -19
  36. data/test/make_tp_collect_fixture_2.rb +16 -10
  37. data/test/make_tp_collect_fixture_3.rb +15 -9
  38. data/test/make_tp_collect_fixture_4.rb +19 -11
  39. data/test/make_tp_collect_fixture_5.rb +25 -0
  40. data/test/make_tp_collect_fixture_6.rb +22 -0
  41. data/test/make_tp_collect_fixture_7.rb +22 -0
  42. data/test/make_tp_collect_fixture_8.rb +26 -0
  43. data/test/make_tp_review_fixture_1.rb +18 -19
  44. data/test/make_tp_review_fixture_2.rb +43 -24
  45. data/test/make_tp_review_fixture_3.rb +35 -0
  46. data/test/make_tp_review_fixture_4.rb +56 -0
  47. data/test/test_integration_script_1_tp_config.rb +7 -7
  48. data/test/test_integration_script_2_tp_make.rb +12 -12
  49. data/test/test_integration_script_3_tp_assign.rb +23 -21
  50. data/test/test_integration_script_4_tp_review.rb +156 -23
  51. data/test/test_integration_script_5_tp_collect.rb +33 -24
  52. data/test/test_integration_script_6_tp_finish.rb +23 -20
  53. data/test/test_unit_amazon.rb +4 -2
  54. data/test/test_unit_filer.rb +6 -6
  55. data/test/test_unit_project.rb +2 -2
  56. data/test/test_unit_project_local.rb +2 -2
  57. data/test/test_unit_project_remote.rb +3 -1
  58. data/test/test_unit_template.rb +6 -6
  59. data/test/test_unit_test.rb +3 -3
  60. metadata +23 -3
  61. data/lib/typingpool/app/test.rb +0 -69
@@ -1,3 +1,3 @@
1
1
  module Typingpool
2
- VERSION = '0.8.11'
2
+ VERSION = '0.8.13'
3
3
  end #Typingpool
@@ -11,7 +11,7 @@ class MakeAmazonQuestion < Typingpool::Test::Script
11
11
  with_temp_transcripts_dir do |dir|
12
12
  tp_make(dir)
13
13
  template = Typingpool::Template::Assignment.from_config(assign_default[:template], config_from_dir(dir))
14
- assignment = transcripts_dir_project(dir).local.file('data', 'assignment.csv').as(:csv).read.first
14
+ assignment = Typingpool::Project.new(project_default[:title], Typingpool::Config.file(config_path(dir))).local.file('data', 'assignment.csv').as(:csv).read.first
15
15
  question_html = template.render(assignment)
16
16
  question_url = 'http://example.com/assignments/101.html'
17
17
  assert_match(question_html, /\S/)
@@ -3,24 +3,23 @@
3
3
  $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
4
 
5
5
  require 'typingpool'
6
- require 'typingpool/test'
6
+ require 'typingpool/utility/test/script'
7
7
  require 'fileutils'
8
8
 
9
- class MakeAndAssignProject < Typingpool::Test::Script
10
- def test_prep_for_fixture
11
- dir = make_fixture_project_dir('tp_collect_project_temp')
12
- make_transcripts_dir_config(dir, self.config)
13
- begin
14
- tp_make(dir)
15
- tp_assign(dir)
16
- rescue
17
- FileUtils.remove_entry_secure(dir)
18
- raise
19
- end
20
- #copy key files over to permanent locations within fixture dir
21
- with_fixtures_in_transcripts_dir(dir, 'tp_collect_') do |fixture_path, project_path|
22
- FileUtils.cp(project_path, fixture_path)
23
- end
24
- add_goodbye_message("Temp project assigned in Mechanical Turk sandbox. Complete and approve TWO assignments and run make_tp_collect_fixture_2.rb. Check for assignments at\nhttps://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups\n...and then approve them at\nhttps://requestersandbox.mturk.com/mturk/manageHITs?hitSortType=CREATION_DESCENDING&%2Fsort.x=11&%2Fsort.y=7")
25
- end
26
- end #MakeAndAssignProject
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ dir = make_fixture_transcripts_dir("tp_collect_project_temp")
12
+ write_testing_config_for_transcripts_dir(dir, self.config)
13
+ begin
14
+ tp_make(dir)
15
+ tp_assign(dir, config_path(dir), project_default[:title], '--approval', '5m')
16
+ rescue
17
+ FileUtils.remove_entry_secure(dir)
18
+ raise
19
+ end
20
+ #copy key files over to permanent locations within fixture dir
21
+ with_fixtures_in_project_dir('tp_collect_', File.join(dir, project_default[:title])) do |source_fixture_path, project_fixture_path|
22
+ FileUtils.cp(project_fixture_path, source_fixture_path)
23
+ end
24
+
25
+ STDERR.puts("Temp project assigned in Mechanical Turk sandbox. Complete and approve TWO assignments and run make_tp_collect_fixture_2.rb. Check for assignments at\nhttps://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups\n...and then approve them at\nhttps://requestersandbox.mturk.com/mturk/manageHITs?hitSortType=CREATION_DESCENDING&%2Fsort.x=11&%2Fsort.y=7")
@@ -2,15 +2,21 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
4
 
5
-
6
- require 'typingpool/test'
5
+ require 'typingpool'
6
+ require 'typingpool/utility/test/script'
7
7
  require 'fileutils'
8
8
 
9
- class CollectProjectFixtureGen2 < Typingpool::Test::Script
10
- def test_populate_fixture
11
- fixture_path = File.join(fixtures_dir, 'vcr', 'tp-collect-1')
12
- tp_collect_with_fixture(fixture_project_dir('tp_collect_project_temp'), fixture_path)
13
- assert(File.exists?("#{fixture_path}.yml"))
14
- add_goodbye_message("Initial tp-collect recorded. Please complete and approve TWO more assignments and run make_tp_collect_fixture_3.rb. Check for assignments at\nhttps://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups\n...and then approve them at\nhttps://requestersandbox.mturk.com/mturk/manageHITs?hitSortType=CREATION_DESCENDING&%2Fsort.x=11&%2Fsort.y=7")
15
- end
16
- end
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ fixture_name = 'tp-collect-1'
12
+ transcripts_dir = File.join(fixtures_dir, 'tp_collect_project_temp')
13
+ tp_collect_with_fixture(transcripts_dir, fixture_name, true)
14
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
15
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
16
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
17
+ project = Typingpool::Project.new(project_default[:title], Typingpool::Config.file(config_path(transcripts_dir)))
18
+ transcript_count = project_transcript_count(project, 'sandbox-assignment.csv')
19
+ transcript_count == 2 or abort "Unexpected number of transcripts added to tp-collect project: #{transcript_count}"
20
+
21
+ STDERR.puts("Initial tp-collect recorded. Please complete TWO more assignments, approve ONE, reject ONE, and run make_tp_collect_fixture_3.rb. Check for assignments at\nhttps://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups\n...and then approve one and reject one at\nhttps://requestersandbox.mturk.com/mturk/manageHITs?hitSortType=CREATION_DESCENDING&%2Fsort.x=11&%2Fsort.y=7")
22
+
@@ -2,14 +2,20 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
4
 
5
- require 'typingpool/test'
5
+ require 'typingpool'
6
+ require 'typingpool/utility/test/script'
6
7
  require 'fileutils'
7
8
 
8
- class CollectProjectFixtureGen3 < Typingpool::Test::Script
9
- def test_populate_fixture2
10
- fixture_path = File.join(fixtures_dir, 'vcr', 'tp-collect-2')
11
- tp_collect_with_fixture(fixture_project_dir('tp_collect_project_temp'), fixture_path)
12
- assert(File.exists?("#{fixture_path}.yml"))
13
- add_goodbye_message("Second tp-collect recorded. Please complete and approve THREE more assignments and run make_tp_collect_fixture_4.rb. Check for assignments at\nhttps://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups\n...and then approve them at\nhttps://requestersandbox.mturk.com/mturk/manageHITs?hitSortType=CREATION_DESCENDING&%2Fsort.x=11&%2Fsort.y=7")
14
- end
15
- end
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ fixture_name = 'tp-collect-2'
12
+ transcripts_dir = File.join(fixtures_dir, 'tp_collect_project_temp')
13
+ tp_collect_with_fixture(transcripts_dir, fixture_name, true)
14
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
15
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
16
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
17
+ project = Typingpool::Project.new(project_default[:title], Typingpool::Config.file(config_path(transcripts_dir)))
18
+ transcript_count = project_transcript_count(project, 'sandbox-assignment.csv')
19
+ transcript_count == 3 or abort "Unexpected number of transcripts in tp-collect project: #{transcript_count}"
20
+
21
+ STDERR.puts("Second tp-collect recorded. Please complete TWO more assignments but ONLY APPROVE ONE. Ignore the other. Wait 6 minutes and then run make_tp_collect_fixture_4.rb. Check for assignments at\nhttps://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups\n...and then approve them at\nhttps://requestersandbox.mturk.com/mturk/manageHITs?hitSortType=CREATION_DESCENDING&%2Fsort.x=11&%2Fsort.y=7")
@@ -2,16 +2,24 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
4
 
5
- require 'typingpool/test'
5
+ require 'typingpool'
6
+ require 'typingpool/utility/test/script'
6
7
  require 'fileutils'
7
8
 
8
- class CollectProjectFixtureGen4 < Typingpool::Test::Script
9
- def test_populate_fixture3
10
- fixture_path = File.join(fixtures_dir, 'vcr', 'tp-collect-3')
11
- tp_collect_with_fixture(fixture_project_dir('tp_collect_project_temp'), fixture_path)
12
- assert(File.exists?("#{fixture_path}.yml"))
13
- tp_finish(fixture_project_dir('tp_collect_project_temp'))
14
- remove_fixture_project_dir('tp_collect_project_temp')
15
- add_goodbye_message("Third and final tp-collect recorded. Fixtures for tp-collect testing successfully generated in #{File.dirname(fixture_path)}!")
16
- end
17
- end
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ fixture_name = 'tp-collect-3'
12
+ transcripts_dir = File.join(fixtures_dir, 'tp_collect_project_temp')
13
+ tp_collect_with_fixture(transcripts_dir, fixture_name, true)
14
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
15
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
16
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
17
+ project = Typingpool::Project.new(project_default[:title], Typingpool::Config.file(config_path(transcripts_dir)))
18
+ transcript_count = project_transcript_count(project, 'sandbox-assignment.csv')
19
+ transcript_count == 5 or abort "Unexpected number of transcripts in tp-collect project: #{transcript_count}. Did you wait five full minutes after submitting the assignments?"
20
+
21
+ tp_finish(transcripts_dir, config_path(transcripts_dir), project_default[:title])
22
+ FileUtils.remove_entry_secure(transcripts_dir, :secure => true)
23
+ STDERR.puts("Third tp-collect recorded. Run make_tp_collect_fixture_5.rb")
24
+
25
+
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
+
5
+ require 'typingpool'
6
+ require 'typingpool/utility/test/script'
7
+ require 'fileutils'
8
+
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ dir = make_fixture_transcripts_dir("tp_review3_project_temp")
12
+ write_testing_config_for_transcripts_dir(dir, self.config)
13
+ begin
14
+ tp_make(dir)
15
+ tp_assign(dir, config_path(dir), project_default[:title], '--approval', '5m')
16
+ rescue
17
+ FileUtils.remove_entry_secure(dir)
18
+ raise
19
+ end
20
+ #copy key files over to permanent locations within fixture dir
21
+ with_fixtures_in_project_dir('tp_review3_', File.join(dir, project_default[:title])) do |source_fixture_path, project_fixture_path|
22
+ FileUtils.cp(project_fixture_path, source_fixture_path)
23
+ end
24
+
25
+ STDERR.puts("Temp project assigned in Mechanical Turk sandbox. Complete and approve TWO assignments and run make_tp_collect_fixture_6.rb. Check for assignments at\nhttps://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups\n...and then approve them at\nhttps://requestersandbox.mturk.com/mturk/manageHITs?hitSortType=CREATION_DESCENDING&%2Fsort.x=11&%2Fsort.y=7")
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
+
5
+ require 'typingpool'
6
+ require 'typingpool/utility/test/script'
7
+ require 'fileutils'
8
+
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ fixture_name='tp-review-7'
12
+ transcripts_dir = File.join(fixtures_dir, 'tp_review3_project_temp')
13
+ output = tp_review_with_fixture(transcripts_dir, fixture_name, %w(q), true)
14
+ output[:status].to_i == 0 or abort "Bad exit code: #{output[:status]} err: #{output[:err]}"
15
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
16
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
17
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
18
+ project = Typingpool::Project.new(project_default[:title], Typingpool::Config.file(config_path(transcripts_dir)))
19
+ transcript_count = project_transcript_count(project, 'sandbox-assignment.csv')
20
+ transcript_count == 2 or abort "Unexpected number of transcripts added to tp-review project: #{transcript_count}"
21
+
22
+ STDERR.puts("Fourth tp-collect recorded. Please complete TWO more assignments, approve ONE, reject ONE, and run make_tp_collect_fixture_7.rb. Check for assignments at\nhttps://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups\n...and then approve one and reject one at\nhttps://requestersandbox.mturk.com/mturk/manageHITs?hitSortType=CREATION_DESCENDING&%2Fsort.x=11&%2Fsort.y=7")
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
+
5
+ require 'typingpool'
6
+ require 'typingpool/utility/test/script'
7
+ require 'fileutils'
8
+
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ fixture_name='tp-review-8'
12
+ transcripts_dir = File.join(fixtures_dir, 'tp_review3_project_temp')
13
+ output = tp_review_with_fixture(transcripts_dir, fixture_name, %w(q), true)
14
+ output[:status].to_i == 0 or abort "Bad exit code: #{output[:status]} err: #{output[:err]}"
15
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
16
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
17
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
18
+ project = Typingpool::Project.new(project_default[:title], Typingpool::Config.file(config_path(transcripts_dir)))
19
+ transcript_count = project_transcript_count(project, 'sandbox-assignment.csv')
20
+ transcript_count == 3 or abort "Unexpected number of transcripts added to tp-review project: #{transcript_count}"
21
+
22
+ STDERR.puts("Fifth tp-collect recorded. Please complete TWO more assignments but ONLY APPROVE ONE. Ignore the other. Wait 5 minutes and then run make_tp_collect_fixture_8.rb. Check for assignments at\nhttps://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups\n...and then approve them at\nhttps://requestersandbox.mturk.com/mturk/manageHITs?hitSortType=CREATION_DESCENDING&%2Fsort.x=11&%2Fsort.y=7")
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
+
5
+ require 'typingpool'
6
+ require 'typingpool/utility/test/script'
7
+ require 'fileutils'
8
+
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ fixture_name='tp-review-9'
12
+ transcripts_dir = File.join(fixtures_dir, 'tp_review3_project_temp')
13
+ output = tp_review_with_fixture(transcripts_dir, fixture_name, %w(q), true)
14
+ output[:status].to_i == 0 or abort "Bad exit code: #{output[:status]} err: #{output[:err]}"
15
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
16
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
17
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
18
+ project = Typingpool::Project.new(project_default[:title], Typingpool::Config.file(config_path(transcripts_dir)))
19
+ transcript_count = project_transcript_count(project, 'sandbox-assignment.csv')
20
+ transcript_count == 5 or abort "Unexpected number of transcripts added to tp-review project: #{transcript_count}. Did you wait five full minutes after submitting the assignments?"
21
+
22
+ tp_finish(transcripts_dir, config_path(transcripts_dir), project_default[:title])
23
+ FileUtils.remove_entry_secure(transcripts_dir, :secure => true)
24
+
25
+
26
+ STDERR.puts("Sixth tp-collect recorded. All done!")
@@ -3,24 +3,23 @@
3
3
  $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
4
 
5
5
  require 'typingpool'
6
- require 'typingpool/test'
6
+ require 'typingpool/utility/test/script'
7
7
  require 'fileutils'
8
8
 
9
- class ReviewProjectFixtureGen1 < Typingpool::Test::Script
10
- def test_prep_for_fixture
11
- dir = make_fixture_project_dir('tp_review_project_temp')
12
- make_transcripts_dir_config(dir, self.config)
13
- begin
14
- tp_make(dir)
15
- tp_assign(dir)
16
- rescue
17
- FileUtils.remove_entry_secure(dir)
18
- raise
19
- end
20
- #copy key files over to permanent locations within fixture dir
21
- with_fixtures_in_transcripts_dir(dir, 'tp_review_') do |fixture_path, project_path|
22
- FileUtils.cp(project_path, fixture_path)
23
- end
24
- add_goodbye_message("Temp project assigned in Mechanical Turk sandbox. Complete SIX assignments and run make_tp_review_fixture_2.rb. Check for assignments at\nhttps://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups\n")
25
- end
26
- end #MakeAndAssignProjectForReview
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ dir = make_fixture_transcripts_dir('tp_review_project_temp')
12
+ write_testing_config_for_transcripts_dir(dir, self.config)
13
+ begin
14
+ tp_make(dir)
15
+ tp_assign(dir, config_path(dir), project_default[:title], '--approval', '5m')
16
+ rescue
17
+ FileUtils.remove_entry_secure(dir)
18
+ raise
19
+ end
20
+ #copy key files over to permanent locations within fixture dir
21
+ with_fixtures_in_project_dir('tp_review_', File.join(dir, project_default[:title])) do |source_fixture_path, project_fixture_path|
22
+ FileUtils.cp(project_fixture_path, source_fixture_path)
23
+ end
24
+ STDERR.puts "Temp project assigned in Mechanical Turk sandbox. Complete SIX assignments and run make_tp_review_fixture_2.rb. Check for assignments at\nhttps://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups\n"
25
+
@@ -2,29 +2,48 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
4
 
5
- require 'typingpool/test'
5
+ require 'typingpool'
6
+ require 'typingpool/utility/test/script'
6
7
  require 'fileutils'
7
8
 
8
- class ReviewProjectFixtureGen2 < Typingpool::Test::Script
9
- def test_populate_fixture
10
- fixture_path = File.join(fixtures_dir, 'vcr', 'tp-review-1')
11
- dir = fixture_project_dir('tp_review_project_temp')
12
- output = nil
13
- assert_nothing_raised do
14
- output = tp_review_with_fixture(dir, fixture_path, %w(a r a r s q ))
15
- end
16
- assert_equal(0, output[:status].to_i, "Bad exit code: #{output[:status]} err: #{output[:err]}")
17
- assert(File.exists?("#{fixture_path}.yml"))
18
-
19
- fixture_path = File.join(fixtures_dir, 'vcr', 'tp-review-2')
20
- assert_nothing_raised do
21
- output = tp_review_with_fixture(dir, fixture_path, %w(a r))
22
- end
23
- assert_equal(0, output[:status].to_i, "Bad exit code: #{output[:status]} err: #{output[:err]}")
24
- assert(File.exists?("#{fixture_path}.yml"))
25
-
26
- tp_finish(dir)
27
- remove_fixture_project_dir('tp_review_project_temp')
28
- add_goodbye_message("All done!")
29
- end
30
- end
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ transcripts_dir = File.join(fixtures_dir, 'tp_review_project_temp')
12
+
13
+ fixture_name = 'tp-review-1'
14
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
15
+ output = tp_review_with_fixture(transcripts_dir, fixture_name, %w(a r a r s q ), true, project_default[:title])
16
+ output[:status].to_i == 0 or abort "Bad exit code: #{output[:status]} err: #{output[:err]}"
17
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
18
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
19
+ project = Typingpool::Project.new(project_default[:title], Typingpool::Config.file(config_path(transcripts_dir)))
20
+ transcript_count = project_transcript_count(project, 'sandbox-assignment.csv')
21
+ transcript_count == 2 or abort "Unexpected number of transcripts in project after first run: #{transcript_count}"
22
+
23
+ fixture_name = 'tp-review-2'
24
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
25
+ output = tp_review_with_fixture(transcripts_dir, fixture_name, %w(a q), true, project_default[:title])
26
+ output[:status].to_i == 0 or abort "Bad exit code: #{output[:status]} err: #{output[:err]}"
27
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
28
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
29
+ transcript_count = project_transcript_count(project, 'sandbox-assignment.csv')
30
+ transcript_count == 3 or abort "Unexpected number of transcripts in project after second run: #{transcript_count}"
31
+
32
+
33
+ STDERR.puts "Waiting 6 minutes to make auto-approval fixture, please stand by..."
34
+ sleep 60*6
35
+
36
+
37
+ fixture_name = 'tp-review-6'
38
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
39
+ output = tp_review_with_fixture(transcripts_dir, fixture_name, %w(q), true, project_default[:title])
40
+ output[:status].to_i == 0 or abort "Bad exit code: #{output[:status]} err: #{output[:err]}"
41
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
42
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
43
+ transcript_count = project_transcript_count(project, 'sandbox-assignment.csv')
44
+ transcript_count == 4 or abort "Unexpected number of transcripts in project after third run: #{transcript_count}"
45
+
46
+ tp_finish(transcripts_dir)
47
+ FileUtils.remove_entry_secure(File.join(fixtures_dir, 'tp_review_project_temp'), :secure => true)
48
+ STDERR.puts "All done!"
49
+
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
+
5
+ require 'typingpool'
6
+ require 'typingpool/utility/test/script'
7
+ require 'fileutils'
8
+
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ transcripts_dir = make_fixture_transcripts_dir('tp_review2_projects_temp')
12
+ write_testing_config_for_transcripts_dir(transcripts_dir, self.config)
13
+ projects = [
14
+ {title: project_default[:title], fixture_prefix: 'tp_review2a_'},
15
+ {title: "Second #{project_default[:title]}", fixture_prefix: 'tp_review2b_'}
16
+ ]
17
+ begin
18
+ projects.each do |project|
19
+ tp_make(transcripts_dir, config_path(transcripts_dir), 'mp3', false, '--title', project[:title])
20
+ tp_assign(transcripts_dir, config_path(transcripts_dir), project[:title], '--approval', '5m')
21
+ end
22
+ rescue
23
+ FileUtils.remove_entry_secure(transcripts_dir)
24
+ raise
25
+ end
26
+ #copy key files over to permanent locations within fixture dir
27
+ projects.each do |project|
28
+ with_fixtures_in_project_dir(project[:fixture_prefix], File.join(transcripts_dir, project[:title])) do |source_fixture_path, project_fixture_path|
29
+ FileUtils.cp(project_fixture_path, source_fixture_path)
30
+ end
31
+ end #each do |project|
32
+
33
+ STDERR.puts "Two temp projects assigned in Mechanical Turk sandbox. Complete TWELVE (12) assignments and run make_tp_review_fixture_4.rb. Check for assignments at"
34
+ STDOUT.puts "https://workersandbox.mturk.com/mturk/searchbar?minReward=0.00&searchWords=typingpooltest&selectedSearchType=hitgroups"
35
+ STDERR.puts "\n"
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(File.dirname($0)), 'lib')
4
+
5
+ require 'typingpool'
6
+ require 'typingpool/utility/test/script'
7
+ require 'fileutils'
8
+
9
+ include Typingpool::Utility::Test::Script
10
+
11
+ fixture_name = 'tp-review-3'
12
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
13
+ transcripts_dir = File.join(fixtures_dir, 'tp_review2_projects_temp')
14
+ output = tp_review_with_fixture(transcripts_dir, fixture_name, %w(a r a r s s r a a s a q ), true)
15
+
16
+ output[:status].to_i == 0 or abort "Bad exit code on first run: #{output[:status]} err: #{output[:err]}"
17
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
18
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
19
+ output[:out] or abort "No STDOUT from tp-review, did not collect as required"
20
+ review_count = split_reviews(output[:out]).count - 1
21
+ review_count == 12 or abort "Expected 12 reviews from tp-review, got #{review_count}"
22
+ project_title = Dir.entries(transcripts_dir).reject{|entry| entry.match(/^\./) }
23
+ project = project_title.map{|title| Typingpool::Project.new(title, Typingpool::Config.file(config_path(transcripts_dir))) }
24
+ project_transcript_count(project[0], 'sandbox-assignment.csv') == 2 or abort "Unexpected number of transcripts in project 1 after run 1: #{project_transcript_count(project[0], 'sandbox-assignment.csv')} instead of 2"
25
+ project_transcript_count(project[1], 'sandbox-assignment.csv') == 3 or abort "Unexpected number of transcripts in project 2 after run 1: #{project_transcript_count(project[1], 'sandbox-assignment.csv')} instead of 3"
26
+
27
+ sleep 10
28
+ fixture_name = 'tp-review-4'
29
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
30
+ output = tp_review_with_fixture(transcripts_dir, fixture_name, %w(a r s a), true)
31
+ output[:status].to_i == 0 or abort "Bad exit code on second run: #{output[:status]} err: #{output[:err]}"
32
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
33
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
34
+ output[:out] or abort "No STDOUT from tp-review, did not collect as required"
35
+ review_count = split_reviews(output[:out]).count - 1
36
+ review_count == 4 or abort "Expected 4 reviews from tp-review, got #{review_count}"
37
+ project_transcript_count(project[0], 'sandbox-assignment.csv') == 3 or abort "Unexpected number of transcripts in project 1 after run 2: #{project_transcript_count(project[0], 'sandbox-assignment.csv')} instead of 3"
38
+ project_transcript_count(project[1], 'sandbox-assignment.csv') == 4 or abort "Unexpected number of transcripts in project 2 after run 2: #{project_transcript_count(project[1], 'sandbox-assignment.csv')} instead of 4"
39
+
40
+
41
+ STDERR.puts "Waiting 6 minutes to make auto-approval fixture, please stand by..."
42
+ sleep 60*6
43
+ fixture_name = 'tp-review-5'
44
+ fixture_path = File.join(vcr_dir, fixture_name + '.yml')
45
+ output = tp_review_with_fixture(transcripts_dir, fixture_name, %w(q), true)
46
+ output[:status].to_i == 0 or abort "Bad exit code on third run: #{output[:status]} err: #{output[:err]}"
47
+ File.exists? fixture_path or abort "Can't find fixture as expected at #{fixture_path}"
48
+ (Time.now - File.ctime(fixture_path)) < 60 or abort "Fixture file does not appear newly created at #{fixture_path}"
49
+ project_transcript_count(project[1], 'sandbox-assignment.csv') == 5 or abort "Unexpected number of transcripts in project 2 after run 3: #{project_transcript_count(project[1], 'sandbox-assignment.csv')} instead of 5"
50
+
51
+
52
+ project_title.each do |title|
53
+ tp_finish(transcripts_dir, config_path(transcripts_dir), title)
54
+ end
55
+ FileUtils.remove_entry_secure(File.join(fixtures_dir, 'tp_review2_projects_temp'), :secure => true)
56
+ STDERR.puts "All done!"