cloudfactory 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  module CF
4
4
  describe CF::RobotWorker do
5
5
  context "create a media converter robot worker" do
6
- xit "should create media_converter_robot worker for first station in a plain ruby way" do
6
+ it "should create media_converter_robot worker for first station in a plain ruby way" do
7
7
  # WebMock.allow_net_connect!
8
8
  VCR.use_cassette "robot_worker/media_converter_robot/plain-ruby/create-worker-in-first-station", :record => :new_episodes do
9
9
  line = CF::Line.new("media_converter_robot","Digitization")
@@ -23,7 +23,7 @@ module CF
23
23
  station = CF::Station.new({:type => "work"})
24
24
  line.stations station
25
25
 
26
- worker = CF::RobotWorker.create({:type => "media_converter_robot", :settings => {:url => "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov", :to => "mpg", :audio_quality => "320", :video_quality => "3"}})
26
+ worker = CF::RobotWorker.create({:type => "media_converter_robot", :settings => {:url => ["{{url}}"], :to => "{{to}}", :audio_quality => "{{audio_quality}}", :video_quality => "{{video_quality}}"}})
27
27
  line.stations.first.worker = worker
28
28
 
29
29
  form = CF::TaskForm.new({:title => "Enter text", :instruction => "Describe"})
@@ -32,18 +32,15 @@ module CF
32
32
  form_fields = CF::FormField.new({:label => "Description", :field_type => "SA", :required => "true"})
33
33
  line.stations.first.form.form_fields form_fields
34
34
 
35
- run = CF::Run.create(line, "media_converter_robot_run", [{"url"=> "www.s3.amazon.com/converted/20110518165230/ten.mpg", "to" => "mpg", "audio_quality" => "320", "video_quality" => "3", "meta_data_text"=>"media"}])
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
36
  @final_output = run.final_output
37
37
  line.stations.first.worker.number.should eq(1)
38
- @final_output.first.final_output.first.audio_quality.should eql("320")
39
- @final_output.first.final_output.first.video_quality.should eql("3")
40
- @final_output.first.final_output.first.to.should eql("mpg")
41
- converted_url = @final_output.first.final_output.first.converted_file_from_url.first
38
+ converted_url = @final_output.first.final_output.first.converted_file_from_url
42
39
  File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
43
40
  end
44
41
  end
45
42
 
46
- xit "should create media_converter_robot in block DSL way" do
43
+ it "should create media_converter_robot in block DSL way" do
47
44
  # WebMock.allow_net_connect!
48
45
  VCR.use_cassette "robot_worker/media_converter_robot/block/create-worker-block-dsl-way", :record => :new_episodes do
49
46
  line = CF::Line.create("media_converter_robot_1","Digitization") do |l|
@@ -52,18 +49,15 @@ module CF
52
49
  CF::InputFormat.new({:line => l, :name => "audio_quality", :required => false, :valid_type => "general"})
53
50
  CF::InputFormat.new({:line => l, :name => "video_quality", :required => false, :valid_type => "general"})
54
51
  CF::Station.create({:line => l, :type => "work"}) do |s|
55
- CF::RobotWorker.create({:station => s, :type => "media_converter_robot", :settings => {:url => "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov", :to => "mpg", :audio_quality => "320", :video_quality => "3"}})
52
+ CF::RobotWorker.create({:station => s, :type => "media_converter_robot", :settings => {:url => ["{{url}}"], :to => "{{to}}", :audio_quality => "{{audio_quality}}", :video_quality => "{{video_quality}}"}})
56
53
  end
57
54
  end
58
55
 
59
- run = CF::Run.create(line, "media_converter_robot_run_1", [{"url"=> "www.s3.amazon.com/converted/20110518165230/ten.mpg", "to" => "mpg", "audio_quality" => "320", "video_quality" => "3", "meta_data_text"=>"media"}])
56
+ 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"}])
60
57
 
61
58
  @final_output = run.final_output
62
59
  line.stations.first.worker.number.should eq(1)
63
- @final_output.first.final_output.first.audio_quality.should eql("320")
64
- @final_output.first.final_output.first.video_quality.should eql("3")
65
- @final_output.first.final_output.first.to.should eql("mpg")
66
- converted_url = @final_output.first.final_output.first.converted_file_from_url.first
60
+ converted_url = @final_output.first.final_output.first.converted_file_from_url
67
61
  File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
