cloudfactory 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +5 -0
- data/lib/cf/account.rb +3 -6
- data/lib/cf/cli.rb +8 -12
- data/lib/cf/cli/line.rb +13 -13
- data/lib/cf/cli/production.rb +18 -14
- data/lib/cf/client.rb +2 -12
- data/lib/cf/custom_task_form.rb +1 -3
- data/lib/cf/input_format.rb +1 -3
- data/lib/cf/line.rb +63 -66
- data/lib/cf/robot_worker.rb +3 -5
- data/lib/cf/run.rb +21 -58
- data/lib/cf/station.rb +6 -10
- data/lib/cf/task_form.rb +1 -3
- data/lib/cf/version.rb +1 -1
- data/spec/account_spec.rb +3 -5
- data/spec/badge_spec.rb +64 -64
- data/spec/concept_tagging_robot_spec.rb +37 -37
- data/spec/config_spec.rb +0 -1
- data/spec/content_scraping_robot_spec.rb +38 -38
- data/spec/custom_task_form_spec.rb +106 -105
- data/spec/department_spec.rb +5 -6
- data/spec/entity_extraction_robot_spec.rb +39 -39
- data/spec/form_field_spec.rb +148 -148
- data/spec/google_translate_robot_spec.rb +40 -40
- data/spec/human_worker_spec.rb +87 -87
- data/spec/image_processing_robot_spec.rb +37 -37
- data/spec/input_format_spec.rb +97 -97
- data/spec/keyword_matching_and_text_extraction_robot_spec.rb +56 -56
- data/spec/line_spec.rb +442 -416
- data/spec/mailer_robot_spec.rb +39 -39
- data/spec/media_converter_robot_spec.rb +40 -46
- data/spec/media_splitting_robot_spec.rb +41 -41
- data/spec/robot_worker_spec.rb +8 -8
- data/spec/run_spec.rb +424 -432
- data/spec/sentiment_robot_spec.rb +37 -37
- data/spec/station_spec.rb +209 -207
- data/spec/task_form_spec.rb +79 -79
- data/spec/term_extraction_robot_spec.rb +37 -37
- metadata +48 -48
data/spec/mailer_robot_spec.rb
CHANGED
@@ -5,53 +5,53 @@ module CF
|
|
5
5
|
describe CF::RobotWorker do
|
6
6
|
context "create a mailer robot worker" do
|
7
7
|
it "should create mailer robot worker for first station in Block DSL way" do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
WebMock.allow_net_connect!
|
9
|
+
@template = "<html><body><h1>Hello {{to}} Welcome to CLoudfactory!!!!</h1><p>Thanks for using!!!!</p></body></html>"
|
10
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
11
|
+
sleep 1
|
12
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
13
|
+
CF::InputFormat.new({:line => l, :name => "to", :required => "true"})
|
14
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
15
|
+
CF::RobotWorker.create({:station => s, :type => "mailer_robot", :settings => {:to => ["manish.das@sprout-technology.com"], :template => @template}})
|
16
16
|
end
|
17
|
-
run = CF::Run.create(line, "mailer_robot_run", [{"to"=> "manish.das@sprout-technology.com"}])
|
18
|
-
# sleep 20
|
19
|
-
output = run.final_output
|
20
|
-
output.first['recipients_of_to'].should eql(["manish.das@sprout-technology.com"])
|
21
|
-
output.first['sent_message_for_to'].should eql("<html><body><h1>Hello manish.das@sprout-technology.com Welcome to CLoudfactory!!!!</h1><p>Thanks for using!!!!</p></body></html>")
|
22
|
-
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
23
|
-
line.stations.first.worker.reward.should eql(0.01)
|
24
|
-
line.stations.first.worker.number.should eql(1)
|
25
|
-
line.stations.first.worker.settings.should eql({:to => ["manish.das@sprout-technology.com"], :template => @template})
|
26
|
-
line.stations.first.worker.type.should eql("MailerRobot")
|
27
17
|
end
|
18
|
+
run = CF::Run.create(line, "run-#{title}", [{"to"=> "manish.das@sprout-technology.com"}])
|
19
|
+
sleep 20
|
20
|
+
output = run.final_output
|
21
|
+
output.first['recipients_of_to'].should eql(["manish.das@sprout-technology.com"])
|
22
|
+
output.first['sent_message_for_to'].should eql("<html><body><h1>Hello manish.das@sprout-technology.com Welcome to CLoudfactory!!!!</h1><p>Thanks for using!!!!</p></body></html>")
|
23
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
24
|
+
line.stations.first.worker.reward.should eql(0.01)
|
25
|
+
line.stations.first.worker.number.should eql(1)
|
26
|
+
line.stations.first.worker.settings.should eql({:to => ["manish.das@sprout-technology.com"], :template => @template})
|
27
|
+
line.stations.first.worker.type.should eql("MailerRobot")
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should create mailer robot worker for first station in a plain ruby way" do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
WebMock.allow_net_connect!
|
32
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
33
|
+
sleep 1
|
34
|
+
@template = "<html><body><h1>Hello {{to}} Welcome to CLoudfactory!!!!</h1><p>Thanks for using!!!!</p></body></html>"
|
35
|
+
line = CF::Line.new(title,"Digitization")
|
36
|
+
input_format = CF::InputFormat.new({:name => "to", :required => "true"})
|
37
|
+
line.input_formats input_format
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
station = CF::Station.new({:type => "work"})
|
40
|
+
line.stations station
|
40
41
|
|
41
|
-
|
42
|
-
|
42
|
+
worker = CF::RobotWorker.create({:type => "mailer_robot", :settings => {:to => ["manish.das@sprout-technology.com"], :template => @template}})
|
43
|
+
line.stations.first.worker = worker
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
45
|
+
run = CF::Run.create(line, "run-#{title}", [{"to"=> "manish.das@sprout-technology.com"}])
|
46
|
+
sleep 20
|
47
|
+
output = run.final_output
|
48
|
+
output.first['recipients_of_to'].should eql(["manish.das@sprout-technology.com"])
|
49
|
+
output.first['sent_message_for_to'].should eql("<html><body><h1>Hello manish.das@sprout-technology.com Welcome to CLoudfactory!!!!</h1><p>Thanks for using!!!!</p></body></html>")
|
50
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
51
|
+
line.stations.first.worker.reward.should eql(0.01)
|
52
|
+
line.stations.first.worker.number.should eql(1)
|
53
|
+
line.stations.first.worker.settings.should eql({:to => ["manish.das@sprout-technology.com"], :template => @template})
|
54
|
+
line.stations.first.worker.type.should eql("MailerRobot")\
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -4,63 +4,57 @@ module CF
|
|
4
4
|
describe CF::RobotWorker do
|
5
5
|
context "create a media converter robot worker" do
|
6
6
|
it "should create media_converter_robot worker for first station in a plain ruby way" do
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
WebMock.allow_net_connect!
|
8
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
9
|
+
sleep 1
|
10
|
+
line = CF::Line.new(title,"Digitization")
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
|
13
|
+
line.input_formats input_format
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
input_format_1 = CF::InputFormat.new({:name => "to", :required => false})
|
16
|
+
line.input_formats input_format_1
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
input_format_2 = CF::InputFormat.new({:name => "audio_quality", :required => false})
|
19
|
+
line.input_formats input_format_2
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
input_format_3 = CF::InputFormat.new({:name => "video_quality", :required => false})
|
22
|
+
line.input_formats input_format_3
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
station = CF::Station.new({:type => "work"})
|
25
|
+
line.stations station
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
worker = CF::RobotWorker.create({:type => "media_converter_robot", :settings => {:url => ["{{url}}"], :to => "{{to}}", :audio_quality => "{{audio_quality}}", :video_quality => "{{video_quality}}"}})
|
28
|
+
line.stations.first.worker = worker
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
run = CF::Run.create(line, "media_converter_robot_run", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov", "to" => "mpg", "audio_quality" => "320", "video_quality" => "3"}])
|
36
|
-
# sleep 20
|
37
|
-
@final_output = run.final_output
|
38
|
-
line.stations.first.worker.number.should eq(1)
|
39
|
-
converted_url = @final_output.first['converted_file_from_url']
|
40
|
-
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
|
41
|
-
end
|
30
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov", "to" => "mpg", "audio_quality" => "320", "video_quality" => "3"}])
|
31
|
+
sleep 10
|
32
|
+
final_output = run.final_output
|
33
|
+
line.stations.first.worker.number.should eq(1)
|
34
|
+
converted_url = final_output.first['converted_file_from_url']
|
35
|
+
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
|
42
36
|
end
|
43
|
-
|
37
|
+
|
44
38
|
it "should create media_converter_robot in block DSL way" do
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
39
|
+
WebMock.allow_net_connect!
|
40
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
41
|
+
sleep 1
|
42
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
43
|
+
CF::InputFormat.new({:line => l, :name => "url", :required => true, :valid_type => "url"})
|
44
|
+
CF::InputFormat.new({:line => l, :name => "to", :required => false})
|
45
|
+
CF::InputFormat.new({:line => l, :name => "audio_quality", :required => false})
|
46
|
+
CF::InputFormat.new({:line => l, :name => "video_quality", :required => false})
|
47
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
48
|
+
CF::RobotWorker.create({:station => s, :type => "media_converter_robot", :settings => {:url => ["{{url}}"], :to => "{{to}}", :audio_quality => "{{audio_quality}}", :video_quality => "{{video_quality}}"}})
|
55
49
|
end
|
56
|
-
|
57
|
-
run = CF::Run.create(line, "media_converter_robot_run_1", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov", "to" => "mpg", "audio_quality" => "320", "video_quality" => "3"}])
|
58
|
-
# sleep 20
|
59
|
-
@final_output = run.final_output
|
60
|
-
line.stations.first.worker.number.should eq(1)
|
61
|
-
converted_url = @final_output.first['converted_file_from_url']
|
62
|
-
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
|
63
50
|
end
|
51
|
+
|
52
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov", "to" => "mpg", "audio_quality" => "320", "video_quality" => "3"}])
|
53
|
+
sleep 10
|
54
|
+
@final_output = run.final_output
|
55
|
+
line.stations.first.worker.number.should eq(1)
|
56
|
+
converted_url = @final_output.first['converted_file_from_url']
|
57
|
+
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
|
64
58
|
end
|
65
59
|
end
|
66
60
|
end
|
@@ -5,55 +5,55 @@ module CF
|
|
5
5
|
describe CF::RobotWorker do
|
6
6
|
context "create a media splitting robot worker" do
|
7
7
|
it "should create media splitting robot worker for first station in Block DSL way" do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
WebMock.allow_net_connect!
|
9
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
10
|
+
sleep 1
|
11
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
12
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
13
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
14
|
+
CF::RobotWorker.create({:station => s, :type => "media_splitting_robot", :settings => {:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"}})
|
15
15
|
end
|
16
|
-
run = CF::Run.create(line, "media_splitting_robot_run", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
17
|
-
# sleep 20
|
18
|
-
output = run.final_output
|
19
|
-
converted_url_1= output.first['splits_of_url'].first
|
20
|
-
converted_url_2= output.first['splits_of_url'].last
|
21
|
-
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_1}").should eql(true)
|
22
|
-
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_2}").should eql(true)
|
23
|
-
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
24
|
-
line.stations.first.worker.reward.should eql(0.01)
|
25
|
-
line.stations.first.worker.number.should eql(1)
|
26
|
-
line.stations.first.worker.settings.should eql({:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"})
|
27
|
-
line.stations.first.worker.type.should eql("MediaSplittingRobot")
|
28
16
|
end
|
17
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
18
|
+
sleep 10
|
19
|
+
output = run.final_output
|
20
|
+
converted_url_1= output.first['splits_of_url'].first
|
21
|
+
converted_url_2= output.first['splits_of_url'].last
|
22
|
+
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_1}").should eql(true)
|
23
|
+
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_2}").should eql(true)
|
24
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
25
|
+
line.stations.first.worker.reward.should eql(0.01)
|
26
|
+
line.stations.first.worker.number.should eql(1)
|
27
|
+
line.stations.first.worker.settings.should eql({:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"})
|
28
|
+
line.stations.first.worker.type.should eql("MediaSplittingRobot")
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should create media splitting robot worker for first station in a plain ruby way" do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
WebMock.allow_net_connect!
|
33
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
34
|
+
sleep 1
|
35
|
+
line = CF::Line.new(title,"Digitization")
|
36
|
+
input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
|
37
|
+
line.input_formats input_format
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
station = CF::Station.new({:type => "work"})
|
40
|
+
line.stations station
|
40
41
|
|
41
|
-
|
42
|
-
|
42
|
+
worker = CF::RobotWorker.create({:type => "media_splitting_robot", :settings => {:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"}})
|
43
|
+
line.stations.first.worker = worker
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
45
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
46
|
+
sleep 10
|
47
|
+
output = run.final_output
|
48
|
+
converted_url_1= output.first['splits_of_url'].first
|
49
|
+
converted_url_2= output.first['splits_of_url'].last
|
50
|
+
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_1}").should eql(true)
|
51
|
+
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_2}").should eql(true)
|
52
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
53
|
+
line.stations.first.worker.reward.should eql(0.01)
|
54
|
+
line.stations.first.worker.number.should eql(1)
|
55
|
+
line.stations.first.worker.settings.should eql({:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"})
|
56
|
+
line.stations.first.worker.type.should eql("MediaSplittingRobot")
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
data/spec/robot_worker_spec.rb
CHANGED
@@ -3,16 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe CF::RobotWorker do
|
4
4
|
context "create a robot worker" do
|
5
5
|
it "should only display the attributes which are mentioned in to_s method" do
|
6
|
-
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
WebMock.allow_net_connect!
|
7
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
8
|
+
sleep 1
|
9
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
10
|
+
CF::InputFormat.new({:line => l, :name => "text", :required => "true"})
|
11
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
12
|
+
CF::RobotWorker.create({:station => s, :type => "entity_extraction_robot", :settings => {:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]}})
|
13
13
|
end
|
14
|
-
line.stations.first.worker.to_s.should eql("{:number => #{line.stations.first.worker.number}, :reward => #{line.stations.first.worker.reward}, :type => EntityExtractionRobot, :settings => #{line.stations.first.worker.settings}, :errors => }")
|
15
14
|
end
|
15
|
+
line.stations.first.worker.to_s.should eql("{:number => #{line.stations.first.worker.number}, :reward => #{line.stations.first.worker.reward}, :type => EntityExtractionRobot, :settings => #{line.stations.first.worker.settings}, :errors => }")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/spec/run_spec.rb
CHANGED
@@ -4,447 +4,442 @@ module CF
|
|
4
4
|
describe CF::Run do
|
5
5
|
context "create a new run" do
|
6
6
|
it "for a line in block dsl way" do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
WebMock.allow_net_connect!
|
8
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
9
|
+
sleep 1
|
10
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
11
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
|
12
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
13
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
14
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
15
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
16
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
17
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
18
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
19
19
|
end
|
20
20
|
end
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
+
run = CF::Run.create(line, "run-#{title}", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
|
23
24
|
|
24
|
-
|
25
|
+
line.title.should eq(title)
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
line.input_formats.first.name.should eq("Company")
|
28
|
+
line.input_formats.first.required.should eq(true)
|
28
29
|
|
29
|
-
|
30
|
+
line.stations[0].type.should eq("WorkStation")
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
line.stations[0].worker.number.should eq(1)
|
33
|
+
line.stations[0].worker.reward.should eq(20)
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
line.stations[0].form.title.should eq("Enter text from a business card image")
|
36
|
+
line.stations[0].form.instruction.should eq("Describe")
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
line.stations[0].form.form_fields[0].label.should eq("First Name")
|
39
|
+
line.stations[0].form.form_fields[0].field_type.should eq("short_answer")
|
40
|
+
line.stations[0].form.form_fields[0].required.should eq(true)
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
42
|
+
run.title.should eq("run-#{title}")
|
43
|
+
runfile = File.read(run.file)
|
44
|
+
runfile.should == File.read(File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should create a production run for input data as Block DSL way" do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
48
|
+
WebMock.allow_net_connect!
|
49
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
50
|
+
sleep 1
|
51
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
52
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
|
53
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
54
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
55
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
56
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
57
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
58
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
59
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
60
60
|
end
|
61
61
|
end
|
62
|
-
run = CF::Run.create(line, "run-name--11111000", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"},{"Company"=>"Google","Website"=>"google.com"}])
|
63
|
-
run.input.should eql( [{"Company"=>"Apple,Inc","Website"=>"Apple.com"},{"Company"=>"Google","Website"=>"google.com"}])
|
64
62
|
end
|
63
|
+
run = CF::Run.create(line, "run-#{title}", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"},{"Company"=>"Google","Website"=>"google.com"}])
|
64
|
+
run.input.should eql( [{"Company"=>"Apple,Inc","Website"=>"Apple.com"},{"Company"=>"Google","Website"=>"google.com"}])
|
65
65
|
end
|
66
66
|
|
67
67
|
it "for an existing line" do
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
68
|
+
WebMock.allow_net_connect!
|
69
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
70
|
+
sleep 1
|
71
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
72
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
|
73
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
74
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
75
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
76
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
77
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
78
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
79
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
79
80
|
end
|
80
81
|
end
|
81
|
-
run = CF::Run.create("Digitizeard123","Runusingline", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
|
82
|
-
run.title.should eq("Runusingline")
|
83
|
-
|
84
82
|
end
|
83
|
+
run = CF::Run.create(line,"run-#{title}", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
|
84
|
+
run.title.should eq("run-#{title}")
|
85
85
|
end
|
86
86
|
|
87
87
|
it "just using line title" do
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
88
|
+
WebMock.allow_net_connect!
|
89
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
90
|
+
sleep 1
|
91
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
92
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
|
93
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
94
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
95
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
96
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
97
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
98
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
99
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
99
100
|
end
|
100
101
|
end
|
101
|
-
run = CF::Run.create("line_title_run", "Runusinglinetitle", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
|
102
|
-
run.title.should eq("Runusinglinetitle")
|
103
|
-
|
104
102
|
end
|
103
|
+
run = CF::Run.create(title, "run-#{title}", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
|
104
|
+
run.title.should eq("run-#{title}")
|
105
105
|
end
|
106
106
|
|
107
107
|
it "for a line in a plain ruby way" do
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
108
|
+
WebMock.allow_net_connect!
|
109
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
110
|
+
sleep 1
|
111
|
+
line = CF::Line.new(title, "Digitization")
|
112
|
+
input_format_1 = CF::InputFormat.new({:name => "Company", :required => true})
|
113
|
+
input_format_2 = CF::InputFormat.new({:name => "Website", :required => true, :valid_type => "url"})
|
114
|
+
line.input_formats input_format_1
|
115
|
+
line.input_formats input_format_2
|
116
|
+
|
117
|
+
station = CF::Station.new({:type => "work"})
|
118
|
+
line.stations station
|
119
|
+
|
120
|
+
worker = CF::HumanWorker.new({:number => 1, :reward => 20})
|
121
|
+
line.stations.first.worker = worker
|
122
|
+
|
123
|
+
form = CF::TaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe"})
|
124
|
+
line.stations.first.form = form
|
125
|
+
|
126
|
+
form_fields_1 = CF::FormField.new({:label => "First Name", :field_type => "short_answer", :required => "true"})
|
127
|
+
line.stations.first.form.form_fields form_fields_1
|
128
|
+
form_fields_2 = CF::FormField.new({:label => "Middle Name", :field_type => "short_answer"})
|
129
|
+
line.stations.first.form.form_fields form_fields_2
|
130
|
+
form_fields_3 = CF::FormField.new({:label => "Last Name", :field_type => "short_answer", :required => "true"})
|
131
|
+
line.stations.first.form.form_fields form_fields_3
|
132
|
+
|
133
|
+
run = CF::Run.create(line, "run-#{title}", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
|
134
|
+
|
135
|
+
line.title.should eq(title)
|
136
|
+
line.stations.first.type.should eq("WorkStation")
|
137
|
+
|
138
|
+
line.input_formats[0].name.should eq("Company")
|
139
|
+
line.input_formats[0].required.should eq(true)
|
140
|
+
line.input_formats[1].name.should eq("Website")
|
141
|
+
line.input_formats[1].required.should eq(true)
|
142
|
+
|
143
|
+
line.stations.first.worker.number.should eql(1)
|
144
|
+
line.stations.first.worker.reward.should eql(20)
|
145
|
+
|
146
|
+
line.stations.first.form.title.should eql("Enter text from a business card image")
|
147
|
+
line.stations.first.form.instruction.should eql("Describe")
|
148
|
+
|
149
|
+
line.stations.first.form.form_fields[0].label.should eql("First Name")
|
150
|
+
line.stations.first.form.form_fields[0].field_type.should eql("short_answer")
|
151
|
+
line.stations.first.form.form_fields[0].required.should eql(true)
|
152
|
+
line.stations.first.form.form_fields[1].label.should eql("Middle Name")
|
153
|
+
line.stations.first.form.form_fields[1].field_type.should eql("short_answer")
|
154
|
+
line.stations.first.form.form_fields[2].label.should eql("Last Name")
|
155
|
+
line.stations.first.form.form_fields[2].field_type.should eql("short_answer")
|
156
|
+
line.stations.first.form.form_fields[2].required.should eql(true)
|
156
157
|
end
|
157
158
|
|
158
159
|
it "should fetch result" do
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
167
|
-
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
168
|
-
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
169
|
-
end
|
170
|
-
end
|
160
|
+
WebMock.allow_net_connect!
|
161
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
162
|
+
sleep 1
|
163
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
164
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
165
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
166
|
+
CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
|
171
167
|
end
|
172
|
-
run = CF::Run.create(line, "run-name-result-0111111111", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
|
173
|
-
# debugger
|
174
|
-
@final_output = run.final_output
|
175
|
-
@final_output.first['first-name'].should eql("Bob")
|
176
|
-
@final_output.first['last-name'].should eql("Marley")
|
177
168
|
end
|
169
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://www.sprout-technology.com"}])
|
170
|
+
sleep 10
|
171
|
+
output = run.final_output
|
172
|
+
output.first['keyword_relevance_of_url'].should eql([96.7417, 57.3763, 56.8721, 54.6844, 17.7066])
|
173
|
+
output.first['keywords_of_url'].should eql(["tech startup thing", "nights", "Nepal", "Canada", "U.S."])
|
178
174
|
end
|
179
175
|
|
180
176
|
it "should fetch result of the specified station with run title" do
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
177
|
+
WebMock.allow_net_connect!
|
178
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
179
|
+
sleep 1
|
180
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
181
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
182
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
183
|
+
CF::RobotWorker.create({:station => s, :type => "text_extraction_robot", :settings => {:url => ["{{url}}"]}})
|
184
|
+
end
|
185
|
+
CF::Station.create({:line => l, :type => "work"}) do |s1|
|
186
|
+
CF::RobotWorker.create({:station => s1, :type => "keyword_matching_robot", :settings => {:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj", "iPhone"]}})
|
191
187
|
end
|
192
|
-
run = CF::Run.create(line, "keyword_matching_robot_run_result", [{"url"=> "http://techcrunch.com/2011/07/26/with-v2-0-assistly-brings-a-simple-pricing-model-rewards-and-a-bit-of-free-to-customer-service-software"}, {"url"=> "http://techcrunch.com/2011/07/26/buddytv-iphone/"}])
|
193
|
-
# sleep 30
|
194
|
-
output = run.final_output
|
195
|
-
output.first['included_keywords_count_in_contents_of_url'].should eql(["3", "2", "2"])
|
196
|
-
output.first['keyword_included_in_contents_of_url'].should eql(["SaaS", "see", "additional"])
|
197
|
-
output.last['included_keywords_count_in_contents_of_url'].should eql(["4"])
|
198
|
-
output.last['keyword_included_in_contents_of_url'].should eql(["iPhone"])
|
199
|
-
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
200
|
-
line.stations.first.worker.reward.should eql(0.5)
|
201
|
-
line.stations.first.worker.number.should eql(1)
|
202
|
-
line.stations.first.worker.settings.should eql({:url => ["{{url}}"]})
|
203
|
-
line.stations.first.worker.type.should eql("TextExtractionRobot")
|
204
|
-
line.stations.last.worker.class.should eql(CF::RobotWorker)
|
205
|
-
line.stations.last.worker.reward.should eql(0.5)
|
206
|
-
line.stations.last.worker.number.should eql(1)
|
207
|
-
line.stations.last.worker.settings.should eql({:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj", "iPhone"]})
|
208
|
-
line.stations.last.worker.type.should eql("KeywordMatchingRobot")
|
209
|
-
output_of_station_1 = CF::Run.output({:title => "keyword_matching_robot_run_result", :station => 1})
|
210
|
-
output_of_station_2 = CF::Run.output({:title => "keyword_matching_robot_run_result", :station => 2})
|
211
|
-
output_of_station_2.first['keyword_included_in_contents_of_url'].should eql(["SaaS", "see", "additional"])
|
212
|
-
output_of_station_2.first['included_keywords_count_in_contents_of_url'].should eql(["3", "2", "2"])
|
213
188
|
end
|
189
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://techcrunch.com/2011/07/26/with-v2-0-assistly-brings-a-simple-pricing-model-rewards-and-a-bit-of-free-to-customer-service-software"}, {"url"=> "http://techcrunch.com/2011/07/26/buddytv-iphone/"}])
|
190
|
+
sleep 30
|
191
|
+
output = run.final_output
|
192
|
+
output.first['included_keywords_count_in_contents_of_url'].should eql(["3", "2", "2"])
|
193
|
+
output.first['keyword_included_in_contents_of_url'].should eql(["SaaS", "see", "additional"])
|
194
|
+
output.last['included_keywords_count_in_contents_of_url'].should eql(["4"])
|
195
|
+
output.last['keyword_included_in_contents_of_url'].should eql(["iPhone"])
|
196
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
197
|
+
line.stations.first.worker.reward.should eql(0.5)
|
198
|
+
line.stations.first.worker.number.should eql(1)
|
199
|
+
line.stations.first.worker.settings.should eql({:url => ["{{url}}"]})
|
200
|
+
line.stations.first.worker.type.should eql("TextExtractionRobot")
|
201
|
+
line.stations.last.worker.class.should eql(CF::RobotWorker)
|
202
|
+
line.stations.last.worker.reward.should eql(0.5)
|
203
|
+
line.stations.last.worker.number.should eql(1)
|
204
|
+
line.stations.last.worker.settings.should eql({:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj", "iPhone"]})
|
205
|
+
line.stations.last.worker.type.should eql("KeywordMatchingRobot")
|
206
|
+
output_of_station_1 = CF::Run.output({:title => "run-#{title}", :station => 1})
|
207
|
+
output_of_station_2 = CF::Run.output({:title => "run-#{title}", :station => 2})
|
208
|
+
opt = output_of_station_2.map{|o| o['keyword_included_in_contents_of_url']}.join(",")
|
209
|
+
opt.should include("SaaS", "see", "additional", "iPhone")
|
214
210
|
end
|
215
211
|
|
216
212
|
it "should create production run with invalid input_format for input" do
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
213
|
+
WebMock.allow_net_connect!
|
214
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
215
|
+
sleep 1
|
216
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
217
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
218
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
219
|
+
CF::RobotWorker.create({:station => s, :type => "media_splitting_robot", :settings => {:url => ["http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"], :split_duration => "2", :overlapping_time => "1"}})
|
224
220
|
end
|
225
|
-
run = CF::Run.create(line, "media_splitting_robot_run_3", [{"url_1"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
226
|
-
run.errors.should eql(["Extra Headers in file: [url_1]", "Insufficient Headers in file: [url]"])
|
227
221
|
end
|
222
|
+
run = CF::Run.create(line, "run-#{title}", [{"url_1"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
223
|
+
run.errors.should eql(["Extra Headers in file: [url_1]", "Insufficient Headers in file: [url]"])
|
228
224
|
end
|
229
225
|
|
230
226
|
it "should create production run with invalid data" do
|
231
|
-
|
232
|
-
|
233
|
-
|
227
|
+
WebMock.allow_net_connect!
|
228
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
229
|
+
sleep 1
|
230
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
234
231
|
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
235
232
|
CF::Station.create({:line => l, :type => "work"}) do |s|
|
236
233
|
CF::RobotWorker.create({:station => s, :type => "media_splitting_robot", :settings => {:url => ["http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"], :split_duration => "2", :overlapping_time => "1"}})
|
237
234
|
end
|
238
235
|
end
|
239
|
-
run = CF::Run.create(line, "
|
236
|
+
run = CF::Run.create(line, "run-#{title}", File.expand_path("../../fixtures/input_data/media_converter_robot.csv", __FILE__))
|
240
237
|
run.errors.should eql(["Extra Headers in file: [url_1]", "Insufficient Headers in file: [url]"])
|
241
|
-
end
|
242
238
|
end
|
243
239
|
|
244
240
|
it "should create production run with used title data" do
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
241
|
+
WebMock.allow_net_connect!
|
242
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
243
|
+
sleep 1
|
244
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
245
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
246
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
247
|
+
CF::RobotWorker.create({:station => s, :type => "media_splitting_robot", :settings => {:url => ["http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"], :split_duration => "2", :overlapping_time => "1"}})
|
252
248
|
end
|
253
|
-
run = CF::Run.create(line, "media_splitting_robot_run_5", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
254
|
-
run_1 = CF::Run.create(line, "media_splitting_robot_run_5", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
255
|
-
run_1.errors.should eql(["Title is already taken for this account"])
|
256
249
|
end
|
250
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
251
|
+
run_1 = CF::Run.create(line, "run-#{title}", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
252
|
+
run_1.errors.should eql(["Title is already taken for this account"])
|
257
253
|
end
|
258
254
|
|
259
255
|
it "should create production run and find created run" do
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
256
|
+
WebMock.allow_net_connect!
|
257
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
258
|
+
sleep 1
|
259
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
260
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
261
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
262
|
+
CF::RobotWorker.create({:station => s, :type => "media_splitting_robot", :settings => {:url => ["http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"], :split_duration => "2", :overlapping_time => "1"}})
|
267
263
|
end
|
268
|
-
run = CF::Run.create(line, "media_splitting_robot_run_6", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
269
|
-
sleep 10
|
270
|
-
found_run = CF::Run.find("media_splitting_robot_run_6")
|
271
|
-
found_run.code.should eql(200)
|
272
|
-
found_run.title.should eql("media_splitting_robot_run_6")
|
273
|
-
found_run.line.title.should eql("media_splitting_robot_6")
|
274
|
-
found_run.line.department.should eql("Digitization")
|
275
|
-
found_run.status.should eql("active")
|
276
264
|
end
|
265
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
266
|
+
sleep 10
|
267
|
+
found_run = CF::Run.find("run-#{title}")
|
268
|
+
found_run['code'].should eql(200)
|
269
|
+
found_run['title'].should eql("run-#{title}")
|
270
|
+
found_run['line']['title'].should eql(title)
|
271
|
+
found_run['line']['department'].should eql("Digitization")
|
272
|
+
found_run['status'].should eql("completed")
|
277
273
|
end
|
278
274
|
|
279
275
|
it "should create production run and try to find run with unused title" do
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
276
|
+
WebMock.allow_net_connect!
|
277
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
278
|
+
sleep 1
|
279
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
280
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
281
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
282
|
+
CF::RobotWorker.create({:station => s, :type => "media_splitting_robot", :settings => {:url => ["http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"], :split_duration => "2", :overlapping_time => "1"}})
|
287
283
|
end
|
288
|
-
run = CF::Run.create(line, "media_splitting_robot_run_7", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
289
|
-
found_run = CF::Run.find("unused_title")
|
290
|
-
found_run.code.should eql(404)
|
291
|
-
found_run.errors.should eql("Run document not found using selector: {:title=>\"unused_title\"}")
|
292
284
|
end
|
285
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
|
286
|
+
found_run = CF::Run.find("unused_title")
|
287
|
+
found_run['code'].should eql(404)
|
288
|
+
found_run['errors'].should eql("Run document not found using selector: {:title=>\"unused_title\"}")
|
293
289
|
end
|
294
290
|
end
|
295
|
-
|
291
|
+
|
296
292
|
context "check run progress and resume run" do
|
297
293
|
it "should check the progress" do
|
298
|
-
|
299
|
-
#
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
294
|
+
WebMock.allow_net_connect!
|
295
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
296
|
+
sleep 1
|
297
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
298
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
299
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
300
|
+
CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
|
305
301
|
end
|
306
|
-
run = CF::Run.create(line, "progress_run", [{"url"=> "http://www.sprout-technology.com"}])
|
307
|
-
# sleep 20
|
308
|
-
progress = run.progress
|
309
|
-
progress_1 = CF::Run.progress("progress_run")
|
310
|
-
progress.should eql(progress_1)
|
311
|
-
progress.progress.should eql(100)
|
312
302
|
end
|
303
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://www.sprout-technology.com"}])
|
304
|
+
sleep 10
|
305
|
+
progress = run.progress
|
306
|
+
progress_1 = CF::Run.progress("run-#{title}")
|
307
|
+
progress.should eql(progress_1)
|
308
|
+
progress['progress'].should eql(100)
|
313
309
|
end
|
314
|
-
|
310
|
+
|
315
311
|
it "should get the progress details" do
|
316
|
-
|
317
|
-
#
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
312
|
+
WebMock.allow_net_connect!
|
313
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
314
|
+
sleep 1
|
315
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
316
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
317
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
318
|
+
CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
|
323
319
|
end
|
324
|
-
run = CF::Run.create(line, "progress_run_1", [{"url"=> "http://www.sprout-technology.com"}])
|
325
|
-
# sleep 20
|
326
|
-
progress = run.progress_details
|
327
|
-
progress_1 = CF::Run.progress_details("progress_run_1")
|
328
|
-
progress.should eql(progress_1)
|
329
|
-
progress.total.progress.should eql(100)
|
330
|
-
progress.total.units.should eql(1)
|
331
320
|
end
|
321
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://www.sprout-technology.com"}])
|
322
|
+
sleep 10
|
323
|
+
progress = run.progress_details
|
324
|
+
progress_1 = CF::Run.progress_details("run-#{title}")
|
325
|
+
progress.should eql(progress_1)
|
326
|
+
progress['total']['progress'].should eql(100)
|
327
|
+
progress['total']['units'].should eql(1)
|
332
328
|
end
|
333
329
|
|
334
330
|
it "should get the progress details for multiple stations" do
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
331
|
+
WebMock.allow_net_connect!
|
332
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
333
|
+
sleep 1
|
334
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
335
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
336
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
337
|
+
CF::RobotWorker.create({:station => s, :type => "text_extraction_robot", :settings => {:url => ["{{url}}"]}})
|
338
|
+
end
|
339
|
+
CF::Station.create({:line => l, :type => "work"}) do |s1|
|
340
|
+
CF::RobotWorker.create({:station => s1, :type => "keyword_matching_robot", :settings => {:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj"]}})
|
345
341
|
end
|
346
|
-
run = CF::Run.create(line, "progress_run_2", [{"url"=> "http://techcrunch.com/2011/07/26/with-v2-0-assistly-brings-a-simple-pricing-model-rewards-and-a-bit-of-free-to-customer-service-software"}])
|
347
|
-
# sleep 30
|
348
|
-
progress = run.progress_details
|
349
|
-
progress_1 = CF::Run.progress_details("progress_run_2")
|
350
|
-
progress.should eql(progress_1)
|
351
|
-
progress.total.progress.should eql(100)
|
352
|
-
progress.total.units.should eql(1)
|
353
342
|
end
|
343
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://techcrunch.com/2011/07/26/with-v2-0-assistly-brings-a-simple-pricing-model-rewards-and-a-bit-of-free-to-customer-service-software"}])
|
344
|
+
sleep 30
|
345
|
+
progress = run.progress_details
|
346
|
+
progress_1 = CF::Run.progress_details("run-#{title}")
|
347
|
+
progress.should eql(progress_1)
|
348
|
+
progress['total']['progress'].should eql(100)
|
349
|
+
progress['total']['units'].should eql(1)
|
354
350
|
end
|
355
351
|
end
|
356
|
-
|
352
|
+
|
357
353
|
context "get run" do
|
358
354
|
it "should return all the runs for an account" do
|
359
|
-
|
360
|
-
#
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
355
|
+
WebMock.allow_net_connect!
|
356
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
357
|
+
sleep 1
|
358
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
359
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
360
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
361
|
+
CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
|
366
362
|
end
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
363
|
+
end
|
364
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://www.sprout-technology.com"}])
|
365
|
+
sleep 10
|
366
|
+
line_1 = CF::Line.create("#{title}_1","Digitization") do |l|
|
367
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
368
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
369
|
+
CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
|
374
370
|
end
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
371
|
+
end
|
372
|
+
run_1 = CF::Run.create(line_1, "run-#{title}_1", [{"url"=> "http://www.sprout-technology.com"}])
|
373
|
+
sleep 10
|
374
|
+
line_2 = CF::Line.create("#{title}_2","Digitization") do |l|
|
375
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
376
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
377
|
+
CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
|
382
378
|
end
|
383
|
-
run_2 = CF::Run.create(line_2, "progress_run_32", [{"url"=> "http://www.sprout-technology.com"}])
|
384
|
-
# sleep 10
|
385
|
-
got_run = CF::Run.all
|
386
|
-
got_run['runs'].class.should eql(Array)
|
387
|
-
got_run['runs'].first['progress'].should eql(0)
|
388
|
-
got_run['runs'].first['status'].should eql("active")
|
389
379
|
end
|
380
|
+
run_2 = CF::Run.create(line_2, "run-#{title}_2", [{"url"=> "http://www.sprout-technology.com"}])
|
381
|
+
sleep 10
|
382
|
+
got_run = CF::Run.all
|
383
|
+
got_run['runs'].class.should eql(Array)
|
384
|
+
got_run['runs'].first['status'].should eql("completed")
|
390
385
|
end
|
391
|
-
|
386
|
+
|
392
387
|
it "should return all the runs for a line" do
|
393
|
-
|
394
|
-
#
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
388
|
+
WebMock.allow_net_connect!
|
389
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
390
|
+
sleep 1
|
391
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
392
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
393
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
394
|
+
CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
|
400
395
|
end
|
401
|
-
run = CF::Run.create(line, "progress_run_11", [{"url"=> "http://www.sprout-technology.com"}])
|
402
|
-
# sleep 10
|
403
|
-
run_1 = CF::Run.create(line, "progress_run_12", [{"url"=> "http://www.sprout-technology.com"}])
|
404
|
-
# sleep 10
|
405
|
-
run_2 = CF::Run.create(line, "progress_run_13", [{"url"=> "http://www.sprout-technology.com"}])
|
406
|
-
# sleep 10
|
407
|
-
got_run = CF::Run.all({:line_title => "progress_run_line_11"})
|
408
|
-
got_run['runs'][0]['title'].should eql("progress_run_11")
|
409
|
-
got_run['runs'][1]['title'].should eql("progress_run_12")
|
410
|
-
got_run['runs'][2]['title'].should eql("progress_run_13")
|
411
396
|
end
|
397
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://www.sprout-technology.com"}])
|
398
|
+
sleep 10
|
399
|
+
run_1 = CF::Run.create(line, "run-#{title}_1", [{"url"=> "http://www.sprout-technology.com"}])
|
400
|
+
sleep 10
|
401
|
+
run_2 = CF::Run.create(line, "run-#{title}_2", [{"url"=> "http://www.sprout-technology.com"}])
|
402
|
+
sleep 10
|
403
|
+
got_run = CF::Run.all({:line_title => "#{title}"})
|
404
|
+
run_titles = got_run['runs'].map {|r| r['title']}.join(",")
|
405
|
+
run_titles.should include("run-#{title}", "run-#{title}_1", "run-#{title}_2")
|
412
406
|
end
|
413
|
-
|
407
|
+
|
414
408
|
it "should get all runs with pagination" do
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
run['runs'].first['progress'].should eql(0)
|
420
|
-
run['runs'].first['status'].should eql("active")
|
421
|
-
end
|
409
|
+
WebMock.allow_net_connect!
|
410
|
+
run = CF::Run.all({:page => 1})
|
411
|
+
run['runs'].class.should eql(Array)
|
412
|
+
run['code'].should eql(200)
|
422
413
|
end
|
423
|
-
|
424
|
-
it "should get all runs with pagination all" do
|
425
|
-
|
426
|
-
#
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
end
|
433
|
-
25.times do |i|
|
434
|
-
CF::Run.create(line, "pagination_run#{i}", [{"url"=> "http://www.sprout-technology.com"}])
|
414
|
+
|
415
|
+
it "should get all runs with pagination params all" do
|
416
|
+
WebMock.allow_net_connect!
|
417
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
418
|
+
sleep 1
|
419
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
420
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
421
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
422
|
+
CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
|
435
423
|
end
|
436
|
-
|
437
|
-
|
438
|
-
run[
|
424
|
+
end
|
425
|
+
3.times do |i|
|
426
|
+
CF::Run.create(line, "run-#{title}_#{i}", [{"url"=> "http://www.sprout-technology.com"}])
|
427
|
+
sleep 10
|
428
|
+
end
|
429
|
+
run = CF::Run.all({:page => "all"})
|
430
|
+
run['runs'].class.should eql(Array)
|
431
|
+
run_title = run['runs'].map {|r| r['title']}.join(",")
|
432
|
+
3.times do |i|
|
433
|
+
run_title.should include("run-#{title}_#{i}")
|
439
434
|
end
|
440
435
|
end
|
441
436
|
end
|
442
|
-
|
437
|
+
|
443
438
|
context "create a run with insufficient balance and" do
|
444
439
|
it "should resume run" do
|
445
440
|
VCR.use_cassette "run/block/resume-run", :record => :new_episodes do
|
446
|
-
|
447
|
-
|
441
|
+
# WebMock.allow_net_connect!
|
442
|
+
# change account available_balance to 10 cents
|
448
443
|
line = CF::Line.create("resume_run_line","Digitization") do |l|
|
449
444
|
CF::InputFormat.new({:line => l, :name => "Company", :required => true})
|
450
445
|
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
@@ -458,139 +453,136 @@ module CF
|
|
458
453
|
end
|
459
454
|
end
|
460
455
|
run = CF::Run.create(line, "resume_run", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"},{"Company"=>"Google","Website"=>"google.com"}])
|
461
|
-
# sleep 10
|
462
456
|
# debugger
|
463
457
|
# Change account available_balance to 200000 cents
|
464
458
|
resumed_run = CF::Run.resume("resume_run")
|
465
|
-
resumed_run
|
466
|
-
resumed_run
|
467
|
-
resumed_run
|
459
|
+
resumed_run['code'].should eql(200)
|
460
|
+
resumed_run['status'].should eql("resumed")
|
461
|
+
resumed_run['title'].should eql("resume_run")
|
468
462
|
end
|
469
463
|
end
|
470
464
|
end
|
471
|
-
|
465
|
+
|
472
466
|
context "creation of run by adding units" do
|
473
467
|
it "should manually add units" do
|
474
|
-
|
475
|
-
#
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
468
|
+
WebMock.allow_net_connect!
|
469
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
470
|
+
sleep 1
|
471
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
472
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true})
|
473
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
474
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
475
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
476
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
477
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
478
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
479
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
486
480
|
end
|
487
481
|
end
|
488
|
-
run = CF::Run.create(line, "adding_units_run", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"}])
|
489
|
-
# sleep 10
|
490
|
-
added_units = CF::Run.add_units(:run_title => "adding_units_run", :units => [{"Company"=>"Apple,Inc","Website"=>"Apple.com"}, {"Company"=>"Sprout","Website"=>"sprout.com"}])
|
491
|
-
added_units['successfull'].should eql("Sucessfully added 2 units, Failed :0")
|
492
|
-
run.title.should eql("adding_units_run")
|
493
482
|
end
|
483
|
+
run = CF::Run.create(line, "run-#{title}", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"}])
|
484
|
+
sleep 10
|
485
|
+
added_units = CF::Run.add_units(:run_title => "run-#{title}", :units => [{"Company"=>"Apple,Inc","Website"=>"Apple.com"}, {"Company"=>"Sprout","Website"=>"sprout.com"}])
|
486
|
+
added_units['successfull'].should eql("Sucessfully added 2 units, Failed :0")
|
487
|
+
run.title.should eql("run-#{title}")
|
494
488
|
end
|
495
|
-
|
489
|
+
|
496
490
|
it "should add units by passing file" do
|
497
|
-
|
498
|
-
#
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
491
|
+
WebMock.allow_net_connect!
|
492
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
493
|
+
sleep 1
|
494
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
495
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true})
|
496
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
497
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
498
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
499
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
500
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
501
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
502
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
509
503
|
end
|
510
504
|
end
|
511
|
-
run = CF::Run.create(line, "adding_units_file_run", [{"Company"=>"Sprout","Website"=>"sprout.com"}])
|
512
|
-
# sleep 10
|
513
|
-
added_units = CF::Run.add_units({:run_title => "adding_units_file_run", :file => File.expand_path("../../fixtures/input_data/test.csv", __FILE__)})
|
514
|
-
added_units['successfull'].should eql("Sucessfully added 1 units, Failed :0")
|
515
|
-
run.title.should eql("adding_units_file_run")
|
516
505
|
end
|
506
|
+
run = CF::Run.create(line, "run-#{title}", [{"Company"=>"Sprout","Website"=>"sprout.com"}])
|
507
|
+
sleep 10
|
508
|
+
added_units = CF::Run.add_units({:run_title => "run-#{title}", :file => File.expand_path("../../fixtures/input_data/test.csv", __FILE__)})
|
509
|
+
added_units['successfull'].should eql("Sucessfully added 1 units, Failed :0")
|
510
|
+
run.title.should eql("run-#{title}")
|
517
511
|
end
|
518
|
-
|
512
|
+
|
519
513
|
it "should throw errors for invalid input while adding units" do
|
520
|
-
|
521
|
-
#
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
514
|
+
WebMock.allow_net_connect!
|
515
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
516
|
+
sleep 1
|
517
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
518
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true})
|
519
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
520
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
521
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
522
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
523
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
524
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
525
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
532
526
|
end
|
533
527
|
end
|
534
|
-
run = CF::Run.create(line, "adding_units_error_run", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"}])
|
535
|
-
added_units = CF::Run.add_units(:run_title => "adding_units_error_run", :units => [{"Company"=>"Sprout","Url"=>"sprout.com"}])
|
536
|
-
added_units['error']['message'].should eql("Run document not found using selector: {:title=>\"adding_units_error_run\"}")
|
537
|
-
run.title.should eql("adding_units_error_run")
|
538
528
|
end
|
529
|
+
run = CF::Run.create(line, "run-#{title}", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"}])
|
530
|
+
added_units = CF::Run.add_units(:run_title => "run-#{title}", :units => [{"Company"=>"Sprout","Url"=>"sprout.com"}])
|
531
|
+
added_units['error']['message'].should eql(["Extra Headers in file: [url]", "Insufficient Headers in file: [website]"])
|
532
|
+
run.title.should eql("run-#{title}")
|
539
533
|
end
|
540
|
-
|
534
|
+
|
541
535
|
it "should throw errors for empty input while adding units" do
|
542
|
-
|
543
|
-
#
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
536
|
+
WebMock.allow_net_connect!
|
537
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
538
|
+
sleep 1
|
539
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
540
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
|
541
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
542
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
543
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
544
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
545
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
546
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
547
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
554
548
|
end
|
555
549
|
end
|
556
|
-
run = CF::Run.create(line, "adding_units_error_run_1", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"}])
|
557
|
-
added_units = CF::Run.add_units(:run_title => "adding_units_error_run", :units => [])
|
558
|
-
added_units['error']['message'].should eql("Run document not found using selector: {:title=>\"adding_units_error_run\"}")
|
559
550
|
end
|
551
|
+
run = CF::Run.create(line, "run-#{title}", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"}])
|
552
|
+
added_units = CF::Run.add_units(:run_title => "run-#{title}", :units => [])
|
553
|
+
added_units['error']['message'].should eql("Run document not found using selector: {:title=>\"run-#{title}\"}")
|
560
554
|
end
|
561
555
|
end
|
562
|
-
|
556
|
+
|
563
557
|
context "Delete Run" do
|
564
558
|
it "should call destroy method of run to delete a created run" do
|
565
|
-
|
566
|
-
#
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
559
|
+
WebMock.allow_net_connect!
|
560
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
561
|
+
sleep 1
|
562
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
563
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true})
|
564
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
565
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
566
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
567
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
568
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
569
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
570
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
577
571
|
end
|
578
572
|
end
|
579
|
-
run = CF::Run.create(line, "delete_run_run", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"}])
|
580
|
-
# sleep 10
|
581
|
-
deleted_resp = CF::Run.destroy("delete_run_run")
|
582
|
-
deleted_resp.code.should eql(200)
|
583
|
-
deleted_resp.line['title'].should eql("delete_run")
|
584
|
-
deleted_resp.title.should eql("delete_run_run")
|
585
573
|
end
|
574
|
+
run = CF::Run.create(line, "run-#{title}", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"}])
|
575
|
+
sleep 10
|
576
|
+
deleted_resp = CF::Run.destroy("run-#{title}")
|
577
|
+
deleted_resp['code'].should eql(200)
|
578
|
+
deleted_resp['line']['title'].should eql(title)
|
579
|
+
deleted_resp['title'].should eql("run-#{title}")
|
586
580
|
end
|
587
|
-
|
581
|
+
|
588
582
|
it "should throw error message while deleting uncreated Run" do
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
delete.error.message.should eql("Run document not found using selector: {:title=>\"norun\"}")
|
593
|
-
end
|
583
|
+
delete = CF::Run.destroy("norun")
|
584
|
+
delete['code'].should_not eql(200)
|
585
|
+
delete['error']['message'].should eql("Run document not found using selector: {:title=>\"norun\"}")
|
594
586
|
end
|
595
587
|
end
|
596
588
|
end
|