typingpool 0.8.13 → 0.8.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -58,21 +58,6 @@ class TestTpFinish < Typingpool::Test::Script
58
58
  end #with_temp_readymade_project do |dir|
59
59
  end
60
60
 
61
- def script_with_vcr(dir, fixture_name, config_path=config_path(dir))
62
- yield([dir, config_path, project_default[:title], *vcr_args(fixture_name)])
63
- end
64
-
65
- def tp_finish_with_vcr(*args)
66
- script_with_vcr(*args){|new_args| tp_finish(*new_args) }
67
- end
68
-
69
- def tp_finish_outside_sandbox_with_vcr(*args)
70
- script_with_vcr(*args){|new_args| tp_finish_outside_sandbox(*new_args) }
71
- end
72
-
73
- def tp_finish_inside_sandbox_with_vcr(*args)
74
- script_with_vcr(*args){|new_args| tp_finish_inside_sandbox(*new_args) }
75
- end
76
61
 
77
62
  def test_tp_finish_on_amazon_hits
78
63
  skip_if_no_amazon_credentials('tp-finish Amazon test')
@@ -153,6 +138,34 @@ class TestTpFinish < Typingpool::Test::Script
153
138
  end #with_temp_readymade_project do...
154
139
  end
155
140
 
141
+
142
+ def test_tp_finish_warns_on_data_loss
143
+ skip_if_no_amazon_credentials('tp-finish warns on data loss test')
144
+ skip_if_no_s3_credentials('tp-finish wanrs on data loss test')
145
+ with_temp_readymade_project do |transcripts_dir|
146
+ copy_fixtures_to_project_dir('tp_finish_4_', File.join(transcripts_dir, project_default[:title]))
147
+ project = Typingpool::Project.new(project_default[:title], Typingpool::Config.file(config_path(transcripts_dir)))
148
+ begin
149
+ assert(File.exist? File.join(project.local, 'data','sandbox-assignment.csv'))
150
+ assert_equal(6, project.local.file('data','sandbox-assignment.csv').as(:csv).reject{|assignment| assignment['hit_id'].to_s.empty? }.count)
151
+ output = tp_review_with_fixture(transcripts_dir, 'tp_finish_9', %w(a r q), false, project_default[:title])
152
+ assert_equal(0, output[:status].to_i)
153
+ assert_equal(1, project_transcript_count(project, 'sandbox-assignment.csv'))
154
+ assert_equal(1, project_hits_rejected(project, 'sandbox-assignment.csv').count)
155
+ assert_equal(1, project_hits_approved(project, 'sandbox-assignment.csv').count)
156
+ assert_equal(1, project_transcript_count(project, 'sandbox-assignment.csv'))
157
+ out, err = tp_finish_inside_sandbox_with_vcr(transcripts_dir, 'tp_finish_10', config_path(transcripts_dir), false, false, %w(s a))
158
+ assert_match(/not been added/, err)
159
+ assert_match(/unreviewed submission/, err)
160
+ assert_equal(2, project_transcript_count(project, 'old-sandbox-assignment.csv'))
161
+ assert_equal(2, project_hits_approved(project, 'old-sandbox-assignment.csv').count)
162
+ ensure
163
+ restore_project_dir_from_fixtures('tp_finish_4_', File.join(transcripts_dir, project_default[:title]))
164
+ end #begin
165
+
166
+ end #with_temp_readymade_project do...
167
+ end
168
+
156
169
  def test_abort_on_config_mismatch
157
170
  skip_if_no_s3_credentials('tp-finish abort on config mismatch test')
158
171
  with_temp_readymade_project do |dir|
@@ -172,4 +185,26 @@ class TestTpFinish < Typingpool::Test::Script
172
185
  end #with_temp_readymade_project do...
173
186
  end
174
187
 
