cloudfactory 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- # WebMock.allow_net_connect!
9
- VCR.use_cassette "robot_worker/mailer_robot/block/create-worker-single-station", :record => :new_episodes do
10
- @template = "<html><body><h1>Hello {{to}} Welcome to CLoudfactory!!!!</h1><p>Thanks for using!!!!</p></body></html>"
11
- line = CF::Line.create("mailer_robot","Digitization") do |l|
12
- CF::InputFormat.new({:line => l, :name => "to", :required => "true"})
13
- CF::Station.create({:line => l, :type => "work"}) do |s|
14
- CF::RobotWorker.create({:station => s, :type => "mailer_robot", :settings => {:to => ["manish.das@sprout-technology.com"], :template => @template}})
15
- end
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
- # WebMock.allow_net_connect!
32
- VCR.use_cassette "robot_worker/mailer_robot/plain-ruby/create-worker-in-first-station", :record => :new_episodes do
33
- @template = "<html><body><h1>Hello {{to}} Welcome to CLoudfactory!!!!</h1><p>Thanks for using!!!!</p></body></html>"
34
- line = CF::Line.new("mailer_robot_1","Digitization")
35
- input_format = CF::InputFormat.new({:name => "to", :required => "true"})
36
- line.input_formats input_format
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
- station = CF::Station.new({:type => "work"})
39
- line.stations station
39
+ station = CF::Station.new({:type => "work"})
40
+ line.stations station
40
41
 
41
- worker = CF::RobotWorker.create({:type => "mailer_robot", :settings => {:to => ["manish.das@sprout-technology.com"], :template => @template}})
42
- line.stations.first.worker = worker
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
- run = CF::Run.create(line, "mailer_robot_run_1", [{"to"=> "manish.das@sprout-technology.com"}])
45
- # sleep 20
46
- output = run.final_output
47
- output.first['recipients_of_to'].should eql(["manish.das@sprout-technology.com"])
48
- 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>")
49
- line.stations.first.worker.class.should eql(CF::RobotWorker)
50
- line.stations.first.worker.reward.should eql(0.01)
51
- line.stations.first.worker.number.should eql(1)
52
- line.stations.first.worker.settings.should eql({:to => ["manish.das@sprout-technology.com"], :template => @template})
53
- line.stations.first.worker.type.should eql("MailerRobot")
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
- # WebMock.allow_net_connect!
8
- VCR.use_cassette "robot_worker/media_converter_robot/plain-ruby/create-worker-in-first-station", :record => :new_episodes do
9
- line = CF::Line.new("media_converter_robot","Digitization")
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
- input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
12
- line.input_formats input_format
12
+ input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
13
+ line.input_formats input_format
13
14
 
14
- input_format_1 = CF::InputFormat.new({:name => "to", :required => false})
15
- line.input_formats input_format_1
15
+ input_format_1 = CF::InputFormat.new({:name => "to", :required => false})
16
+ line.input_formats input_format_1
16
17
 
17
- input_format_2 = CF::InputFormat.new({:name => "audio_quality", :required => false})
18
- line.input_formats input_format_2
18
+ input_format_2 = CF::InputFormat.new({:name => "audio_quality", :required => false})
19
+ line.input_formats input_format_2
19
20
 
20
- input_format_3 = CF::InputFormat.new({:name => "video_quality", :required => false})
21
- line.input_formats input_format_3
21
+ input_format_3 = CF::InputFormat.new({:name => "video_quality", :required => false})
22
+ line.input_formats input_format_3
22
23
 
23
- station = CF::Station.new({:type => "work"})
24
- line.stations station
24
+ station = CF::Station.new({:type => "work"})
25
+ line.stations station
25
26
 
