typingpool 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -6
- data/bin/tp-collect +1 -0
- data/bin/tp-make +4 -2
- data/bin/tp-review +1 -0
- data/lib/typingpool/app.rb +0 -30
- data/lib/typingpool/app/test.rb +35 -0
- data/lib/typingpool/test.rb +19 -2
- data/lib/typingpool/test/script.rb +64 -5
- data/lib/typingpool/version.rb +1 -1
- data/test/test_integration_script_1_tp_config.rb +2 -1
- data/test/test_integration_script_2_tp_make.rb +56 -34
- data/test/test_integration_script_3_tp_assign.rb +33 -33
- data/test/test_integration_script_4_tp_review.rb +5 -6
- data/test/test_integration_script_5_tp_collect.rb +4 -6
- data/test/test_integration_script_6_tp_finish.rb +31 -30
- data/test/test_unit_amazon.rb +4 -2
- data/test/test_unit_config.rb +2 -1
- data/test/test_unit_filer.rb +2 -1
- data/test/test_unit_project.rb +2 -3
- data/test/test_unit_project_local.rb +2 -1
- data/test/test_unit_project_remote.rb +4 -9
- data/test/test_unit_template.rb +2 -1
- data/test/test_unit_test.rb +52 -0
- data/test/test_unit_transcript.rb +2 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9684ded37fc04f867ff0149b4c3e5818c406816
|
4
|
+
data.tar.gz: 0ce4f81ef776d2c66a43b7ef36480f1b238dd70c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81e328fc781b70bd82a4c9b8bda7d8fb2b3f339f266967faec6785526452fef5c94ce50802da0df75d2b533d5218a48a662967db981547c70a1dfa0ea35a3a08
|
7
|
+
data.tar.gz: 95849ca6aef153d4868726cb6106761dd101fd1c3efdc31c9c3f99823fad1150f62fdfd7c01636ceb1ccea27d435a8a4875edd2184077b47887e0c607c0a5f87
|
data/Rakefile
CHANGED
@@ -10,14 +10,10 @@ task :test => [:test_unit, :test_integration]
|
|
10
10
|
|
11
11
|
desc "Run unit tests"
|
12
12
|
Rake::TestTask.new('test_unit') do |t|
|
13
|
-
t.
|
14
|
-
'test/test_unit*'
|
15
|
-
]
|
13
|
+
t.pattern = 'test/test_unit*'
|
16
14
|
end
|
17
15
|
|
18
16
|
desc "Run integration tests"
|
19
17
|
Rake::TestTask.new('test_integration') do |t|
|
20
|
-
t.
|
21
|
-
(1..6).map{|n| "test/test_integration_script_#{n}*" }
|
22
|
-
]
|
18
|
+
t.pattern = 'test/test_integration_script*'
|
23
19
|
end
|
data/bin/tp-collect
CHANGED
@@ -18,6 +18,7 @@ OptionParser.new do |commands|
|
|
18
18
|
commands.on('--fixture=PATH',
|
19
19
|
"Optional. For testing purposes only.",
|
20
20
|
"A VCR ficture for running with mock data.") do |fixture|
|
21
|
+
require 'typingpool/app/test'
|
21
22
|
options[:fixture] = fixture
|
22
23
|
end
|
23
24
|
commands.on('--help',
|
data/bin/tp-make
CHANGED
@@ -164,8 +164,10 @@ else
|
|
164
164
|
FileUtils.remove_entry_secure(temp_conversion_dir)
|
165
165
|
end #if project.local
|
166
166
|
|
167
|
-
|
168
|
-
|
167
|
+
unless options[:devtest]
|
168
|
+
Typingpool::App.upload_audio_for_project(project) do |file, as|
|
169
|
+
STDERR.puts "Uploading #{File.basename(file)} to #{project.remote.host}/#{project.remote.path} as #{as}"
|
170
|
+
end
|
169
171
|
end
|
170
172
|
|
171
173
|
if STDOUT.tty? && Typingpool::Utility.os_x?
|
data/bin/tp-review
CHANGED
@@ -29,6 +29,7 @@ OptionParser.new do |commands|
|
|
29
29
|
commands.on('--fixture=PATH',
|
30
30
|
"Optional. For testing purposes only.",
|
31
31
|
"A VCR fixture for running with mock data") do |fixture|
|
32
|
+
require 'typingpool/app/test'
|
32
33
|
options[:fixture] = fixture
|
33
34
|
end
|
34
35
|
commands.on('--help',
|
data/lib/typingpool/app.rb
CHANGED
@@ -11,7 +11,6 @@ module Typingpool
|
|
11
11
|
#As such, all App methods should be considered fluid and likely to
|
12
12
|
#change in subsequent releases.
|
13
13
|
module App
|
14
|
-
require 'vcr'
|
15
14
|
require 'stringio'
|
16
15
|
require 'open3'
|
17
16
|
class << self
|
@@ -424,35 +423,6 @@ module Typingpool
|
|
424
423
|
yield(missing) unless missing.empty?
|
425
424
|
end
|
426
425
|
|
427
|
-
#Begins recording of an HTTP mock fixture (for automated
|
428
|
-
#testing) using the great VCR gem. Automatically filters your
|
429
|
-
#Config#amazon#key and Config#amazon#secret from the recorded
|
430
|
-
#fixture, and automatically determines the "cassette" name and
|
431
|
-
#"cassette library" dir from the supplied path.
|
432
|
-
# ==== Params
|
433
|
-
# [fixture_path] Path to where you want the HTTP fixture
|
434
|
-
# recorded, including filename.
|
435
|
-
# [config] A Config instance, used to extract the
|
436
|
-
# Config#amazon#secret and Config#amazon#key that
|
437
|
-
# will be filtered from the fixture.
|
438
|
-
# ==== Returns
|
439
|
-
# Result of calling VCR.insert_cassette.
|
440
|
-
def vcr_record(fixture_path, config)
|
441
|
-
VCR.configure do |c|
|
442
|
-
c.cassette_library_dir = File.dirname(fixture_path)
|
443
|
-
c.hook_into :webmock
|
444
|
-
c.filter_sensitive_data('<AWS_KEY>'){ config.amazon.key }
|
445
|
-
c.filter_sensitive_data('<AWS_SECRET>'){ config.amazon.secret }
|
446
|
-
end
|
447
|
-
VCR.insert_cassette(File.basename(fixture_path, '.*'), :record => :new_episodes)
|
448
|
-
end
|
449
|
-
|
450
|
-
#Stops recording of the last call to vcr_record. Returns the
|
451
|
-
#result of VCR.eject_cassette.
|
452
|
-
def vcr_stop
|
453
|
-
VCR.eject_cassette
|
454
|
-
end
|
455
|
-
|
456
426
|
#protected
|
457
427
|
|
458
428
|
def with_abort_on_url_mismatch(url_type='')
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Typingpool
|
2
|
+
module App
|
3
|
+
require 'vcr'
|
4
|
+
class << self
|
5
|
+
#Begins recording of an HTTP mock fixture (for automated
|
6
|
+
#testing) using the great VCR gem. Automatically filters your
|
7
|
+
#Config#amazon#key and Config#amazon#secret from the recorded
|
8
|
+
#fixture, and automatically determines the "cassette" name and
|
9
|
+
#"cassette library" dir from the supplied path.
|
10
|
+
# ==== Params
|
11
|
+
# [fixture_path] Path to where you want the HTTP fixture
|
12
|
+
# recorded, including filename.
|
13
|
+
# [config] A Config instance, used to extract the
|
14
|
+
# Config#amazon#secret and Config#amazon#key that
|
15
|
+
# will be filtered from the fixture.
|
16
|
+
# ==== Returns
|
17
|
+
# Result of calling VCR.insert_cassette.
|
18
|
+
def vcr_record(fixture_path, config)
|
19
|
+
VCR.configure do |c|
|
20
|
+
c.cassette_library_dir = File.dirname(fixture_path)
|
21
|
+
c.hook_into :webmock
|
22
|
+
c.filter_sensitive_data('<AWS_KEY>'){ config.amazon.key }
|
23
|
+
c.filter_sensitive_data('<AWS_SECRET>'){ config.amazon.secret }
|
24
|
+
end
|
25
|
+
VCR.insert_cassette(File.basename(fixture_path, '.*'), :record => :new_episodes)
|
26
|
+
end
|
27
|
+
|
28
|
+
#Stops recording of the last call to vcr_record. Returns the
|
29
|
+
#result of VCR.eject_cassette.
|
30
|
+
def vcr_stop
|
31
|
+
VCR.eject_cassette
|
32
|
+
end
|
33
|
+
end #class << self
|
34
|
+
end #App
|
35
|
+
end #Typingpool
|
data/lib/typingpool/test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Typingpool
|
2
|
-
require 'minitest
|
3
|
-
|
2
|
+
require 'minitest'
|
3
|
+
require 'typingpool/app/test'
|
4
4
|
class Test < Minitest::Test
|
5
5
|
require 'nokogiri'
|
6
6
|
require 'fileutils'
|
@@ -100,6 +100,23 @@ module Typingpool
|
|
100
100
|
Typingpool::Utility.working_url?(*args)
|
101
101
|
end
|
102
102
|
|
103
|
+
def working_url_eventually?(url, max_seconds=10, min_tries=2, max_redirects=6, seeking=true)
|
104
|
+
start = Time.now.to_i
|
105
|
+
tries = 0
|
106
|
+
wait = 0
|
107
|
+
loop do
|
108
|
+
sleep wait
|
109
|
+
return seeking if (working_url?(url, max_redirects) == seeking)
|
110
|
+
wait = wait > 0 ? wait * 2 : 1
|
111
|
+
tries += 1
|
112
|
+
end until (tries >= min_tries) && ((Time.now.to_i + wait - start) >= max_seconds)
|
113
|
+
not seeking
|
114
|
+
end
|
115
|
+
|
116
|
+
def broken_url_eventually?(url, max_seconds=10, min_tries=2, max_redirects=6)
|
117
|
+
not(working_url_eventually?(url, max_seconds, min_tries, max_redirects, false))
|
118
|
+
end
|
119
|
+
|
103
120
|
def fetch_url(*args)
|
104
121
|
Typingpool::Utility.fetch_url(*args)
|
105
122
|
end
|
@@ -4,7 +4,64 @@ module Typingpool
|
|
4
4
|
require 'typingpool'
|
5
5
|
require 'yaml'
|
6
6
|
require 'open3'
|
7
|
+
require 'fileutils'
|
7
8
|
|
9
|
+
@@readymade_project_path = nil
|
10
|
+
|
11
|
+
def self.readymade_project_container=(path)
|
12
|
+
@@readymade_project_path = path
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.readymade_project_container
|
16
|
+
@@readymade_project_path
|
17
|
+
end
|
18
|
+
|
19
|
+
def with_temp_readymade_project
|
20
|
+
in_temp_tp_dir do |dir|
|
21
|
+
setup_readymade_project_into(config_path(dir))
|
22
|
+
yield(dir)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def setup_readymade_project_into(config_path)
|
27
|
+
init_readymade_project
|
28
|
+
copy_readymade_project_into(config_path)
|
29
|
+
reconfigure_readymade_project_in(config_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def init_readymade_project
|
33
|
+
unless Typingpool::Test::Script.readymade_project_container
|
34
|
+
dir = Typingpool::Test::Script.readymade_project_container = Dir.mktmpdir('typingpool_')
|
35
|
+
Minitest.after_run{ FileUtils.remove_entry_secure(dir) }
|
36
|
+
setup_temp_tp_dir(dir)
|
37
|
+
tp_make(dir, config_path(dir), 'mp3', true)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def copy_readymade_project_into(config_path)
|
42
|
+
config = Typingpool::Config.file(config_path)
|
43
|
+
FileUtils.cp_r(temp_tp_dir_project_dir(Typingpool::Test::Script.readymade_project_container), config.transcripts)
|
44
|
+
end
|
45
|
+
|
46
|
+
def reconfigure_readymade_project_in(config_path)
|
47
|
+
#rewrite URLs in assignment.csv according to config at config_path
|
48
|
+
project = Project.new(project_default[:title], Config.file(config_path))
|
49
|
+
File.delete(project.local.file('data', 'id.txt'))
|
50
|
+
project.local.create_id
|
51
|
+
id = project.local.id
|
52
|
+
assignments = project.local.file('data', 'assignment.csv').as(:csv)
|
53
|
+
urls = project.create_remote_names(assignments.map{|assignment| Project.local_basename_from_url(assignment['audio_url']) }).map{|file| project.remote.file_to_url(file) }
|
54
|
+
assignments.each! do |assignment|
|
55
|
+
assignment['audio_url'] = urls.shift
|
56
|
+
assignment['project_id'] = id
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def simulate_failed_audio_upload_in(config_path)
|
61
|
+
project = Project.new(project_default[:title], Config.file(config_path))
|
62
|
+
csv = project.local.file('data', 'assignment.csv').as(:csv)
|
63
|
+
csv.each!{|a| a['audio_uploaded'] = 'maybe'}
|
64
|
+
end
|
8
65
|
|
9
66
|
def audio_files(subdir='mp3')
|
10
67
|
dir = File.join(audio_dir, subdir)
|
@@ -26,7 +83,7 @@ module Typingpool
|
|
26
83
|
|
27
84
|
|
28
85
|
def in_temp_tp_dir
|
29
|
-
|
86
|
+
Dir.mktmpdir('typingpool_') do |dir|
|
30
87
|
setup_temp_tp_dir(dir)
|
31
88
|
yield(dir)
|
32
89
|
end
|
@@ -83,17 +140,19 @@ module Typingpool
|
|
83
140
|
end
|
84
141
|
|
85
142
|
def call_tp_make(*args)
|
86
|
-
call_script(path_to_tp_make, *args
|
143
|
+
call_script(path_to_tp_make, *args)
|
87
144
|
end
|
88
145
|
|
89
|
-
def tp_make(in_dir, config=config_path(in_dir), audio_subdir='mp3')
|
90
|
-
|
146
|
+
def tp_make(in_dir, config=config_path(in_dir), audio_subdir='mp3', devtest_mode_skipping_upload=false)
|
147
|
+
commands = [
|
91
148
|
'--config', config,
|
92
149
|
'--chunks', project_default[:chunks],
|
93
150
|
*[:title, :subtitle].map{|param| ["--#{param}", project_default[param]] }.flatten,
|
94
151
|
*[:voice, :unusual].map{|param| project_default[param].map{|value| ["--#{param}", value] } }.flatten,
|
95
152
|
*audio_files(audio_subdir).map{|path| ['--file', path]}.flatten
|
96
|
-
|
153
|
+
]
|
154
|
+
commands.push('--devtest') if devtest_mode_skipping_upload
|
155
|
+
call_tp_make(*commands)
|
97
156
|
end
|
98
157
|
|
99
158
|
def path_to_tp_finish
|
data/lib/typingpool/version.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(File.dirname(__FILE__)), 'lib')
|
4
4
|
|
5
|
+
require 'minitest/autorun'
|
5
6
|
require 'typingpool'
|
6
7
|
require 'typingpool/test'
|
7
|
-
require 'csv'
|
8
8
|
require 'open3'
|
9
9
|
|
10
10
|
class TestTpMake < Typingpool::Test::Script
|
@@ -25,58 +25,80 @@ class TestTpMake < Typingpool::Test::Script
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def assert_tp_make_abort_match(args, regex)
|
28
|
+
args.push('--devtest')
|
28
29
|
assert_script_abort_match(args, regex) do |args|
|
29
30
|
call_tp_make(*args)
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
def
|
34
|
+
def tp_make_and_upload_with(dir, config_path)
|
34
35
|
begin
|
35
|
-
tp_make(dir, config_path,
|
36
|
+
tp_make(dir, config_path, 'mp3', false)
|
36
37
|
assert(project = temp_tp_dir_project(dir, Typingpool::Config.file(config_path)))
|
37
|
-
|
38
|
-
|
39
|
-
assert(project.local.subdir('audio','chunks').to_a.size <= 7)
|
40
|
-
assert(project.local.subdir('audio','chunks').to_a.size >= 6)
|
41
|
-
assert_equal(project_default[:subtitle], project.local.subtitle)
|
42
|
-
assignments = project.local.file('data', 'assignment.csv').as(:csv)
|
43
|
-
assert_equal(project.local.subdir('audio','chunks').to_a.size, assignments.count)
|
44
|
-
assert_all_assets_have_upload_status(assignments, ['audio'], 'yes')
|
45
|
-
sleep 4 #pause before checking URLs so remote server has time to fully upload
|
46
|
-
assignments.each do |assignment|
|
47
|
-
assert(assignment['audio_url'])
|
48
|
-
assert(working_url? assignment['audio_url'])
|
49
|
-
assert_equal(assignment['project_id'], project.local.id)
|
50
|
-
assert_equal(assignment['unusual'].split(/\s*,\s*/), project_default[:unusual])
|
51
|
-
project_default[:voice].each_with_index do |voice, i|
|
52
|
-
name, description = voice.split(/\s*,\s*/)
|
53
|
-
assert_equal(name, assignment["voice#{i+1}"])
|
54
|
-
if not(description.to_s.empty?)
|
55
|
-
assert_equal(description, assignment["voice#{i+1}title"])
|
56
|
-
end
|
57
|
-
end #project_default[:voice].each_with_index...
|
58
|
-
end #assignments.each d0....
|
38
|
+
check_project_files(project)
|
39
|
+
check_project_uploads(project)
|
59
40
|
ensure
|
60
41
|
tp_finish_outside_sandbox(dir, config_path)
|
61
42
|
end #begin
|
62
|
-
assert_all_assets_have_upload_status(
|
43
|
+
assert_all_assets_have_upload_status(project.local.file('data', 'assignment.csv').as(:csv), ['audio'], 'no')
|
63
44
|
end
|
64
45
|
|
65
|
-
|
46
|
+
|
47
|
+
def check_project_uploads(project)
|
48
|
+
assignments = project.local.file('data', 'assignment.csv').as(:csv)
|
49
|
+
assert_all_assets_have_upload_status(assignments, ['audio'], 'yes')
|
50
|
+
assignments.each do |assignment|
|
51
|
+
assert(assignment['audio_url'])
|
52
|
+
assert(working_url_eventually? assignment['audio_url'])
|
53
|
+
assert_equal('yes', assignment['audio_uploaded'])
|
54
|
+
end #assignments.each do....
|
55
|
+
end
|
56
|
+
|
57
|
+
def check_project_files(project)
|
58
|
+
assert(project.local)
|
59
|
+
assert(project.local.id)
|
60
|
+
assert(project.local.subdir('audio','chunks').to_a.size <= 7)
|
61
|
+
assert(project.local.subdir('audio','chunks').to_a.size >= 6)
|
62
|
+
assert_equal(project_default[:subtitle], project.local.subtitle)
|
63
|
+
assignments = project.local.file('data', 'assignment.csv').as(:csv)
|
64
|
+
assert_equal(project.local.subdir('audio','chunks').to_a.size, assignments.count)
|
65
|
+
assignments.each do |assignment|
|
66
|
+
assert_equal(assignment['project_id'], project.local.id)
|
67
|
+
assert_equal(assignment['unusual'].split(/\s*,\s*/), project_default[:unusual])
|
68
|
+
project_default[:voice].each_with_index do |voice, i|
|
69
|
+
name, description = voice.split(/\s*,\s*/)
|
70
|
+
assert_equal(name, assignment["voice#{i+1}"])
|
71
|
+
if not(description.to_s.empty?)
|
72
|
+
assert_equal(description, assignment["voice#{i+1}title"])
|
73
|
+
end
|
74
|
+
end #project_default[:voice].each_with_index...
|
75
|
+
end #assignments.each do....
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_tp_make_audio_handling
|
66
79
|
Dir.entries(audio_dir).select{|entry| File.directory?(File.join(audio_dir, entry))}.reject{|entry| entry.match(/^\./) }.each do |subdir|
|
67
80
|
in_temp_tp_dir do |dir|
|
68
81
|
config_path = self.config_path(dir)
|
69
|
-
skip_if_no_upload_credentials('tp-make
|
70
|
-
|
82
|
+
skip_if_no_upload_credentials('tp-make audio handling test', Typingpool::Config.file(config_path))
|
83
|
+
tp_make(dir, config_path, subdir, true)
|
84
|
+
assert(project = temp_tp_dir_project(dir, Typingpool::Config.file(config_path)))
|
85
|
+
check_project_files(project)
|
71
86
|
end #in_temp_tp_dir
|
72
87
|
end #Dir.entries
|
73
88
|
end
|
74
89
|
|
90
|
+
def test_tp_make_sftp
|
91
|
+
in_temp_tp_dir do |dir|
|
92
|
+
skip_if_no_sftp_credentials('tp-make SFTP upload test', config)
|
93
|
+
tp_make_and_upload_with(dir, config_path(dir))
|
94
|
+
end #in_temp_tp_dir do...
|
95
|
+
end
|
96
|
+
|
75
97
|
def test_tp_make_s3
|
76
98
|
in_temp_tp_dir do |dir|
|
77
99
|
skip_if_no_s3_credentials('tp-make S3 integration test', config)
|
78
100
|
config_path = setup_s3_config(dir)
|
79
|
-
|
101
|
+
tp_make_and_upload_with(dir, config_path)
|
80
102
|
end #in_temp_tp_dir do...
|
81
103
|
end
|
82
104
|
|
@@ -110,8 +132,7 @@ class TestTpMake < Typingpool::Test::Script
|
|
110
132
|
audio_urls.each_with_index do |original_url, i|
|
111
133
|
assert_equal(original_url, audio_urls2[i])
|
112
134
|
end
|
113
|
-
|
114
|
-
assert_equal(audio_urls.count, audio_urls2.select{|url| working_url? url }.count)
|
135
|
+
assert_equal(audio_urls.count, audio_urls2.select{|url| working_url_eventually? url }.count)
|
115
136
|
ensure
|
116
137
|
tp_finish_outside_sandbox(dir, good_config_path)
|
117
138
|
end #begin
|
@@ -125,8 +146,9 @@ class TestTpMake < Typingpool::Test::Script
|
|
125
146
|
skip_if_no_upload_credentials('tp-make audio file sorting test', Typingpool::Config.file(config_path))
|
126
147
|
assert(audio_files('mp3').count > 1)
|
127
148
|
correctly_ordered_paths = audio_files('mp3').sort
|
128
|
-
|
149
|
+
tp_make(dir, config_path, 'mp3', true)
|
129
150
|
assert(project = temp_tp_dir_project(dir))
|
151
|
+
check_project_files(project)
|
130
152
|
assert(merged_audio_file = project.local.subdir('audio','originals').files.detect{|filer| filer.path.match(/.\.all\../)})
|
131
153
|
assert(File.exists? merged_audio_file)
|
132
154
|
actually_ordered_paths = originals_from_merged_audio_file(merged_audio_file)
|
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(File.dirname(__FILE__)), 'lib')
|
4
4
|
|
5
|
+
require 'minitest/autorun'
|
5
6
|
require 'typingpool'
|
6
7
|
require 'typingpool/test'
|
7
8
|
|
@@ -39,8 +40,7 @@ class TestTpAssign < Typingpool::Test::Script
|
|
39
40
|
def test_tp_assign
|
40
41
|
skip_if_no_amazon_credentials('tp-assign integration test')
|
41
42
|
skip_if_no_upload_credentials('tp-assign integration test')
|
42
|
-
|
43
|
-
tp_make(dir)
|
43
|
+
with_temp_readymade_project do |dir|
|
44
44
|
begin
|
45
45
|
tp_assign(dir)
|
46
46
|
assign_time = Time.now
|
@@ -65,88 +65,88 @@ class TestTpAssign < Typingpool::Test::Script
|
|
65
65
|
tp_finish(dir)
|
66
66
|
end #begin
|
67
67
|
assert_empty(Typingpool::Amazon::HIT.all_for_project(project.local.id))
|
68
|
-
end #
|
68
|
+
end #with_temp_readymade_project do...
|
69
69
|
end
|
70
70
|
|
71
71
|
def test_uploads_audio_when_needed
|
72
72
|
skip_if_no_amazon_credentials('tp-assign unuploaded audio integration test')
|
73
73
|
skip_if_no_s3_credentials('tp-assign unuploaded audio integration test')
|
74
|
-
|
75
|
-
good_config_path = setup_s3_config(dir)
|
76
|
-
bad_config_path = setup_s3_config_with_bad_password(dir)
|
77
|
-
assert_raises(Typingpool::Error::Shell) do
|
78
|
-
tp_make(dir, bad_config_path, 'mp3')
|
79
|
-
end
|
74
|
+
with_temp_readymade_project do |dir|
|
80
75
|
project_dir = temp_tp_dir_project_dir(dir)
|
81
76
|
assert(File.exists? project_dir)
|
82
77
|
assert(File.directory? project_dir)
|
83
|
-
assert(project = temp_tp_dir_project(dir
|
78
|
+
assert(project = temp_tp_dir_project(dir))
|
84
79
|
csv = project.local.file('data', 'assignment.csv').as(:csv)
|
85
80
|
assert_empty(csv.select{|assignment| working_url? assignment['audio_url']})
|
81
|
+
csv.each!{|a| a['audio_uploaded'] = 'maybe'}
|
86
82
|
assert_all_assets_have_upload_status(csv, ['audio'], 'maybe')
|
87
83
|
begin
|
88
|
-
tp_assign(dir
|
84
|
+
tp_assign(dir)
|
89
85
|
sandbox_csv = project.local.file('data', 'sandbox-assignment.csv').as(:csv)
|
90
86
|
assert_equal(csv.count, sandbox_csv.count)
|
91
|
-
assert_equal(sandbox_csv.count, sandbox_csv.select{|assignment|
|
87
|
+
assert_equal(sandbox_csv.count, sandbox_csv.select{|assignment| working_url_eventually? assignment['audio_url'] }.count)
|
92
88
|
assert_all_assets_have_upload_status(csv, ['audio'], 'yes')
|
93
89
|
ensure
|
94
|
-
tp_finish(dir
|
90
|
+
tp_finish(dir)
|
95
91
|
end #begin
|
96
|
-
end #
|
92
|
+
end #with_temp_readymade_project do...
|
97
93
|
end
|
98
94
|
|
99
95
|
def test_fixing_failed_assignment_html_upload
|
100
96
|
skip_if_no_amazon_credentials('tp-assign failed assignment upload integration test')
|
101
97
|
skip_if_no_s3_credentials('tp-assign failed assignment upload integration test')
|
102
|
-
|
98
|
+
with_temp_readymade_project do |dir|
|
103
99
|
good_config_path = setup_s3_config(dir)
|
100
|
+
reconfigure_readymade_project_in(good_config_path)
|
101
|
+
project = temp_tp_dir_project(dir, Typingpool::Config.file(good_config_path))
|
102
|
+
csv = project.local.file('data', 'assignment.csv').as(:csv)
|
103
|
+
csv.each!{|a| a['audio_uploaded'] = 'maybe'}
|
104
|
+
tp_make(dir, good_config_path)
|
105
|
+
assert_all_assets_have_upload_status(csv, ['audio'], 'yes')
|
104
106
|
bad_config_path = setup_s3_config_with_bad_password(dir)
|
105
|
-
tp_make(dir, good_config_path, 'mp3')
|
106
107
|
begin
|
107
|
-
assert(project = temp_tp_dir_project(dir, Typingpool::Config.file(good_config_path)))
|
108
108
|
assert(project.local)
|
109
109
|
get_assignment_urls = lambda{|csv| csv.map{|assignment| assignment['assignment_url'] }.select{|url| url } }
|
110
|
-
assert_empty(get_assignment_urls.call(
|
110
|
+
assert_empty(get_assignment_urls.call(csv))
|
111
111
|
exception = assert_raises(Typingpool::Error::Shell) do
|
112
112
|
tp_assign(dir, bad_config_path)
|
113
113
|
end #assert_raises...
|
114
114
|
assert_match(/s3 operation fail/i, exception.message)
|
115
115
|
sandbox_csv = project.local.file('data', 'sandbox-assignment.csv').as(:csv)
|
116
116
|
refute_empty(get_assignment_urls.call(sandbox_csv))
|
117
|
-
|
118
|
-
check_assignment_urls.call.each{|checked_out| refute(checked_out) }
|
117
|
+
get_assignment_urls.call(sandbox_csv).each{|url| refute(working_url? url) }
|
119
118
|
assert_all_assets_have_upload_status(sandbox_csv, ['assignment'], 'maybe')
|
120
119
|
tp_assign(dir, good_config_path)
|
121
|
-
|
120
|
+
get_assignment_urls.call(sandbox_csv).each{|url| assert(working_url_eventually? url) }
|
122
121
|
assert_all_assets_have_upload_status(sandbox_csv, ['assignment'], 'yes')
|
123
122
|
ensure
|
124
123
|
tp_finish(dir, good_config_path)
|
125
124
|
end #begin
|
126
|
-
end #
|
125
|
+
end #with_temp_readymade_project do...
|
127
126
|
end
|
128
127
|
|
129
128
|
def test_abort_on_config_mismatch
|
130
129
|
skip_if_no_s3_credentials('tp-assign abort on config mismatch test')
|
131
|
-
|
130
|
+
with_temp_readymade_project do |dir|
|
132
131
|
config = config_from_dir(dir)
|
133
132
|
good_config_path = setup_s3_config(dir, config, '.config_s3_good')
|
134
|
-
|
133
|
+
reconfigure_readymade_project_in(good_config_path)
|
134
|
+
assert(config.amazon.bucket)
|
135
|
+
new_bucket = 'configmismatch-test'
|
136
|
+
refute_equal(new_bucket, config.amazon.bucket)
|
137
|
+
config.amazon.bucket = new_bucket
|
138
|
+
bad_config_path = setup_s3_config(dir, config, '.config_s3_bad')
|
139
|
+
success = false
|
135
140
|
begin
|
136
|
-
tp_finish_outside_sandbox(dir, good_config_path)
|
137
|
-
assert(config.amazon.bucket)
|
138
|
-
new_bucket = 'configmismatch-test'
|
139
|
-
refute_equal(new_bucket, config.amazon.bucket)
|
140
|
-
config.amazon.bucket = new_bucket
|
141
|
-
bad_config_path = setup_s3_config(dir, config, '.config_s3_bad')
|
142
141
|
exception = assert_raises(Typingpool::Error::Shell) do
|
143
142
|
tp_assign(dir, bad_config_path)
|
144
143
|
end #assert_raises...
|
145
144
|
assert_match(/\burls don't look right\b/i, exception.message)
|
145
|
+
success = true
|
146
146
|
ensure
|
147
|
-
tp_finish(dir, good_config_path)
|
147
|
+
tp_finish(dir, good_config_path) unless success
|
148
148
|
end #begin
|
149
|
-
end #
|
149
|
+
end #with_temp_readymade_project do...
|
150
150
|
end
|
151
151
|
|
152
152
|
end #TestTpAssign
|
@@ -1,21 +1,21 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(File.dirname(__FILE__)), 'lib')
|
4
4
|
|
5
|
+
require 'minitest/autorun'
|
5
6
|
require 'typingpool'
|
6
7
|
require 'typingpool/test'
|
7
8
|
|
8
9
|
class TestTpReview < Typingpool::Test::Script
|
9
10
|
|
10
11
|
def test_tp_review
|
11
|
-
|
12
|
+
with_temp_readymade_project do |dir|
|
12
13
|
skip_if_no_upload_credentials('tp-review integration test')
|
13
14
|
skip_if_no_amazon_credentials('tp-review integration test')
|
14
|
-
tp_make(dir)
|
15
15
|
copy_fixtures_to_temp_tp_dir(dir, 'tp_review_')
|
16
16
|
assert(File.exists? File.join(temp_tp_dir_project_dir(dir), 'data','sandbox-assignment.csv'))
|
17
17
|
project = temp_tp_dir_project(dir)
|
18
|
-
|
18
|
+
assert_equal(7, project.local.file('data','sandbox-assignment.csv').as(:csv).reject{|assignment| assignment['hit_id'].to_s.empty? }.count)
|
19
19
|
begin
|
20
20
|
output = nil
|
21
21
|
output = tp_review_with_fixture(dir, File.join(fixtures_dir, 'vcr', 'tp-review-1'), %w(a r a r s q))
|
@@ -55,9 +55,8 @@ class TestTpReview < Typingpool::Test::Script
|
|
55
55
|
assert_assignment_csv_has_transcription_count(3, project, 'sandbox-assignment.csv')
|
56
56
|
ensure
|
57
57
|
rm_fixtures_from_temp_tp_dir(dir, 'tp_review_')
|
58
|
-
tp_finish(dir)
|
59
58
|
end #begin
|
60
|
-
end #
|
59
|
+
end #with_temp_readymade_project do...
|
61
60
|
end
|
62
61
|
|
63
62
|
def split_reviews(output)
|
@@ -1,18 +1,17 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(File.dirname(__FILE__)), 'lib')
|
4
4
|
|
5
|
+
require 'minitest/autorun'
|
5
6
|
require 'typingpool'
|
6
7
|
require 'typingpool/test'
|
7
8
|
|
8
9
|
class TestTpCollect < Typingpool::Test::Script
|
9
|
-
require 'fileutils'
|
10
10
|
|
11
11
|
def test_tp_collect
|
12
|
-
|
12
|
+
with_temp_readymade_project do |dir|
|
13
13
|
skip_if_no_upload_credentials('tp-collect integration test')
|
14
14
|
skip_if_no_amazon_credentials('tp-collect integration test')
|
15
|
-
tp_make(dir)
|
16
15
|
copy_fixtures_to_temp_tp_dir(dir, 'tp_collect_')
|
17
16
|
begin
|
18
17
|
project = temp_tp_dir_project(dir)
|
@@ -30,9 +29,8 @@ class TestTpCollect < Typingpool::Test::Script
|
|
30
29
|
# assert_assignment_csv_has_transcription_count(7, project, 'sandbox-assignment.csv')
|
31
30
|
ensure
|
32
31
|
rm_fixtures_from_temp_tp_dir(dir, 'tp_collect_')
|
33
|
-
tp_finish(dir)
|
34
32
|
end #begin
|
35
|
-
end #
|
33
|
+
end #with_temp_readymade_project do...
|
36
34
|
end
|
37
35
|
|
38
36
|
end #TestTpCollect
|
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(File.dirname(__FILE__)), 'lib')
|
4
4
|
|
5
|
+
require 'minitest/autorun'
|
5
6
|
require 'typingpool'
|
6
7
|
require 'typingpool/test'
|
7
8
|
|
@@ -9,23 +10,22 @@ class TestTpFinish < Typingpool::Test::Script
|
|
9
10
|
def tp_finish_on_audio_files_with(dir, config_path)
|
10
11
|
skip_if_no_amazon_credentials('tp-finish audio test')
|
11
12
|
skip_if_no_upload_credentials('tp-finish audio test')
|
13
|
+
simulate_failed_audio_upload_in(config_path)
|
12
14
|
tp_make(dir, config_path)
|
13
15
|
project = temp_tp_dir_project(dir, Typingpool::Config.file(config_path))
|
14
16
|
csv = project.local.file('data', 'assignment.csv').as(:csv)
|
15
17
|
urls = csv.map{|assignment| assignment['audio_url'] }
|
16
18
|
refute_empty(urls)
|
17
19
|
assert_all_assets_have_upload_status(csv, ['audio'], 'yes')
|
18
|
-
|
19
|
-
assert_equal(urls.size, urls.select{|url| working_url? url}.size)
|
20
|
+
assert_equal(urls.count, urls.select{|url| working_url_eventually? url}.count)
|
20
21
|
tp_finish_outside_sandbox(dir, config_path)
|
21
|
-
|
22
|
-
assert_empty(urls.select{|url| working_url? url })
|
22
|
+
assert_equal(urls.count, urls.select{|url| broken_url_eventually? url }.count)
|
23
23
|
assert_all_assets_have_upload_status(csv, ['audio'], 'no')
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_tp_finish_on_audio_files_with_sftp
|
27
27
|
skip_if_no_sftp_credentials('tp-finish sftp test')
|
28
|
-
|
28
|
+
with_temp_readymade_project do |dir|
|
29
29
|
config_path = self.config_path(dir)
|
30
30
|
tp_finish_on_audio_files_with(dir, config_path)
|
31
31
|
end
|
@@ -33,10 +33,11 @@ class TestTpFinish < Typingpool::Test::Script
|
|
33
33
|
|
34
34
|
def test_tp_finish_on_audio_files_with_s3
|
35
35
|
skip_if_no_s3_credentials('tp-finish sftp test')
|
36
|
-
|
36
|
+
with_temp_readymade_project do |dir|
|
37
37
|
config = config_from_dir(dir)
|
38
38
|
config.to_hash.delete('sftp')
|
39
39
|
config_path = write_config(config, dir)
|
40
|
+
reconfigure_readymade_project_in(config_path)
|
40
41
|
tp_finish_on_audio_files_with(dir, config_path)
|
41
42
|
end
|
42
43
|
end
|
@@ -44,12 +45,13 @@ class TestTpFinish < Typingpool::Test::Script
|
|
44
45
|
def test_tp_finish_on_amazon_hits
|
45
46
|
skip_if_no_amazon_credentials('tp-finish Amazon test')
|
46
47
|
skip_if_no_upload_credentials('tp-finish Amazon test')
|
47
|
-
|
48
|
-
tp_make(dir)
|
48
|
+
with_temp_readymade_project do |dir|
|
49
49
|
tp_assign(dir)
|
50
50
|
project = temp_tp_dir_project(dir)
|
51
|
+
csv = project.local.file('data', 'assignment.csv').as(:csv)
|
51
52
|
sandbox_csv = project.local.file('data', 'sandbox-assignment.csv').as(:csv)
|
52
|
-
assert_all_assets_have_upload_status(sandbox_csv, ['
|
53
|
+
assert_all_assets_have_upload_status(sandbox_csv, ['assignment'], 'yes')
|
54
|
+
assert_all_assets_have_upload_status(csv, ['audio'], 'yes')
|
53
55
|
setup_amazon(dir)
|
54
56
|
results = Typingpool::Amazon::HIT.all_for_project(project.local.id)
|
55
57
|
refute_empty(results)
|
@@ -67,21 +69,22 @@ class TestTpFinish < Typingpool::Test::Script
|
|
67
69
|
end #begin
|
68
70
|
end #results.each...
|
69
71
|
refute(File.exists? sandbox_csv)
|
70
|
-
assert_all_assets_have_upload_status(
|
71
|
-
end #
|
72
|
+
assert_all_assets_have_upload_status(csv, ['audio'], 'no')
|
73
|
+
end #with_temp_readymade_project do...
|
72
74
|
end
|
73
75
|
|
74
76
|
def test_tp_finish_with_missing_files
|
75
77
|
skip_if_no_amazon_credentials('tp-finish missing files test')
|
76
78
|
skip_if_no_upload_credentials('tp-finish missing files test')
|
77
|
-
|
79
|
+
with_temp_readymade_project do |dir|
|
78
80
|
project = nil
|
81
|
+
simulate_failed_audio_upload_in(config_path(dir))
|
79
82
|
tp_make(dir)
|
80
83
|
begin
|
81
84
|
project = temp_tp_dir_project(dir)
|
82
85
|
assignments = project.local.file('data', 'assignment.csv').as(:csv).read
|
83
86
|
urls = assignments.map{|assignment| assignment['audio_url'] }
|
84
|
-
|
87
|
+
assert_equal(urls.count, urls.select{|url| working_url_eventually? url }.count)
|
85
88
|
bogus_url = urls.first.sub(/\.mp3/, '.foo.mp3')
|
86
89
|
refute_equal(urls.first, bogus_url)
|
87
90
|
refute(working_url? bogus_url)
|
@@ -89,21 +92,23 @@ class TestTpFinish < Typingpool::Test::Script
|
|
89
92
|
bogus_assignment['audio_url'] = bogus_url
|
90
93
|
assignments.insert(1, bogus_assignment)
|
91
94
|
project.local.file('data', 'assignment.csv').as(:csv).write(assignments)
|
92
|
-
|
95
|
+
assignments = project.local.file('data', 'assignment.csv').as(:csv).read
|
96
|
+
refute(working_url? assignments[1]['audio_url'])
|
93
97
|
ensure
|
94
98
|
tp_finish_outside_sandbox(dir)
|
95
99
|
end #begin
|
96
|
-
|
97
|
-
|
100
|
+
urls = project.local.file('data', 'assignment.csv').as(:csv).map{|assignment| assignment['audio_url'] }
|
101
|
+
assert_equal(urls.count, urls.select{|url| broken_url_eventually? url }.count)
|
102
|
+
end #with_temp_readymade_project do...
|
98
103
|
end
|
99
104
|
|
100
|
-
def test_abort_on_config_mismatch
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
105
|
+
def test_abort_on_config_mismatch
|
106
|
+
skip_if_no_s3_credentials('tp-finish abort on config mismatch test')
|
107
|
+
with_temp_readymade_project do |dir|
|
108
|
+
config = config_from_dir(dir)
|
109
|
+
good_config_path = setup_s3_config(dir, config, '.config_s3_good')
|
110
|
+
reconfigure_readymade_project_in(good_config_path)
|
111
|
+
simulate_failed_audio_upload_in(good_config_path)
|
107
112
|
assert(config.amazon.bucket)
|
108
113
|
new_bucket = 'configmismatch-test'
|
109
114
|
refute_equal(new_bucket, config.amazon.bucket)
|
@@ -113,11 +118,7 @@ def test_abort_on_config_mismatch
|
|
113
118
|
tp_finish_outside_sandbox(dir, bad_config_path)
|
114
119
|
end #assert_raises...
|
115
120
|
assert_match(/\burls don't look right\b/i, exception.message)
|
116
|
-
|
117
|
-
|
118
|
-
end #begin
|
119
|
-
end #in_temp_tp_dir do...
|
120
|
-
|
121
|
-
end
|
121
|
+
end #with_temp_readymade_project do...
|
122
|
+
end
|
122
123
|
|
123
124
|
end #TestTpFinish
|
data/test/test_unit_amazon.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(File.dirname(__FILE__)), 'lib')
|
4
4
|
|
5
|
+
require 'minitest/autorun'
|
5
6
|
require 'typingpool'
|
6
7
|
require 'typingpool/test'
|
7
8
|
require 'uri'
|
@@ -137,7 +138,8 @@ class TestAmazon < Typingpool::Test
|
|
137
138
|
with_dummy_typingpool_hit_or_skip('test_handles_hits_with_broken_external_question', url) do |hit, config|
|
138
139
|
assert_equal(hit.full.external_question_url, url)
|
139
140
|
refute(hit.full.external_question)
|
140
|
-
|
141
|
+
refute(hit.full.external_question_param(hit.class.url_at))
|
142
|
+
end #with_dummy....
|
141
143
|
end
|
142
144
|
|
143
145
|
#Lacks test for HIT::Assignment - needs VCR fixture (TODO)
|
data/test/test_unit_config.rb
CHANGED
data/test/test_unit_filer.rb
CHANGED
data/test/test_unit_project.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(File.dirname(__FILE__)), 'lib')
|
4
4
|
|
5
|
+
require 'minitest/autorun'
|
5
6
|
require 'typingpool'
|
6
7
|
require 'typingpool/test'
|
7
|
-
require 'tmpdir'
|
8
|
-
require 'fileutils'
|
9
8
|
require 'uri'
|
10
9
|
|
11
10
|
class TestProject < Typingpool::Test
|
@@ -1,12 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(File.dirname(__FILE__)), 'lib')
|
4
4
|
|
5
|
+
require 'minitest/autorun'
|
5
6
|
require 'typingpool'
|
6
7
|
require 'typingpool/test'
|
7
8
|
require 'stringio'
|
8
9
|
require 'aws-sdk'
|
9
|
-
require 'securerandom'
|
10
10
|
|
11
11
|
class TestProjectRemote < Typingpool::Test
|
12
12
|
def test_project_remote_from_config
|
@@ -101,7 +101,6 @@ class TestProjectRemote < Typingpool::Test
|
|
101
101
|
:test_with => lambda{|urls| urls.each_with_index{|url, i| assert_includes(url, basenames[i]) } }
|
102
102
|
)
|
103
103
|
|
104
|
-
sleep 5
|
105
104
|
#now with different basenames
|
106
105
|
remote_basenames = basenames.map{|name| [File.basename(name, '.*'), pseudo_random_chars, File.extname(name)].join }
|
107
106
|
base_args = {
|
@@ -116,7 +115,6 @@ class TestProjectRemote < Typingpool::Test
|
|
116
115
|
)
|
117
116
|
)
|
118
117
|
|
119
|
-
sleep 5
|
120
118
|
#now using remove_urls for removal
|
121
119
|
put_remove_test(
|
122
120
|
base_args.merge(
|
@@ -125,7 +123,6 @@ class TestProjectRemote < Typingpool::Test
|
|
125
123
|
)
|
126
124
|
)
|
127
125
|
|
128
|
-
sleep 5
|
129
126
|
#now with stringio streams
|
130
127
|
put_remove_test(
|
131
128
|
base_args.merge(
|
@@ -164,14 +161,12 @@ class TestProjectRemote < Typingpool::Test
|
|
164
161
|
assert(urls = args[:remote].put(*put_args))
|
165
162
|
begin
|
166
163
|
assert_equal(args[:streams].count, urls.count)
|
167
|
-
|
168
|
-
urls.each{|url| assert(working_url?(url)) }
|
164
|
+
urls.each{|url| assert(working_url_eventually?(url)) }
|
169
165
|
args[:test_with].call(urls) if args[:test_with]
|
170
166
|
ensure
|
171
167
|
args[:remove_with].call(urls)
|
172
168
|
end #begin
|
173
|
-
|
174
|
-
urls.each{|url| refute(working_url?(url)) }
|
169
|
+
urls.each{|url| assert(broken_url_eventually?(url)) }
|
175
170
|
urls
|
176
171
|
end
|
177
172
|
|
data/test/test_unit_template.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(File.dirname(__FILE__)), 'lib')
|
4
|
+
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require 'typingpool'
|
7
|
+
require 'typingpool/test'
|
8
|
+
require 'set'
|
9
|
+
|
10
|
+
class TestTest < Typingpool::Test::Script
|
11
|
+
|
12
|
+
def test_readymade_project
|
13
|
+
in_temp_tp_dir do |dir|
|
14
|
+
tp_make(dir, config_path(dir), 'mp3', true)
|
15
|
+
assert_is_proper_tp_dir(dir)
|
16
|
+
assert_has_proper_assignment_csv(dir)
|
17
|
+
end
|
18
|
+
with_temp_readymade_project do |dir|
|
19
|
+
assert_is_proper_tp_dir(dir)
|
20
|
+
assert_has_proper_assignment_csv(dir)
|
21
|
+
end
|
22
|
+
with_temp_readymade_project do |dir|
|
23
|
+
with_temp_readymade_project do |dir2|
|
24
|
+
projects = [temp_tp_dir_project(dir), temp_tp_dir_project(dir2)]
|
25
|
+
refute_equal(projects[0].local.id, projects[1].local.id)
|
26
|
+
['audio_url', 'project_id'].each do |csv_param|
|
27
|
+
param_set = projects.map{|project| Set.new project.local.file('data', 'assignment.csv').as(:csv).select{|a| a[csv_param] } }
|
28
|
+
assert_empty(param_set[0].intersection(param_set[1]))
|
29
|
+
end #['audio_url', 'project_id'].each do...
|
30
|
+
end #with_temp_readymade_project do...
|
31
|
+
end #with_temp_readymade_project do...
|
32
|
+
end
|
33
|
+
|
34
|
+
def assert_is_proper_tp_dir(dir)
|
35
|
+
assert(File.exists? temp_tp_dir_project_dir(dir))
|
36
|
+
assert(File.directory? temp_tp_dir_project_dir(dir))
|
37
|
+
assert(project = temp_tp_dir_project(dir))
|
38
|
+
assert(project.local)
|
39
|
+
assert_equal(3, project.local.subdir('audio', 'originals').files.count)
|
40
|
+
assert_in_delta(6, project.local.subdir('audio', 'chunks').files.count, 1)
|
41
|
+
end
|
42
|
+
|
43
|
+
def assert_has_proper_assignment_csv(dir)
|
44
|
+
assert(project = temp_tp_dir_project(dir))
|
45
|
+
assert(File.exists? project.local.file('data', 'assignment.csv').path)
|
46
|
+
assert(assignments = project.local.file('data', 'assignment.csv').as(:csv).read)
|
47
|
+
assert_equal(project.local.subdir('audio', 'chunks').files.count, assignments.count)
|
48
|
+
assert_equal(assignments.count, assignments.select{|a| a['audio_url']}.count)
|
49
|
+
assignments.each{|a| assert_match(/^https?:\/\/\w+/i, a['audio_url']) }
|
50
|
+
end
|
51
|
+
|
52
|
+
end #class TestTest
|
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.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rturk
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/typingpool/app/cli.rb
|
156
156
|
- lib/typingpool/app/cli/formatter.rb
|
157
157
|
- lib/typingpool/app/friendlyexceptions.rb
|
158
|
+
- lib/typingpool/app/test.rb
|
158
159
|
- lib/typingpool/config.rb
|
159
160
|
- lib/typingpool/config/root.rb
|
160
161
|
- lib/typingpool/error.rb
|
@@ -252,6 +253,7 @@ files:
|
|
252
253
|
- test/test_unit_project_local.rb
|
253
254
|
- test/test_unit_project_remote.rb
|
254
255
|
- test/test_unit_template.rb
|
256
|
+
- test/test_unit_test.rb
|
255
257
|
- test/test_unit_transcript.rb
|
256
258
|
- typingpool.gemspec
|
257
259
|
homepage: http://github.com/ryantate/typingpool
|