188
+
189
+ def project_hits_rejected(project, csv='sandbox-assignment.csv')
190
+ project.local.file('data', csv).as(:csv).select{|assignment| assignment_rejected?(assignment) }
191
+ end
192
+
193
+ def project_hits_approved(project, csv='sandbox-assignment.csv')
194
+ project.local.file('data', csv).as(:csv).select{|assignment| assignment_approved?(assignment) }
195
+ end
196
+
197
+ def project_hits_pending(project, csv='sandbox-assignment.csv')
198
+ project.local.file('data', csv).as(:csv).reject{|assignment| assignment_approved?(assignment) || assignment_rejected?(assignment)}
199
+ end
200
+
201
+ def assignment_rejected?(assignment)
202
+ assignment['hit_id'].to_s.empty?
203
+ end
204
+
205
+ def assignment_approved?(assignment)
206
+ assignment['transcript'].to_s.match(/\S/)
207
+ end
208
+
209
+
175
210
  end #TestTpFinish
@@ -84,7 +84,7 @@ class TestAmazon < Typingpool::Test
84
84
  assert_instance_of(Typingpool::Transcript::Chunk, hit.transcript)
85
85
  assert_kind_of(RTurk::Hit, hit.at_amazon)
86
86
  assert_instance_of(Typingpool::Amazon::HIT::Full, hit.full)
87
- assert_instance_of(Typingpool::Amazon::HIT::Assignment::Empty, hit.assignment)
87
+ assert_instance_of(Typingpool::Amazon::HIT::Assignment, hit.assignment)
88
88
  end #with_dummy_hit_or_skip
89
89
  end
90
90
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typingpool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.13
4
+ version: 0.8.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tate
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-07 00:00:00.000000000 Z
11
+ date: 2017-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rturk
@@ -259,6 +259,8 @@ files:
259
259
  - lib/typingpool/test/fixtures/tp_finish_3_assignment.csv
260
260
  - lib/typingpool/test/fixtures/tp_finish_3_id.txt
261
261
  - lib/typingpool/test/fixtures/tp_finish_3_time.txt
262
+ - lib/typingpool/test/fixtures/tp_finish_4_id.txt
263
+ - lib/typingpool/test/fixtures/tp_finish_4_sandbox-assignment.csv
262
264
  - lib/typingpool/test/fixtures/tp_make_assignment.csv
263
265
  - lib/typingpool/test/fixtures/tp_make_id.txt
264
266
  - lib/typingpool/test/fixtures/tp_review2a_id.txt
@@ -301,6 +303,7 @@ files:
301
303
  - lib/typingpool/test/fixtures/vcr/tp_assign_6.yml
302
304
  - lib/typingpool/test/fixtures/vcr/tp_assign_7.yml
303
305
  - lib/typingpool/test/fixtures/vcr/tp_finish_1.yml
306
+ - lib/typingpool/test/fixtures/vcr/tp_finish_10.yml
304
307
  - lib/typingpool/test/fixtures/vcr/tp_finish_2.yml
305
308
  - lib/typingpool/test/fixtures/vcr/tp_finish_3.yml
306
309
  - lib/typingpool/test/fixtures/vcr/tp_finish_4.yml
@@ -308,6 +311,7 @@ files:
308
311
  - lib/typingpool/test/fixtures/vcr/tp_finish_6.yml
309
312
  - lib/typingpool/test/fixtures/vcr/tp_finish_7.yml
310
313
  - lib/typingpool/test/fixtures/vcr/tp_finish_8.yml
314
+ - lib/typingpool/test/fixtures/vcr/tp_finish_9.yml
311
315
  - lib/typingpool/test/fixtures/vcr/tp_make_1.yml
312
316
  - lib/typingpool/test/fixtures/vcr/tp_make_2.yml
313
317
  - lib/typingpool/test/script.rb
@@ -327,6 +331,9 @@ files:
327
331
  - test/make_tp_collect_fixture_6.rb
328
332
  - test/make_tp_collect_fixture_7.rb
329
333
  - test/make_tp_collect_fixture_8.rb
334
+ - test/make_tp_finish_fixture_1.rb
335
+ - test/make_tp_finish_fixture_2.rb
336
+ - test/make_tp_finish_fixture_3.rb
330
337
  - test/make_tp_review_fixture_1.rb
331
338
  - test/make_tp_review_fixture_2.rb
332
339
  - test/make_tp_review_fixture_3.rb