26
- worker = CF::RobotWorker.create({:type => "media_converter_robot", :settings => {:url => ["{{url}}"], :to => "{{to}}", :audio_quality => "{{audio_quality}}", :video_quality => "{{video_quality}}"}})
27
- line.stations.first.worker = worker
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
- form = CF::TaskForm.new({:title => "Enter text", :instruction => "Describe"})
30
- line.stations.first.form = form
31
-
32
- form_fields = CF::FormField.new({:label => "Description", :field_type => "SA", :required => "true"})
33
- line.stations.first.form.form_fields form_fields
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
- # WebMock.allow_net_connect!
46
- VCR.use_cassette "robot_worker/media_converter_robot/block/create-worker-block-dsl-way", :record => :new_episodes do
47
- line = CF::Line.create("media_converter_robot_1","Digitization") do |l|
48
- CF::InputFormat.new({:line => l, :name => "url", :required => true, :valid_type => "url"})
49
- CF::InputFormat.new({:line => l, :name => "to", :required => false})
50
- CF::InputFormat.new({:line => l, :name => "audio_quality", :required => false})
51
- CF::InputFormat.new({:line => l, :name => "video_quality", :required => false})
52
- CF::Station.create({:line => l, :type => "work"}) do |s|
53
- CF::RobotWorker.create({:station => s, :type => "media_converter_robot", :settings => {:url => ["{{url}}"], :to => "{{to}}", :audio_quality => "{{audio_quality}}", :video_quality => "{{video_quality}}"}})
54
- end
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
- # WebMock.allow_net_connect!
9
- VCR.use_cassette "robot_worker/media_splitting_robot/block/create-worker-single-station", :record => :new_episodes do
10
- line = CF::Line.create("media_splitting_robot","Digitization") do |l|
11
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
12
- CF::Station.create({:line => l, :type => "work"}) do |s|
13
- CF::RobotWorker.create({:station => s, :type => "media_splitting_robot", :settings => {:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"}})
14
- end
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
- # WebMock.allow_net_connect!
33
- VCR.use_cassette "robot_worker/media_splitting_robot/plain-ruby/create-worker-in-first-station", :record => :new_episodes do
34
- line = CF::Line.new("media_splitting_robot_1","Digitization")
35
- input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
36
- line.input_formats input_format
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
- station = CF::Station.new({:type => "work"})
39
- line.stations station
39
+ station = CF::Station.new({:type => "work"})
40
+ line.stations station
40
41
 
41
- worker = CF::RobotWorker.create({:type => "media_splitting_robot", :settings => {:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"}})
42
- line.stations.first.worker = worker
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
- run = CF::Run.create(line, "media_splitting_robot_run_1", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
45
- # sleep 20
46
- output = run.final_output
47
- converted_url_1= output.first['splits_of_url'].first
48
- converted_url_2= output.first['splits_of_url'].last
49
- File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_1}").should eql(true)
50
- File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_2}").should eql(true)
51
- line.stations.first.worker.class.should eql(CF::RobotWorker)
52
- line.stations.first.worker.reward.should eql(0.01)
53
- line.stations.first.worker.number.should eql(1)
54
- line.stations.first.worker.settings.should eql({:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"})
55
- line.stations.first.worker.type.should eql("MediaSplittingRobot")
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
@@ -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
- VCR.use_cassette "robot_worker/block/display-to_s", :record => :new_episodes do
7
- # WebMock.allow_net_connect!
8
- line = CF::Line.create("display_entity_extraction_robot","Digitization") do |l|
9
- CF::InputFormat.new({:line => l, :name => "text", :required => "true"})
10
- CF::Station.create({:line => l, :type => "work"}) do |s|
11
- 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"]}})
12
- end
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
- VCR.use_cassette "run/block/create-run", :record => :new_episodes do
8
- # WebMock.allow_net_connect!
9
- line = CF::Line.create("Digarde-007","Digitization") do |l|
10
- CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
11
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
12
- CF::Station.create({:line => l, :type => "work"}) do |s|
13
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
14
- CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
15
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
16
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
17
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
18
- end
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
- run = CF::Run.create(line, "runnamee1", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
23
+ run = CF::Run.create(line, "run-#{title}", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
23
24
 
24
- line.title.should eq("Digarde-007")
25
+ line.title.should eq(title)
25
26
 
26
- line.input_formats.first.name.should eq("Company")
27
- line.input_formats.first.required.should eq(true)
27
+ line.input_formats.first.name.should eq("Company")
28
+ line.input_formats.first.required.should eq(true)
28
29
 
29
- line.stations[0].type.should eq("WorkStation")
30
+ line.stations[0].type.should eq("WorkStation")
30
31
 
31
- line.stations[0].worker.number.should eq(1)
32
- line.stations[0].worker.reward.should eq(20)
32
+ line.stations[0].worker.number.should eq(1)
33
+ line.stations[0].worker.reward.should eq(20)
33
34
 
34
- line.stations[0].form.title.should eq("Enter text from a business card image")
35
- line.stations[0].form.instruction.should eq("Describe")
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
- line.stations[0].form.form_fields[0].label.should eq("First Name")
38
- line.stations[0].form.form_fields[0].field_type.should eq("short_answer")
39
- line.stations[0].form.form_fields[0].required.should eq(true)
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
- run.title.should eq("runnamee1")
42
- runfile = File.read(run.file)
43
- runfile.should == File.read(File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
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
- # WebMock.allow_net_connect!
49
- VCR.use_cassette "run/block/create-run-without-file", :record => :new_episodes do
50
- line = CF::Line.create("Digitizard--11111000","Digitization") do |l|
51
- CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
52
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
53
- CF::Station.create({:line => l, :type => "work"}) do |s|
54
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
55
- CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
56
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
57
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
58
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
59
- end
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
- VCR.use_cassette "run/block/create-run-of-an-existing-line", :record => :new_episodes do
69
- line = CF::Line.create("Digitizeard123","Digitization") do |l|
70
- CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
71
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
72
- CF::Station.create({:line => l, :type => "work"}) do |s|
73
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
74
- CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
75
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
76
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
77
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
78
- end
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
- VCR.use_cassette "run/block/create-run-using-line-title", :record => :new_episodes do
89
- line = CF::Line.create("line_title_run","Digitization") do |l|
90
- CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
91
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
92
- CF::Station.create({:line => l, :type => "work"}) do |s|
93
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
94
- CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
95
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
96
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
97
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
98
- end
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
- VCR.use_cassette "run/plain-ruby/create-run", :record => :new_episodes do
109
- line = CF::Line.new("Digitize--ard1", "Digitization")
110
- input_format_1 = CF::InputFormat.new({:name => "Company", :required => true})
111
- input_format_2 = CF::InputFormat.new({:name => "Website", :required => true, :valid_type => "url"})
112
- line.input_formats input_format_1
113
- line.input_formats input_format_2
114
-
115
- station = CF::Station.new({:type => "work"})
116
- line.stations station
117
-
118
- worker = CF::HumanWorker.new({:number => 1, :reward => 20})
119
- line.stations.first.worker = worker
120
-
121
- form = CF::TaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe"})
122
- line.stations.first.form = form
123
-
124
- form_fields_1 = CF::FormField.new({:label => "First Name", :field_type => "short_answer", :required => "true"})
125
- line.stations.first.form.form_fields form_fields_1
126
- form_fields_2 = CF::FormField.new({:label => "Middle Name", :field_type => "short_answer"})
127
- line.stations.first.form.form_fields form_fields_2
128
- form_fields_3 = CF::FormField.new({:label => "Last Name", :field_type => "short_answer", :required => "true"})
129
- line.stations.first.form.form_fields form_fields_3
130
-
131
- run = CF::Run.create(line,"Run-in-plain-ruby-way", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
132
-
133
- line.title.should eq("Digitize--ard1")
134
- line.stations.first.type.should eq("WorkStation")
135
-
136
- line.input_formats[0].name.should eq("Company")
137
- line.input_formats[0].required.should eq(true)
138
- line.input_formats[1].name.should eq("Website")
139
- line.input_formats[1].required.should eq(true)
140
-
141
- line.stations.first.worker.number.should eql(1)
142
- line.stations.first.worker.reward.should eql(20)
143
-
144
- line.stations.first.form.title.should eql("Enter text from a business card image")
145
- line.stations.first.form.instruction.should eql("Describe")
146
-
147
- line.stations.first.form.form_fields[0].label.should eql("First Name")
148
- line.stations.first.form.form_fields[0].field_type.should eql("short_answer")
149
- line.stations.first.form.form_fields[0].required.should eql(true)
150
- line.stations.first.form.form_fields[1].label.should eql("Middle Name")
151
- line.stations.first.form.form_fields[1].field_type.should eql("short_answer")
152
- line.stations.first.form.form_fields[2].label.should eql("Last Name")
153
- line.stations.first.form.form_fields[2].field_type.should eql("short_answer")
154
- line.stations.first.form.form_fields[2].required.should eql(true)
155
- end
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
- VCR.use_cassette "run/block/create-run-fetch-result", :record => :new_episodes do
160
- line = CF::Line.create("Digarde-00111111111","Digitization") do |l|
161
- CF::InputFormat.new({:line => l, :name => "Company", :required => true})
162
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
163
- CF::Station.create({:line => l, :type => "work"}) do |s|
164
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
165
- CF::TaskForm.create({:station => s, :title => "Enter about CEO from card1", :instruction => "Describe"}) do |i|
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
- # WebMock.allow_net_connect!
182
- VCR.use_cassette "run/block/fetch-result-with-title", :record => :new_episodes do
183
- line = CF::Line.create("keyword_matching_robot_result","Digitization") do |l|
184
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
185
- CF::Station.create({:line => l, :type => "work"}) do |s|
186
- CF::RobotWorker.create({:station => s, :type => "text_extraction_robot", :settings => {:url => ["{{url}}"]}})
187
- end
188
- CF::Station.create({:line => l, :type => "work"}) do |s1|
189
- CF::RobotWorker.create({:station => s1, :type => "keyword_matching_robot", :settings => {:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj", "iPhone"]}})
190
- end
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
- # WebMock.allow_net_connect!
218
- VCR.use_cassette "run/block/create-run-invalid-data", :record => :new_episodes do
219
- line = CF::Line.create("media_splitting_robot_3","Digitization") do |l|
220
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
221
- CF::Station.create({:line => l, :type => "work"}) do |s|
222
- 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"}})
223
- end
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
- # WebMock.allow_net_connect!
232
- VCR.use_cassette "run/block/create-run-invalid-file", :record => :new_episodes do
233
- line = CF::Line.create("media_splitting_robot_4","Digitization") do |l|
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, "media_splitting_robot_run_4", File.expand_path("../../fixtures/input_data/media_converter_robot.csv", __FILE__))
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
- # WebMock.allow_net_connect!
246
- VCR.use_cassette "run/block/create-run-used-title", :record => :new_episodes do
247
- line = CF::Line.create("media_splitting_robot_5","Digitization") do |l|
248
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
249
- CF::Station.create({:line => l, :type => "work"}) do |s|
250
- 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"}})
251
- end
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
- # WebMock.allow_net_connect!
261
- VCR.use_cassette "run/block/create-run-and-find", :record => :new_episodes do
262
- line = CF::Line.create("media_splitting_robot_6","Digitization") do |l|
263
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
264
- CF::Station.create({:line => l, :type => "work"}) do |s|
265
- 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"}})
266
- end
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
- # WebMock.allow_net_connect!
281
- VCR.use_cassette "run/block/find-run-with-unused-title", :record => :new_episodes do
282
- line = CF::Line.create("media_splitting_robot_7","Digitization") do |l|
283
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
284
- CF::Station.create({:line => l, :type => "work"}) do |s|
285
- 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"}})
286
- end
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
- VCR.use_cassette "run/block/run-progress", :record => :new_episodes do
299
- # WebMock.allow_net_connect!
300
- line = CF::Line.create("progress_run_line","Digitization") do |l|
301
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
302
- CF::Station.create({:line => l, :type => "work"}) do |s|
303
- CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
304
- end
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
- VCR.use_cassette "run/block/run-progress-detail", :record => :new_episodes do
317
- # WebMock.allow_net_connect!
318
- line = CF::Line.create("progress_run_line_1","Digitization") do |l|
319
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
320
- CF::Station.create({:line => l, :type => "work"}) do |s|
321
- CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
322
- end
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
- VCR.use_cassette "run/block/run-progress-detail-for-multiple-station", :record => :new_episodes do
336
- # WebMock.allow_net_connect!
337
- line = CF::Line.create("progress_run_line_2","Digitization") do |l|
338
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
339
- CF::Station.create({:line => l, :type => "work"}) do |s|
340
- CF::RobotWorker.create({:station => s, :type => "text_extraction_robot", :settings => {:url => ["{{url}}"]}})
341
- end
342
- CF::Station.create({:line => l, :type => "work"}) do |s1|
343
- CF::RobotWorker.create({:station => s1, :type => "keyword_matching_robot", :settings => {:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj"]}})
344
- end
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
- VCR.use_cassette "run/block/get-run-account", :record => :new_episodes do
360
- # WebMock.allow_net_connect!
361
- line = CF::Line.create("progress_run_line_3","Digitization") do |l|
362
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
363
- CF::Station.create({:line => l, :type => "work"}) do |s|
364
- CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
365
- end
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
- run = CF::Run.create(line, "progress_run_3", [{"url"=> "http://www.sprout-technology.com"}])
368
- # sleep 10
369
- line_1 = CF::Line.create("progress_run_line_31","Digitization") do |l|
370
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
371
- CF::Station.create({:line => l, :type => "work"}) do |s|
372
- CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
373
- end
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
- run_1 = CF::Run.create(line_1, "progress_run_31", [{"url"=> "http://www.sprout-technology.com"}])
376
- # sleep 10
377
- line_2 = CF::Line.create("progress_run_line_32","Digitization") do |l|
378
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
379
- CF::Station.create({:line => l, :type => "work"}) do |s|
380
- CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
381
- end
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
- VCR.use_cassette "run/block/get-run-line", :record => :new_episodes do
394
- # WebMock.allow_net_connect!
395
- line = CF::Line.create("progress_run_line_11","Digitization") do |l|
396
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
397
- CF::Station.create({:line => l, :type => "work"}) do |s|
398
- CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
399
- end
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
- VCR.use_cassette "run/plain-ruby/get-run-with-page", :record => :new_episodes do
416
- # WebMock.allow_net_connect!
417
- run = CF::Run.all({:page => 1})
418
- run['runs'].class.should eql(Array)
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
- VCR.use_cassette "run/plain-ruby/get-run-with-page-all", :record => :new_episodes do
426
- # WebMock.allow_net_connect!
427
- line = CF::Line.create("pagination_line","Digitization") do |l|
428
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
429
- CF::Station.create({:line => l, :type => "work"}) do |s|
430
- CF::RobotWorker.create({:station => s, :settings => {:url => ["{{url}}"], :max_retrieve => 5, :show_source_text => true}, :type => "term_extraction_robot"})
431
- end
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
- run = CF::Run.all({:page => "all"})
437
- run['total_pages'].should eql(1)
438
- run['runs'].class.should eql(Array)
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
- # WebMock.allow_net_connect!
447
- # change account available_balance to 10 cents
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.code.should eql(200)
466
- resumed_run.status.should eql("resumed")
467
- resumed_run.title.should eql("resume_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
- VCR.use_cassette "run/block/adding_units", :record => :new_episodes do
475
- # WebMock.allow_net_connect!
476
- line = CF::Line.create("adding_units","Digitization") do |l|
477
- CF::InputFormat.new({:line => l, :name => "Company", :required => true})
478
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
479
- CF::Station.create({:line => l, :type => "work"}) do |s|
480
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
481
- CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
482
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
483
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
484
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
485
- end
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
- VCR.use_cassette "run/block/adding_units_file", :record => :new_episodes do
498
- # WebMock.allow_net_connect!
499
- line = CF::Line.create("adding_units_file","Digitization") do |l|
500
- CF::InputFormat.new({:line => l, :name => "Company", :required => true})
501
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
502
- CF::Station.create({:line => l, :type => "work"}) do |s|
503
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
504
- CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
505
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
506
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
507
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
508
- end
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
- VCR.use_cassette "run/block/adding_units_errors", :record => :new_episodes do
521
- # WebMock.allow_net_connect!
522
- line = CF::Line.create("adding_units_error","Digitization") do |l|
523
- CF::InputFormat.new({:line => l, :name => "Company", :required => true})
524
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
525
- CF::Station.create({:line => l, :type => "work"}) do |s|
526
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
527
- CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
528
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
529
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
530
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
531
- end
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
- VCR.use_cassette "run/block/adding_units_empty_errors", :record => :new_episodes do
543
- # WebMock.allow_net_connect!
544
- line = CF::Line.create("adding_units_error_1","Digitization") do |l|
545
- CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
546
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
547
- CF::Station.create({:line => l, :type => "work"}) do |s|
548
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
549
- CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
550
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
551
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
552
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
553
- end
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
- VCR.use_cassette "run/block/delete_run", :record => :new_episodes do
566
- # WebMock.allow_net_connect!
567
- line = CF::Line.create("delete_run","Digitization") do |l|
568
- CF::InputFormat.new({:line => l, :name => "Company", :required => true})
569
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
570
- CF::Station.create({:line => l, :type => "work"}) do |s|
571
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
572
- CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
573
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
574
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
575
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
576
- end
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
- VCR.use_cassette "run/block/delete_run_error", :record => :new_episodes do
590
- delete = CF::Run.destroy("norun")
591
- delete.code.should_not eql(200)
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