68
62
  end
69
63
  end
@@ -10,21 +10,19 @@ module CF
10
10
  line = CF::Line.create("media_splitting_robot","Digitization") do |l|
11
11
  CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
12
12
  CF::Station.create({:line => l, :type => "work"}) do |s|
13
- 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"}})
13
+ CF::RobotWorker.create({:station => s, :type => "media_splitting_robot", :settings => {:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"}})
14
14
  end
15
15
  end
16
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
17
  output = run.final_output
18
- output.first.final_output.first.overlapping_time.should eql("1")
19
- output.first.final_output.first.split_duration.should eql("2")
20
- converted_url_1= output.first.final_output.first.splits_of_url.first.first
21
- converted_url_2= output.first.final_output.first.splits_of_url.first.last
18
+ converted_url_1= output.first.final_output.first.splits_of_url.first
19
+ converted_url_2= output.first.final_output.first.splits_of_url.last
22
20
  File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_1}").should eql(true)
23
21
  File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_2}").should eql(true)
24
22
  line.stations.first.worker.class.should eql(CF::RobotWorker)
25
- line.stations.first.worker.reward.should eql(5)
23
+ line.stations.first.worker.reward.should eql(0.01)
26
24
  line.stations.first.worker.number.should eql(1)
27
- line.stations.first.worker.settings.should eql({:url => ["http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"], :split_duration => "2", :overlapping_time => "1"})
25
+ line.stations.first.worker.settings.should eql({:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"})
28
26
  line.stations.first.worker.type.should eql("MediaSplittingRobot")
29
27
  end
30
28
  end
@@ -39,21 +37,19 @@ module CF
39
37
  station = CF::Station.new({:type => "work"})
40
38
  line.stations station
41
39
 
42
- worker = CF::RobotWorker.create({: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"}})
40
+ worker = CF::RobotWorker.create({:type => "media_splitting_robot", :settings => {:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"}})
43
41
  line.stations.first.worker = worker
44
42
 
45
43
  run = CF::Run.create(line, "media_splitting_robot_run_1", [{"url"=> "http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"}])
46
44
  output = run.final_output
47
- output.first.final_output.first.overlapping_time.should eql("1")
48
- output.first.final_output.first.split_duration.should eql("2")
49
- converted_url_1= output.first.final_output.first.splits_of_url.first.first
50
- converted_url_2= output.first.final_output.first.splits_of_url.first.last
45
+ converted_url_1= output.first.final_output.first.splits_of_url.first
46
+ converted_url_2= output.first.final_output.first.splits_of_url.last
51
47
  File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_1}").should eql(true)
52
48
  File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url_2}").should eql(true)
53
49
  line.stations.first.worker.class.should eql(CF::RobotWorker)
54
- line.stations.first.worker.reward.should eql(5)
50
+ line.stations.first.worker.reward.should eql(0.01)
55
51
  line.stations.first.worker.number.should eql(1)
56
- line.stations.first.worker.settings.should eql({:url => ["http://media-robot.s3.amazonaws.com/media_robot/media/upload/8/ten.mov"], :split_duration => "2", :overlapping_time => "1"})
52
+ line.stations.first.worker.settings.should eql({:url => ["{{url}}"], :split_duration => "2", :overlapping_time => "1"})
57
53
  line.stations.first.worker.type.should eql("MediaSplittingRobot")
58
54
  end
59
55
  end
@@ -12,9 +12,9 @@ module CF
12
12
  CF::Station.create({:line => l, :type => "work"}) do |s|
13
13
  CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
14
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 => "SA", :required => "true"})
16
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
17
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "SA", :required => "true"})
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
18
  end
19
19
  end
20
20
  end
@@ -23,8 +23,8 @@ module CF
23
23
 
24
24
  line.title.should eq("Digarde-007")
25
25
 
26
- line.stations.first.input_formats.first['name'].should eq("Company")
27
- line.stations.first.input_formats.first['required'].should eq(true)
26
+ line.input_formats.first.name.should eq("Company")
27
+ line.input_formats.first.required.should eq(true)
28
28
 
29
29
  line.stations[0].type.should eq("WorkStation")
30
30
 
@@ -35,7 +35,7 @@ module CF
35
35
  line.stations[0].form.instruction.should eq("Describe")
36
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("SA")
38
+ line.stations[0].form.form_fields[0].field_type.should eq("short_answer")
39
39
  line.stations[0].form.form_fields[0].required.should eq(true)
40
40
 
41
41
  run.title.should eq("runnamee1")
@@ -44,7 +44,7 @@ module CF
44
44
  end
45
45
  end
46
46
 
47
- it "should create a production run for input data as plain data" do
47
+ it "should create a production run for input data as Block DSL way" do
48
48
  # WebMock.allow_net_connect!
49
49
  VCR.use_cassette "run/block/create-run-without-file", :record => :new_episodes do
50
50
  line = CF::Line.create("Digitizard--11111000","Digitization") do |l|
@@ -53,9 +53,9 @@ module CF
53
53
  CF::Station.create({:line => l, :type => "work"}) do |s|
54
54
  CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
55
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 => "SA", :required => "true"})
57
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
58
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "SA", :required => "true"})
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
59
  end
60
60
  end
61
61
  end
@@ -72,14 +72,13 @@ module CF
72
72
  CF::Station.create({:line => l, :type => "work"}) do |s|
73
73
  CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
74
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 => "SA", :required => "true"})
76
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
77
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "SA", :required => "true"})
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
78
  end
79
79
  end
80
80
  end
81
- old_line = CF::Line.info(line.title)
82
- run = CF::Run.create(old_line,"Runusingline", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
81
+ run = CF::Run.create("Digitizeard123","Runusingline", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
83
82
  run.title.should eq("Runusingline")
84
83
 
85
84
  end
@@ -93,9 +92,9 @@ module CF
93
92
  CF::Station.create({:line => l, :type => "work"}) do |s|
94
93
  CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
95
94
  CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
96
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
97
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
98
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "SA", :required => "true"})
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"})
99
98
  end
100
99
  end
101
100
  end
@@ -108,23 +107,25 @@ module CF
108
107
  it "for a line in a plain ruby way" do
109
108
  VCR.use_cassette "run/plain-ruby/create-run", :record => :new_episodes do
110
109
  line = CF::Line.new("Digitize--ard1", "Digitization")
111
- station = CF::Station.new({:type => "work"})
112
- line.stations station
113
110
  input_format_1 = CF::InputFormat.new({:name => "Company", :required => true, :valid_type => "general"})
114
111
  input_format_2 = CF::InputFormat.new({:name => "Website", :required => true, :valid_type => "url"})
115
112
  line.input_formats input_format_1
116
113
  line.input_formats input_format_2
114
+
115
+ station = CF::Station.new({:type => "work"})
116
+ line.stations station
117
+
117
118
  worker = CF::HumanWorker.new({:number => 1, :reward => 20})
118
119
  line.stations.first.worker = worker
119
120
 
120
121
  form = CF::TaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe"})
121
122
  line.stations.first.form = form
122
123
 
123
- form_fields_1 = CF::FormField.new({:label => "First Name", :field_type => "SA", :required => "true"})
124
+ form_fields_1 = CF::FormField.new({:label => "First Name", :field_type => "short_answer", :required => "true"})
124
125
  line.stations.first.form.form_fields form_fields_1
125
- form_fields_2 = CF::FormField.new({:label => "Middle Name", :field_type => "SA"})
126
+ form_fields_2 = CF::FormField.new({:label => "Middle Name", :field_type => "short_answer"})
126
127
  line.stations.first.form.form_fields form_fields_2
127
- form_fields_3 = CF::FormField.new({:label => "Last Name", :field_type => "SA", :required => "true"})
128
+ form_fields_3 = CF::FormField.new({:label => "Last Name", :field_type => "short_answer", :required => "true"})
128
129
  line.stations.first.form.form_fields form_fields_3
129
130
 
130
131
  run = CF::Run.create(line,"Run-in-plain-ruby-way", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
@@ -144,12 +145,12 @@ module CF
144
145
  line.stations.first.form.instruction.should eql("Describe")
145
146
 
146
147
  line.stations.first.form.form_fields[0].label.should eql("First Name")
147
- line.stations.first.form.form_fields[0].field_type.should eql("SA")
148
+ line.stations.first.form.form_fields[0].field_type.should eql("short_answer")
148
149
  line.stations.first.form.form_fields[0].required.should eql(true)
149
150
  line.stations.first.form.form_fields[1].label.should eql("Middle Name")
150
- line.stations.first.form.form_fields[1].field_type.should eql("SA")
151
+ line.stations.first.form.form_fields[1].field_type.should eql("short_answer")
151
152
  line.stations.first.form.form_fields[2].label.should eql("Last Name")
152
- line.stations.first.form.form_fields[2].field_type.should eql("SA")
153
+ line.stations.first.form.form_fields[2].field_type.should eql("short_answer")
153
154
  line.stations.first.form.form_fields[2].required.should eql(true)
154
155
  end
155
156
  end
@@ -161,44 +162,18 @@ module CF
161
162
  CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
162
163
  CF::Station.create({:line => l, :type => "work"}) do |s|
163
164
  CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
164
- CF::TaskForm.create({:station => s, :title => "Enter blah from card image", :instruction => "Describe"}) do |i|
165
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
166
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
167
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "SA", :required => "true"})
165
+ CF::TaskForm.create({:station => s, :title => "Enter about CEO from card", :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"})
168
169
  end
169
170
  end
170
171
  end
171
172
  run = CF::Run.create(line, "run-name-result-0111111111", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
172
173
  @final_output = run.final_output
173
- @final_output.first.meta_data['company'].should eql("Apple")
174
- @final_output.first.final_outputs.last['first-name'].should eql("Bob")
175
- @final_output.first.final_outputs.last['last-name'].should eql("Marley")
176
- end
177
- end
178
-
179
- xit "should fetch result of the specified station" do
180
- VCR.use_cassette "run/block/fetch-result-of-specified-station", :record => :new_episodes do
181
- line = CF::Line.create("Digitizeard-run-111","Digitization") do |l|
182
- CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
183
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
184
- CF::Station.create({:line => l, :type => "work"}) do |s|
185
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
186
- CF::TaskForm.create({:station => s, :title => "Enter name of CEO :station", :instruction => "Describe"}) do |i|
187
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
188
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
189
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "SA", :required => "true"})
190
- end
191
- end
192
- end
193
-
194
- run = CF::Run.create(line, "run-name-run", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
195
- @final_output = run.final_output
196
- @final_output.first.meta_data['company'].should eql("Apple")
197
- @final_output.first.final_outputs.last['first-name'].should eql("Bob")
198
- @final_output.first.final_outputs.last['last-name'].should eql("Marley")
199
-
200
- result_of_station_1 = run.output(:station => 1)
201
- result_of_station_1.first.meta_data['company'].should eql("Apple")
174
+ # debugger
175
+ @final_output.first.final_output.first['first-name'].should eql("Bob")
176
+ @final_output.first.final_output.first['last-name'].should eql("Marley")
202
177
  end
203
178
  end
204
179
 
@@ -208,10 +183,10 @@ module CF
208
183
  line = CF::Line.create("keyword_matching_robot_result","Digitization") do |l|
209
184
  CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
210
185
  CF::Station.create({:line => l, :type => "work"}) do |s|
211
- CF::RobotWorker.create({:station => s, :type => "text_extraction_robot", :settings => {:url => ["{url}"]}})
186
+ CF::RobotWorker.create({:station => s, :type => "text_extraction_robot", :settings => {:url => ["{{url}}"]}})
212
187
  end
213
188
  CF::Station.create({:line => l, :type => "work"}) do |s1|
214
- CF::RobotWorker.create({:station => s1, :type => "keyword_matching_robot", :settings => {:content => ["{contents_of_url}"], :keywords => ["SaaS","see","additional","deepak","saroj"]}})
189
+ CF::RobotWorker.create({:station => s1, :type => "keyword_matching_robot", :settings => {:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj"]}})
215
190
  end
216
191
  end
217
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"}])
@@ -219,19 +194,19 @@ module CF
219
194
  output.first.final_output.first.included_keywords_count_in_contents_of_url.should eql(["3", "2", "2"])
220
195
  output.first.final_output.first.keyword_included_in_contents_of_url.should eql(["SaaS", "see", "additional"])
221
196
  line.stations.first.worker.class.should eql(CF::RobotWorker)
222
- line.stations.first.worker.reward.should eql(1)
197
+ line.stations.first.worker.reward.should eql(0.5)
223
198
  line.stations.first.worker.number.should eql(1)
224
- line.stations.first.worker.settings.should eql({:url => ["{url}"]})
199
+ line.stations.first.worker.settings.should eql({:url => ["{{url}}"]})
225
200
  line.stations.first.worker.type.should eql("TextExtractionRobot")
226
201
  line.stations.last.worker.class.should eql(CF::RobotWorker)
227
- line.stations.last.worker.reward.should eql(1)
202
+ line.stations.last.worker.reward.should eql(0.5)
228
203
  line.stations.last.worker.number.should eql(1)
229
- line.stations.last.worker.settings.should eql({:content => ["{contents_of_url}"], :keywords => ["SaaS","see","additional","deepak","saroj"]})
204
+ line.stations.last.worker.settings.should eql({:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj"]})
230
205
  line.stations.last.worker.type.should eql("KeywordMatchingRobot")
231
206
  output_of_station_1 = CF::Run.output({:title => "keyword_matching_robot_run_result", :station => 1})
232
207
  output_of_station_2 = CF::Run.output({:title => "keyword_matching_robot_run_result", :station => 2})
233
- output_of_station_2['keyword_included_in_contents_of_url'].should eql(["SaaS", "see", "additional"])
234
- output_of_station_2['included_keywords_count_in_contents_of_url'].should eql(["3", "2", "2"])
208
+ output_of_station_2.first['keyword_included_in_contents_of_url'].should eql(["SaaS", "see", "additional"])
209
+ output_of_station_2.first['included_keywords_count_in_contents_of_url'].should eql(["3", "2", "2"])
235
210
  end
236
211
  end
237
212
 
@@ -250,8 +225,8 @@ module CF
250
225
  end
251
226
 
252
227
  it "should create production run with invalid data" do
253
- WebMock.allow_net_connect!
254
- # VCR.use_cassette "run/block/create-run-invalid-file", :record => :new_episodes do
228
+ # WebMock.allow_net_connect!
229
+ VCR.use_cassette "run/block/create-run-invalid-file", :record => :new_episodes do
255
230
  line = CF::Line.create("media_splitting_robot_4","Digitization") do |l|
256
231
  CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
257
232
  CF::Station.create({:line => l, :type => "work"}) do |s|
@@ -260,8 +235,7 @@ module CF
260
235
  end
261
236
  run = CF::Run.create(line, "media_splitting_robot_run_4", File.expand_path("../../fixtures/input_data/media_converter_robot.csv", __FILE__))
262
237
  run.errors.should eql(["Extra Headers in file: [url_1]", "Insufficient Headers in file: [url]"])
263
-
264
- # end
238
+ end
265
239
  end
266
240
 
267
241
  it "should create production run with used title data" do
@@ -402,12 +376,10 @@ module CF
402
376
  run_2 = CF::Run.create(line_2, "progress_run_32", [{"url"=> "http://www.sprout-technology.com"}])
403
377
 
404
378
  got_run = CF::Run.all
405
- got_run[0].line.title.should eql("progress_run_line_3")
406
- got_run[0].title.should eql("progress_run_3")
407
- got_run[1].line.title.should eql("progress_run_line_31")
408
- got_run[1].title.should eql("progress_run_31")
409
- got_run[2].line.title.should eql("progress_run_line_32")
410
- got_run[2].title.should eql("progress_run_32")
379
+ got_run.first.line.title.should eql("digitizard--11111000")
380
+ got_run.first.title.should eql("run-name--11111000")
381
+ got_run.last.line.title.should eql("progress_run_line_31")
382
+ got_run.last.title.should eql("progress_run_31")
411
383
  end
412
384
  end
413
385
 
@@ -449,6 +421,7 @@ module CF
449
421
  end
450
422
  end
451
423
  run = CF::Run.create(line, "resume_run", [{"Company"=>"Apple,Inc","Website"=>"Apple.com"},{"Company"=>"Google","Website"=>"google.com"}])
424
+ run.errors.should eql("run is created but could not be started because of lack of funds please refund your account to continue the run see your email for more information")
452
425
  # debugger
453
426
  # Change account available_balance to 200000 cents
454
427
  resumed_run = CF::Run.resume("resume_run")
@@ -10,18 +10,17 @@ module CF
10
10
  line = CF::Line.create("sentiment_robot","Digitization") do |l|
11
11
  CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
12
12
  CF::Station.create({:line => l, :type => "work"}) do |s|
13
- CF::RobotWorker.create({:station => s, :settings => {:document => ["{url}"], :sanitize => true}, :type => "sentiment_robot"})
13
+ CF::RobotWorker.create({:station => s, :settings => {:document => ["{{url}}"], :sanitize => true}, :type => "sentiment_robot"})
14
14
  end
15
15
  end
16
16
  run = CF::Run.create(line, "sentiment_robot_run", [{"url"=> "http://www.thehappyguy.com/happiness-self-help-book.html"}])
17
17
  output = run.final_output
18
- output.first.final_output.first.sanitize.should eql("true")
19
18
  output.first.final_output.first.sentiment_of_url.should eql("positive")
20
19
  output.first.final_output.first.sentiment_relevance_of_url.should eql(24.0408)
21
20
  line.stations.first.worker.class.should eql(CF::RobotWorker)
22
- line.stations.first.worker.reward.should eql(0)
21
+ line.stations.first.worker.reward.should eql(0.5)
23
22
  line.stations.first.worker.number.should eql(1)
24
- line.stations.first.worker.settings.should eql({:document => ["{url}"], :sanitize => true})
23
+ line.stations.first.worker.settings.should eql({:document => ["{{url}}"], :sanitize => true})
25
24
  line.stations.first.worker.type.should eql("SentimentRobot")
26
25
  end
27
26
  end
@@ -36,18 +35,17 @@ module CF
36
35
  station = CF::Station.new({:type => "work"})
37
36
  line.stations station
38
37
 
39
- worker = CF::RobotWorker.new({:settings => {:document => ["{url}"], :sanitize => true}, :type => "sentiment_robot"})
38
+ worker = CF::RobotWorker.new({:settings => {:document => ["{{url}}"], :sanitize => true}, :type => "sentiment_robot"})
40
39
  line.stations.first.worker = worker
41
40
 
42
41
  run = CF::Run.create(line, "sentiment_robot_run_1", [{"url"=> "http://www.thehappyguy.com/happiness-self-help-book.html"}])
43
42
  output = run.final_output
44
- output.first.final_output.first.sanitize.should eql("true")
45
43
  output.first.final_output.first.sentiment_of_url.should eql("positive")
46
44
  output.first.final_output.first.sentiment_relevance_of_url.should eql(24.0408)
47
45
  line.stations.first.worker.class.should eql(CF::RobotWorker)
48
- line.stations.first.worker.reward.should eql(0)
46
+ line.stations.first.worker.reward.should eql(0.5)
49
47
  line.stations.first.worker.number.should eql(1)
50
- line.stations.first.worker.settings.should eql({:document => ["{url}"], :sanitize => true})
48
+ line.stations.first.worker.settings.should eql({:document => ["{{url}}"], :sanitize => true})
51
49
  line.stations.first.worker.type.should eql("SentimentRobot")
52
50
  end
53
51
  end
@@ -6,6 +6,7 @@ describe CF::Station do
6
6
  # WebMock.allow_net_connect!
7
7
  VCR.use_cassette "stations/plain-ruby/create", :record => :new_episodes do
8
8
  line = CF::Line.new("Digitize--ard", "Digitization")
9
+ CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
9
10
  station = CF::Station.new({:type => "work"})
10
11
  line.stations station
11
12
  line.stations.first.type.should eql("WorkStation")
@@ -16,12 +17,13 @@ describe CF::Station do
16
17
  # WebMock.allow_net_connect!
17
18
  VCR.use_cassette "stations/block/create-with-block-var", :record => :new_episodes do
18
19
  line = CF::Line.create("igitizeard", "Digitization") do
20
+ CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
19
21
  CF::Station.create({:line => self, :type => "work"}) do |s|
20
22
  CF::HumanWorker.new({:station => s, :number => 2, :reward => 20})
21
23
  CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
22
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
23
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
24
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "SA", :required => "true"})
24
+ CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
25
+ CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
26
+ CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
25
27
  end
26
28
  end
27
29
  end
@@ -40,12 +42,13 @@ describe CF::Station do
40
42
  # WebMock.allow_net_connect!
41
43
  VCR.use_cassette "stations/block/create-without-block-var", :record => :new_episodes do
42
44
  line = CF::Line.create("Digitizrd", "Digitization") do
45
+ CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
43
46
  CF::Station.create({:line => self, :type => "work"}) do
44
47
  CF::HumanWorker.new({:station => self, :number => 2, :reward => 20})
45
48
  CF::TaskForm.create({:station => self, :title => "Enter text from a business card image", :instruction => "Describe"}) do
46
- CF::FormField.new({:form => self, :label => "First Name", :field_type => "SA", :required => "true"})
47
- CF::FormField.new({:form => self, :label => "Middle Name", :field_type => "SA"})
48
- CF::FormField.new({:form => self, :label => "Last Name", :field_type => "SA", :required => "true"})
49
+ CF::FormField.new({:form => self, :label => "First Name", :field_type => "short_answer", :required => "true"})
50
+ CF::FormField.new({:form => self, :label => "Middle Name", :field_type => "short_answer"})
51
+ CF::FormField.new({:form => self, :label => "Last Name", :field_type => "short_answer", :required => "true"})
49
52
  end
50
53
  end
51
54
  end
@@ -65,17 +68,17 @@ describe CF::Station do
65
68
  VCR.use_cassette "stations/block/tournament-station", :record => :new_episodes do
66
69
  line = CF::Line.create("Digitized-9", "Digitization") do
67
70
  CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
68
- CF::Station.create({:line => self, :type => "tournament", :jury_worker=> {:max_judges => 10}, :auto_judge => {:enabled => true}}) do |s|
71
+ CF::Station.create({:line => self, :type => "tournament", :jury_worker=> {:max_judges => 10, :reward => 5}, :auto_judge => {:enabled => true}}) do |s|
69
72
  CF::HumanWorker.new({:station => s, :number => 3, :reward => 20})
70
73
  CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
71
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
72
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
73
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "SA", :required => "true"})
74
+ CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
75
+ CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
76
+ CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
74
77
  end
75
78
  end
76
79
  end
77
80
  line.stations.first.type.should eq("TournamentStation")
78
- line.stations.first.jury_worker.should eql({:max_judges => 10})
81
+ line.stations.first.jury_worker.should eql({:max_judges => 10,:reward=>5})
79
82
  line.stations.first.auto_judge.should eql({:enabled => true})
80
83
  line.stations.first.worker.number.should eql(3)
81
84
  line.stations.first.worker.reward.should eql(20)
@@ -91,6 +94,7 @@ describe CF::Station do
91
94
  # WebMock.allow_net_connect!
92
95
  VCR.use_cassette "stations/block/improve-as-first-station", :record => :new_episodes do
93
96
  line = CF::Line.new("Digitd", "Digitization")
97
+ CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
94
98
  station = CF::Station.new({:type => "improve"})
95
99
  expect { line.stations station }.to raise_error(CF::ImproveStationNotAllowed)
96
100
  end
@@ -129,6 +133,7 @@ describe CF::Station do
129
133
  VCR.use_cassette "stations/plain-ruby/get-station", :record => :new_episodes do
130
134
  line = CF::Line.new("Digitizerd1","Digitization")
131
135
  line.title.should eq("Digitizerd1")
136
+ CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
132
137
  station = CF::Station.new(:type => "Work")
133
138
  line.stations station
134
139
  station.type.should eq("Work")
@@ -141,6 +146,7 @@ describe CF::Station do
141
146
  VCR.use_cassette "stations/plain-ruby/get-all-stations", :record => :new_episodes do
142
147
  line = CF::Line.new("Digitizrd11","Digitization")
143
148
  line.title.should eq("Digitizrd11")
149
+ CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
144
150
  station = CF::Station.new(:type => "Work")
145
151
  line.stations station
146
152
  stations = CF::Station.all(line)
@@ -148,52 +154,6 @@ describe CF::Station do
148
154
  end
149
155
  end
150
156
  end
151
-
152
- context "create multiple station" do
153
- xit "should create two stations with improve station" do
154
- WebMock.allow_net_connect!
155
- # VCR.use_cassette "stations/block/multiple-station", :record => :new_episodes do
156
- line = CF::Line.create("Company Info -1","Digitization") do |l|
157
- CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
158
- CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
159
- CF::Station.create({:line => l, :type => "work"}) do |s|
160
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
161
- CF::TaskForm.create({:station => s, :title => "Enter the name of CEO", :instruction => "Describe"}) do |i|
162
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
163
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
164
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "SA", :required => "true"})
165
- end
166
- end
167
- end
168
-
169
- station = CF::Station.new({:type => "Improve"})
170
- line.stations station
171
-
172
- worker = CF::HumanWorker.new({:number => 1, :reward => 10})
173
- line.stations.last.worker = worker
174
-
175
- form = CF::TaskForm.new({:title => "Enter the address of the given Person", :instruction => "Description"})
176
- line.stations.last.form = form
177
-
178
- form_fields_1 = CF::FormField.new({:label => "Street", :field_type => "SA", :required => "true"})
179
- line.stations.last.form.form_fields form_fields_1
180
- form_fields_2 = CF::FormField.new({:label => "City", :field_type => "SA", :required => "true"})
181
- line.stations.last.form.form_fields form_fields_2
182
- form_fields_3 = CF::FormField.new({:label => "Country", :field_type => "SA", :required => "true"})
183
- line.stations.last.form.form_fields form_fields_3
184
-
185
- run = CF::Run.create(line,"Creation of Multiple Station", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
186
- # debugger
187
- result_of_station_1 = run.output(:station => 1)
188
- result_of_station_2 = run.output(:station => 2)
189
- @final_output = run.final_output
190
- @final_output.first.meta_data['company'].should eql("Apple")
191
- @final_output.first.final_outputs.last['street'].should eql("Kupondole")
192
- @final_output.first.final_outputs.last['city'].should eql("Kathmandu")
193
- @final_output.first.final_outputs.last['country'].should eql("Nepal")
194
- # end
195
- end
196
- end
197
157
 
198
158
  context "create multiple station" do
199
159
  it "should create two stations using different input format" do
@@ -205,9 +165,9 @@ describe CF::Station do
205
165
  CF::Station.create({:line => l, :type => "work", :input_formats=> {:station_0 => [{:name => "Company"},{:name => "Website", :except => true}]}}) do |s|
206
166
  CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
207
167
  CF::TaskForm.create({:station => s, :title => "Enter the name of CEO", :instruction => "Describe"}) do |i|
208
- CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
209
- CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
210
- CF::FormField.new({:form => i, :label => "Last Name", :field_type => "SA", :required => "true"})
168
+ CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
169
+ CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
170
+ CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
211
171
  end
212
172
  end
213
173
  end
@@ -222,11 +182,11 @@ describe CF::Station do
222
182
  form = CF::TaskForm.new({:title => "Enter the address of the given Person", :instruction => "Description"})
223
183
  line.stations.last.form = form
224
184
 
225
- form_fields_1 = CF::FormField.new({:label => "Street", :field_type => "SA", :required => "true"})
185
+ form_fields_1 = CF::FormField.new({:label => "Street", :field_type => "short_answer", :required => "true"})
226
186
  line.stations.last.form.form_fields form_fields_1
227
- form_fields_2 = CF::FormField.new({:label => "City", :field_type => "SA", :required => "true"})
187
+ form_fields_2 = CF::FormField.new({:label => "City", :field_type => "short_answer", :required => "true"})
228
188
  line.stations.last.form.form_fields form_fields_2
229
- form_fields_3 = CF::FormField.new({:label => "Country", :field_type => "SA", :required => "true"})
189
+ form_fields_3 = CF::FormField.new({:label => "Country", :field_type => "short_answer", :required => "true"})
230
190
  line.stations.last.form.form_fields form_fields_3
231
191
  station_1 = line.stations.first.get
232
192
  station_1.input_formats.count.should eql(1)