cloudfactory 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -79,7 +79,7 @@ describe CF::CustomTaskForm do
79
79
  CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
80
80
  CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
81
81
  CF::Station.create({:line => self, :type => "work"}) do |s|
82
- CF::HumanWorker.new({:station => s, :number => 3, :reward => 20})
82
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
83
83
  CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html, :raw_css => css, :raw_javascript => javascript})
84
84
  end
85
85
  end
@@ -222,13 +222,13 @@ describe CF::CustomTaskForm do
222
222
  CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
223
223
  CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
224
224
  CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
225
- CF::HumanWorker.new({:station => s, :number => 3, :reward => 20})
225
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
226
226
  CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html})
227
227
  end
228
228
  end
229
229
  line.title.should eql("Digitizecustomform111")
230
230
  line.department_name.should eql("Digitization")
231
- line.stations.first.form.errors.should eql("[\"Raw html should contain a Form tag\", \"Raw html The name 'final_output[first_name]' is not valid, it should be of format output[name]\", \"Raw html The name 'final_output[middle_name]' is not valid, it should be of format output[name]\", \"Raw html The name 'final_output[last_name]' is not valid, it should be of format output[name]\", \"Raw html The name 'final_output[email]' is not valid, it should be of format output[name]\", \"Raw html The name 'final_output[phone]' is not valid, it should be of format output[name]\", \"Raw html The name 'final_output[mobile]' is not valid, it should be of format output[name]\"]")
231
+ line.stations.first.form.errors.should eql(["Raw html should contain a Form tag", "Raw html The name 'final_output[first_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[middle_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[last_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[email]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[phone]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[mobile]' is not valid, it should be of format output[name]"])
232
232
  end
233
233
  end
234
234
 
@@ -265,13 +265,13 @@ describe CF::CustomTaskForm do
265
265
  CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
266
266
  CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
267
267
  CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
268
- CF::HumanWorker.new({:station => s, :number => 3, :reward => 20})
268
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
269
269
  CF::CustomTaskForm.create({:station => s, :instruction => "Describe", :raw_html => html})
270
270
  end
271
271
  end
272
272
  line.title.should eql("Digitizecustomform112")
273
273
  line.department_name.should eql("Digitization")
274
- line.stations.first.form.errors.should eql("[\"Title can't be blank\", \"Raw html should contain a Form tag\"]")
274
+ line.stations.first.form.errors.should eql(["Title can't be blank", "Raw html should contain a Form tag"])
275
275
  end
276
276
  end
277
277
 
@@ -308,13 +308,13 @@ describe CF::CustomTaskForm do
308
308
  CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
309
309
  CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
310
310
  CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
311
- CF::HumanWorker.new({:station => s, :number => 3, :reward => 20})
311
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
312
312
  CF::CustomTaskForm.create({:station => s, :title => "title", :raw_html => html})
313
313
  end
314
314
  end
315
315
  line.title.should eql("Digitizecustomform113")
316
316
  line.department_name.should eql("Digitization")
317
- line.stations.first.form.errors.should eql("[\"Instruction can't be blank\", \"Raw html should contain a Form tag\"]")
317
+ line.stations.first.form.errors.should eql(["Instruction can't be blank", "Raw html should contain a Form tag"])
318
318
  end
319
319
  end
320
320
 
@@ -325,13 +325,13 @@ describe CF::CustomTaskForm do
325
325
  CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
326
326
  CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
327
327
  CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
328
- CF::HumanWorker.new({:station => s, :number => 3, :reward => 20})
328
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
329
329
  CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"})
330
330
  end
331
331
  end
332
332
  line.title.should eql("Digitizecustomform114")
333
333
  line.department_name.should eql("Digitization")
334
- line.stations.first.form.errors.should eql("[\"Raw html is required\"]")
334
+ line.stations.first.form.errors.should eql(["Raw html is required"])
335
335
  end
336
336
  end
337
337
 
@@ -342,7 +342,7 @@ describe CF::CustomTaskForm do
342
342
  CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
343
343
  CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
344
344
  CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
345
- CF::HumanWorker.new({:station => s, :number => 3, :reward => 20})
345
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
346
346
  end
347
347
  end
348
348
 
@@ -351,7 +351,7 @@ describe CF::CustomTaskForm do
351
351
 
352
352
  line.title.should eql("Digitizecustomform115")
353
353
  line.department_name.should eql("Digitization")
354
- line.stations.first.form.errors.should eql("[\"Raw html is required\"]")
354
+ line.stations.first.form.errors.should eql(["Raw html is required"])
355
355
  end
356
356
  end
357
357
  end
@@ -8,17 +8,18 @@ module CF
8
8
  # WebMock.allow_net_connect!
9
9
  VCR.use_cassette "robot_worker/entity_extraction_robot/block/create-worker-single-station", :record => :new_episodes do
10
10
  line = CF::Line.create("entity_extraction_robot","Digitization") do |l|
11
- CF::InputFormat.new({:line => l, :name => "text", :valid_type => "general", :required => "true"})
11
+ CF::InputFormat.new({:line => l, :name => "text", :required => "true"})
12
12
  CF::Station.create({:line => l, :type => "work"}) do |s|
13
13
  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"]}})
14
14
  end
15
15
  end
16
16
  run = CF::Run.create(line, "entity_extraction_robot_run", [{"text"=> "Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"}])
17
+ # sleep 20
17
18
  output = run.final_output
18
- output.first['entity_counts_of_document'].should eql([["2", "2", "1", "1", "2", "1"]])
19
- output.first['entity_names_of_document'].should eql([["Ludwig Von Beethoven", "Franz Kafka", "George Orwell", "Mozart", "China", "Japan"]])
20
- output.first['entity_relevances_of_document'].should eql([[92.12089999999999, 73.8997, 48.079100000000004, 28.9416, 27.1982, 21.1997]])
21
- output.first['entity_types_of_document'].should eql([["Person", "Person", "Person", "Person", "Country", "Country"]])
19
+ output.first['entity_counts_of_document'].should eql(["2", "2", "1", "1", "2", "1"])
20
+ output.first['entity_names_of_document'].should eql(["Ludwig Von Beethoven", "Franz Kafka", "George Orwell", "Mozart", "China", "Japan"])
21
+ output.first['entity_relevances_of_document'].should eql([92.12089999999999, 73.8997, 48.079100000000004, 28.9416, 27.1982, 21.1997])
22
+ output.first['entity_types_of_document'].should eql(["Person", "Person", "Person", "Person", "Country", "Country"])
22
23
  line.stations.first.worker.class.should eql(CF::RobotWorker)
23
24
  line.stations.first.worker.reward.should eql(0.5)
24
25
  line.stations.first.worker.number.should eql(1)
@@ -30,7 +31,7 @@ module CF
30
31
  # WebMock.allow_net_connect!
31
32
  VCR.use_cassette "robot_worker/entity_extraction_robot/plain-ruby/create-worker-in-first-station", :record => :new_episodes do
32
33
  line = CF::Line.new("entity_extraction_robot_1","Digitization")
33
- input_format = CF::InputFormat.new({:name => "text", :required => "true", :valid_type => "general"})
34
+ input_format = CF::InputFormat.new({:name => "text", :required => "true"})
34
35
  line.input_formats input_format
35
36
 
36
37
  station = CF::Station.new({:type => "work"})
@@ -40,11 +41,12 @@ module CF
40
41
  line.stations.first.worker = worker
41
42
 
42
43
  run = CF::Run.create(line, "entity_extraction_robot_run_1", [{"text"=> "Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"}])
44
+ # sleep 20
43
45
  output = run.final_output
44
- output.first['entity_counts_of_document'].should eql([["2", "2", "1", "1", "2", "1"]])
45
- output.first['entity_names_of_document'].should eql([["Ludwig Von Beethoven", "Franz Kafka", "George Orwell", "Mozart", "China", "Japan"]])
46
- output.first['entity_relevances_of_document'].should eql([[92.12089999999999, 73.8997, 48.079100000000004, 28.9416, 27.1982, 21.1997]])
47
- output.first['entity_types_of_document'].should eql([["Person", "Person", "Person", "Person", "Country", "Country"]])
46
+ output.first['entity_counts_of_document'].should eql(["2", "2", "1", "1", "2", "1"])
47
+ output.first['entity_names_of_document'].should eql(["Ludwig Von Beethoven", "Franz Kafka", "George Orwell", "Mozart", "China", "Japan"])
48
+ output.first['entity_relevances_of_document'].should eql([92.12089999999999, 73.8997, 48.079100000000004, 28.9416, 27.1982, 21.1997])
49
+ output.first['entity_types_of_document'].should eql(["Person", "Person", "Person", "Person", "Country", "Country"])
48
50
  line.stations.first.worker.class.should eql(CF::RobotWorker)
49
51
  line.stations.first.worker.reward.should eql(0.5)
50
52
  line.stations.first.worker.number.should eql(1)
@@ -13,7 +13,7 @@ describe CF::FormField do
13
13
  station = CF::Station.new({:type => "work"})
14
14
  line.stations station
15
15
 
16
- worker = CF::HumanWorker.new({:number => 2, :reward => 20})
16
+ worker = CF::HumanWorker.new({:number => 1, :reward => 20})
17
17
  line.stations.first.worker = worker
18
18
 
19
19
  form = CF::TaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe"})
@@ -52,7 +52,7 @@ describe CF::FormField do
52
52
  line = CF::Line.create("Digitize-0101111-final", "Digitization") do
53
53
  CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
54
54
  CF::Station.create({:line => self, :type => "work"}) do |station|
55
- CF::HumanWorker.new({:station => station, :number => 2, :reward => 20})
55
+ CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
56
56
  CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
57
57
  CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
58
58
  CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
@@ -65,7 +65,7 @@ describe CF::FormField do
65
65
  line.department_name.should eq("Digitization")
66
66
  line.input_formats.first.name.should eql("image_url")
67
67
  line.stations.first.type.should eq("WorkStation")
68
- line.stations.first.worker.number.should eq(2)
68
+ line.stations.first.worker.number.should eq(1)
69
69
  line.stations.first.form.instruction.should eq("Describe")
70
70
  line.stations.first.form.form_fields[0].label.should eq("First Name")
71
71
  line.stations.first.form.form_fields[0].field_type.should eq("short_answer")
@@ -122,7 +122,7 @@ describe CF::FormField do
122
122
  line = CF::Line.create("Digitize-0101111-final", "Digitization") do
123
123
  CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
124
124
  CF::Station.create({:line => self, :type => "work"}) do |station|
125
- CF::HumanWorker.new({:station => station, :number => 2, :reward => 20})
125
+ CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
126
126
  CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
127
127
  CF::FormField.new({:form => i, :field_type => "short_answer", :required => "true"})
128
128
  end
@@ -143,7 +143,7 @@ describe CF::FormField do
143
143
  station = CF::Station.new({:type => "work"})
144
144
  line.stations station
145
145
 
146
- worker = CF::HumanWorker.new({:number => 2, :reward => 20})
146
+ worker = CF::HumanWorker.new({:number => 1, :reward => 20})
147
147
  line.stations.first.worker = worker
148
148
 
149
149
  form = CF::TaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe"})
@@ -163,7 +163,7 @@ describe CF::FormField do
163
163
  line = CF::Line.create("Display_form_fields", "Digitization") do
164
164
  CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
165
165
  CF::Station.create({:line => self, :type => "work"}) do |station|
166
- CF::HumanWorker.new({:station => station, :number => 2, :reward => 20})
166
+ CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
167
167
  CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
168
168
  CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
169
169
  CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
@@ -8,7 +8,7 @@ module CF
8
8
  # WebMock.allow_net_connect!
9
9
  VCR.use_cassette "robot_worker/google_translate_robot/plain-ruby/create-worker-in-first-station", :record => :new_episodes do
10
10
  line = CF::Line.new("google_translate_robot","Digitization")
11
- input_format = CF::InputFormat.new({:name => "text", :required => true, :valid_type => "general"})
11
+ input_format = CF::InputFormat.new({:name => "text", :required => true})
12
12
  line.input_formats input_format
13
13
 
14
14
  station = CF::Station.new({:type => "work"})
@@ -26,6 +26,7 @@ module CF
26
26
  line.stations.first.worker.settings.should eql({:data => ["{{text}}"], :from => "en", :to => "es"})
27
27
  line.stations.first.worker.type.should eql("GoogleTranslateRobot")
28
28
  run = CF::Run.create(line, "google_translate_robot_run", [{"text"=> "I started loving Monsoon"}])
29
+ # sleep 20
29
30
  @final_output = run.final_output
30
31
  line.stations.first.worker.number.should eq(1)
31
32
  @final_output.first['translation_of_text'].should eql('Empecé a amar a Monzón')
@@ -36,7 +37,7 @@ module CF
36
37
  VCR.use_cassette "robot_worker/google_translate_robot/block/create-worker-block-dsl-way", :record => :new_episodes do
37
38
  # WebMock.allow_net_connect!
38
39
  line = CF::Line.create("google_translate_robot_1","Digitization") do |l|
39
- CF::InputFormat.new({:line => l, :name => "text", :required => true, :valid_type => "general"})
40
+ CF::InputFormat.new({:line => l, :name => "text", :required => true})
40
41
  CF::Station.create({:line => l, :type => "work"}) do |s|
41
42
  CF::RobotWorker.create({:station => s, :type => "google_translate_robot", :settings => {:data => ["{{text}}"], :from => "en", :to => "es"}})
42
43
  end
@@ -47,7 +48,7 @@ module CF
47
48
  line.stations.first.worker.settings.should eql({:data => ["{{text}}"], :from => "en", :to => "es"})
48
49
  line.stations.first.worker.type.should eql("GoogleTranslateRobot")
49
50
  run = CF::Run.create(line, "google_translate_robot_run_1", [{"text"=> "I started loving Monsoon"}])
50
-
51
+ # sleep 20
51
52
  @final_output = run.final_output
52
53
  line.stations.first.worker.number.should eq(1)
53
54
  @final_output.first['translation_of_text'].should eql('Empecé a amar a Monzón')
@@ -9,11 +9,11 @@ module CF
9
9
  line = CF::Line.create("human_worker", "Digitization") do |l|
10
10
  CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
11
11
  CF::Station.create({:line =>l, :type => "work"}) do |s|
12
- @worker = CF::HumanWorker.new({:station => s, :number => 2, :reward => 20})
12
+ @worker = CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
13
13
  end
14
14
  end
15
15
  line.stations.first.type.should eql("WorkStation")
16
- line.stations.first.worker.number.should eql(2)
16
+ line.stations.first.worker.number.should eql(1)
17
17
  line.stations.first.worker.reward.should eql(20)
18
18
  end
19
19
  end
@@ -56,10 +56,10 @@ module CF
56
56
  line = CF::Line.create("Display_human_worker", "Digitization") do
57
57
  CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
58
58
  CF::Station.create({:line => self, :type => "work"}) do |station|
59
- CF::HumanWorker.new({:station => station, :number => 2, :reward => 20})
59
+ CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
60
60
  end
61
61
  end
62
- line.stations.first.worker.to_s.should eql("{:id => => #{line.stations.first.worker.id}, :number => 2, :reward => 20, :stat_badge => {\"approval_rating\"=>80, \"assignment_duration\"=>3600, \"abandonment_rate\"=>30, \"country\"=>nil}, :skill_badges => [nil], :errors => }")
62
+ line.stations.first.worker.to_s.should eql("{:id => => #{line.stations.first.worker.id}, :number => 1, :reward => 20, :stat_badge => {\"approval_rating\"=>80, \"assignment_duration\"=>3600, \"abandonment_rate\"=>30, \"country\"=>nil}, :skill_badges => [nil], :errors => }")
63
63
  end
64
64
  end
65
65
  end
@@ -83,11 +83,11 @@ module CF
83
83
  line = CF::Line.create("human_worker3", "Digitization") do |l|
84
84
  CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
85
85
  CF::Station.create({:line =>l, :type => "work"}) do |s|
86
- @worker = CF::HumanWorker.new({:station => s, :number => 2, :reward => 20, :skill_badge => badge})
86
+ @worker = CF::HumanWorker.new({:station => s, :number => 1, :reward => 20, :skill_badge => badge})
87
87
  end
88
88
  end
89
89
  line.stations.first.type.should eql("WorkStation")
90
- line.stations.first.worker.number.should eql(2)
90
+ line.stations.first.worker.number.should eql(1)
91
91
  line.stations.first.worker.reward.should eql(20)
92
92
  line.stations.first.worker.skill_badges.first.should eql([{"title"=>"Football Fanatic", "description"=>"This qualification allows you to perform work at stations which have this badge.", "score"=>nil, "quality_rating"=>nil, "max_badges"=>3, "skill_test"=>{"score_after"=>"submit", "manual_scoring"=>false, "display_answers"=>false, "edit_answers"=>true, "retries"=>0, "pass_percentage"=>100, "test_units"=>[{"input"=>{"name"=>"Lionel Andres Messi", "country"=>"Argentina"}, "expected_output"=>[{"birthplace"=>"Rosario, Santa Fe, Argentina", "match_options"=>{"tolerance"=>"1", "ignore_case"=>"false"}, "position"=>"CF", "current-club"=>"Barcelona"}], "match_options"=>{"tolerance"=>0, "ignore_case"=>false}}]}}])
93
93
  line.stations.first.worker.stat_badge.should eql({"approval_rating"=>80, "assignment_duration"=>3600, "abandonment_rate"=>30, "country"=>nil})
@@ -116,11 +116,11 @@ module CF
116
116
  station = CF::Station.new({:type => "work"})
117
117
  line.stations station
118
118
 
119
- worker = CF::HumanWorker.new({:number => 2, :reward => 20, :skill_badge => skill_badge})
119
+ worker = CF::HumanWorker.new({:number => 1, :reward => 20, :skill_badge => skill_badge})
120
120
  line.stations.first.worker = worker
121
121
 
122
122
  line.stations.first.type.should eql("WorkStation")
123
- line.stations.first.worker.number.should eql(2)
123
+ line.stations.first.worker.number.should eql(1)
124
124
  line.stations.first.worker.reward.should eql(20)
125
125
  line.stations.first.worker.skill_badges.first.should eql([{"title"=>"Football Fanatic", "description"=>"This qualification allows you to perform work at stations which have this badge.", "score"=>nil, "quality_rating"=>nil, "max_badges"=>3, "skill_test"=>{"score_after"=>"submit", "manual_scoring"=>false, "display_answers"=>false, "edit_answers"=>true, "retries"=>0, "pass_percentage"=>100, "test_units"=>[{"input"=>{"name"=>"Lionel Andres Messi", "country"=>"Argentina"}, "expected_output"=>[{"birthplace"=>"Rosario, Santa Fe, Argentina", "match_options"=>{"tolerance"=>"1", "ignore_case"=>"false"}, "position"=>"CF", "current-club"=>"Barcelona"}], "match_options"=>{"tolerance"=>0, "ignore_case"=>false}}]}}])
126
126
  line.stations.first.worker.stat_badge.should eql({"approval_rating"=>80, "assignment_duration"=>3600, "abandonment_rate"=>30, "country"=>nil})
@@ -14,6 +14,7 @@ module CF
14
14
  end
15
15
  end
16
16
  run = CF::Run.create(line, "image_processing_robot_run", [{"url"=> "http://wwwdelivery.superstock.com/WI/223/1527/PreviewComp/SuperStock_1527R-020214.jpg"}])
17
+ # sleep 20
17
18
  output = run.final_output
18
19
  converted_url = output.first['processed_image_of_url']
19
20
  File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
@@ -39,6 +40,7 @@ module CF
39
40
  line.stations.first.worker = worker
40
41
 
41
42
  run = CF::Run.create(line, "image_processing_robot_run_1", [{"url"=> "http://wwwdelivery.superstock.com/WI/223/1527/PreviewComp/SuperStock_1527R-020214.jpg"}])
43
+ # sleep 20
42
44
  output = run.final_output
43
45
  converted_url = output.first['processed_image_of_url']
44
46
  File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
@@ -6,10 +6,9 @@ describe CF::InputFormat do
6
6
  # WebMock.allow_net_connect!
7
7
  VCR.use_cassette "input_formats/plain-ruby/create-within-line", :record => :new_episodes do
8
8
  line = CF::Line.new("Digitize","Digitization")
9
- input_format = CF::InputFormat.new({:name => "Company", :required => true, :valid_type => "general"})
9
+ input_format = CF::InputFormat.new({:name => "Company", :required => true})
10
10
  line.input_formats input_format
11
11
  line.input_formats.first.name.should eql("Company")
12
- line.input_formats.first.valid_type.should eql("general")
13
12
  end
14
13
  end
15
14
 
@@ -82,7 +81,7 @@ describe CF::InputFormat do
82
81
  line = CF::Line.create("Display_input_format", "Digitization") do
83
82
  CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
84
83
  CF::Station.create({:line => self, :type => "work"}) do |station|
85
- CF::HumanWorker.new({:station => station, :number => 2, :reward => 20})
84
+ CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
86
85
  end
87
86
  end
88
87
  line.input_formats.first.to_s.should eql("{:id => #{line.input_formats.first.id}, :name => image_url, :required => true, :valid_type => url, :errors => }")
@@ -17,6 +17,7 @@ module CF
17
17
  end
18
18
  end
19
19
  run = CF::Run.create(line, "keyword_matching_robot_run", [{"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"}])
20
+ # sleep 20
20
21
  output = run.final_output
21
22
  output.first['included_keywords_count_in_contents_of_url'].should eql(["3", "2", "2"])
22
23
  output.first['keyword_included_in_contents_of_url'].should eql(["SaaS", "see", "additional"])
@@ -53,6 +54,7 @@ module CF
53
54
  line.stations.last.worker = worker
54
55
 
55
56
  run = CF::Run.create(line, "keyword_matching_robot_run_1", [{"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"}])
57
+ # sleep 20
56
58
  output = run.final_output
57
59
  output.first['included_keywords_count_in_contents_of_url'].should eql(["3", "2", "2"])
58
60
  output.first['keyword_included_in_contents_of_url'].should eql(["SaaS", "see", "additional"])
data/spec/line_spec.rb CHANGED
@@ -35,7 +35,7 @@ describe CF::Line do
35
35
  line = CF::Line.create("Digitizeard", "Digitization") do
36
36
  CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
37
37
  CF::Station.create({:line => self, :type => "work"}) do |station|
38
- CF::HumanWorker.new({:station => station, :number => 2, :reward => 20})
38
+ CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
39
39
  CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
40
40
  CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
41
41
  CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
@@ -47,7 +47,7 @@ describe CF::Line do
47
47
  line.department_name.should eq("Digitization")
48
48
  line.input_formats.first.name.should eql("image_url")
49
49
  line.stations.first.type.should eq("WorkStation")
50
- line.stations.first.worker.number.should eq(2)
50
+ line.stations.first.worker.number.should eq(1)
51
51
  line.stations.first.form.instruction.should eq("Describe")
52
52
  line.stations.first.form.form_fields.first.label.should eq("First Name")
53
53
  end
@@ -72,7 +72,7 @@ describe CF::Line do
72
72
  line = CF::Line.create("Digitizer1", "Digitization") do |l|
73
73
  CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
74
74
  CF::Station.create({:line => l, :type => "work"}) do |station|
75
- CF::HumanWorker.new({:line => l, :station => station, :number => 2, :reward => 20})
75
+ CF::HumanWorker.new({:line => l, :station => station, :number => 1, :reward => 20})
76
76
  CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
77
77
  CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
78
78
  CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
@@ -84,7 +84,7 @@ describe CF::Line do
84
84
  line.department_name.should eq("Digitization")
85
85
  line.input_formats.first.name.should eql("image_url")
86
86
  line.stations.first.type.should eq("WorkStation")
87
- line.stations.first.worker.number.should eq(2)
87
+ line.stations.first.worker.number.should eq(1)
88
88
  line.stations.first.worker.reward.should eq(20)
89
89
  line.stations.first.form.title.should eq("Enter text from a business card image")
90
90
  line.stations.first.form.instruction.should eq("Describe")
@@ -118,7 +118,7 @@ describe CF::Line do
118
118
  end
119
119
 
120
120
  lines = CF::Line.public_lines
121
- lines.last.title.should eq("lineee-1")
121
+ lines.map(&:title).should include("lineee-1")
122
122
  end
123
123
  end
124
124
  end
@@ -151,7 +151,7 @@ describe CF::Line do
151
151
  VCR.use_cassette "lines/block/non-existing-line", :record => :new_episodes do
152
152
  get_line = CF::Line.info("non-existing-line-title")
153
153
  get_line.code.should eql(404)
154
- get_line.error.message.should match("Line document not found using selector")
154
+ get_line.error.message.should match("Line not found for title: non-existing-line-title under your account")
155
155
  end
156
156
  end
157
157
 
@@ -165,7 +165,7 @@ describe CF::Line do
165
165
  resp = line.destroy
166
166
  resp.code.should eql(200)
167
167
  deleted_resp = CF::Line.info(line)
168
- deleted_resp.error.message.should eql("Line document not found using selector: {:public=>true, :title=>\"digitizerd-2\"}")
168
+ deleted_resp.error.message.should eql("Line not found for title: digitizerd-2 under your account")
169
169
  end
170
170
  end
171
171
 
@@ -188,7 +188,7 @@ describe CF::Line do
188
188
  line = CF::Line.create("Digiard-11","Digitization") do |l|
189
189
  CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
190
190
  CF::Station.create({:line => l, :type => "work"}) do |s|
191
- CF::HumanWorker.new({:station => s, :number => 2, :reward => 20})
191
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
192
192
  CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
193
193
  CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
194
194
  CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "SA"})
@@ -199,7 +199,7 @@ describe CF::Line do
199
199
  line.title.should eq("Digiard-11")
200
200
  line.input_formats.first.name.should eql("image_url")
201
201
  line.stations.first.type.should eq("WorkStation")
202
- line.stations.first.worker.number.should eq(2)
202
+ line.stations.first.worker.number.should eq(1)
203
203
  line.stations.first.worker.reward.should eq(20)
204
204
  line.stations.first.form.title.should eq("Enter text from a business card image")
205
205
  line.stations.first.form.instruction.should eq("Describe")
@@ -235,10 +235,10 @@ describe CF::Line do
235
235
  CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
236
236
  station = CF::Station.new({:type => "work"})
237
237
  line.stations station
238
- worker = CF::HumanWorker.new({:number => 2, :reward => 20})
238
+ worker = CF::HumanWorker.new({:number => 1, :reward => 20})
239
239
  line.stations.first.worker = worker
240
240
  line.stations.first.type.should eql("WorkStation")
241
- line.stations.first.worker.number.should eql(2)
241
+ line.stations.first.worker.number.should eql(1)
242
242
  line.stations.first.worker.reward.should eql(20)
243
243
  end
244
244
  end
@@ -251,7 +251,7 @@ describe CF::Line do
251
251
  station = CF::Station.new({:type => "work"})
252
252
  line.stations station
253
253
 
254
- worker = CF::HumanWorker.new({:number => 2, :reward => 20})
254
+ worker = CF::HumanWorker.new({:number => 1, :reward => 20})
255
255
  line.stations.first.worker = worker
256
256
 
257
257
  form = CF::TaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe"})
@@ -284,7 +284,7 @@ describe CF::Line do
284
284
  station = CF::Station.new({:type => "work"})
285
285
  line.stations station
286
286
 
287
- worker = CF::HumanWorker.new({:number => 2, :reward => 20})
287
+ worker = CF::HumanWorker.new({:number => 1, :reward => 20})
288
288
  line.stations.first.worker = worker
289
289
 
290
290
  form = CF::TaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe"})
@@ -325,7 +325,7 @@ describe CF::Line do
325
325
  VCR.use_cassette "lines/block/delete-line-of-active-run", :record => :new_episodes do
326
326
  # WebMock.allow_net_connect!
327
327
  line = CF::Line.create("delete_line_of_run","Digitization") do |l|
328
- CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
328
+ CF::InputFormat.new({:line => l, :name => "Company", :required => true})
329
329
  CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
330
330
  CF::Station.create({:line => l, :type => "work"}) do |s|
331
331
  CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
@@ -338,16 +338,15 @@ describe CF::Line do
338
338
  end
339
339
 
340
340
  run = CF::Run.create(line, "delete_line_of_run_run", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
341
-
342
341
  delete = CF::Line.destroy("delete_line_of_run")
343
- delete.error.message.should eql("cannot delete the line, Active runs exists. use forced delete if you still want to delete the line.")
342
+ delete.error.message.should eql("Cannot delete line. You have production runs using this line. Pass force option to enforce deletion.")
344
343
  delete.code.should_not eql(200)
345
344
 
346
345
  forced_delete = CF::Line.destroy("delete_line_of_run", :forced => true)
347
346
 
348
347
  search_line = CF::Line.find("delete_line_of_run")
349
348
  search_line['code'].should eql(404)
350
- search_line['error']['message'].should eql("Line document not found using selector: {:public=>true, :title=>\"delete_line_of_run\"}")
349
+ search_line['error']['message'].should eql("Line not found for title: delete_line_of_run under your account")
351
350
  end
352
351
  end
353
352
  end
@@ -357,7 +356,7 @@ describe CF::Line do
357
356
  VCR.use_cassette "lines/block/line-details", :record => :new_episodes do
358
357
  # WebMock.allow_net_connect!
359
358
  line = CF::Line.create("line_details","Digitization") do |l|
360
- CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
359
+ CF::InputFormat.new({:line => l, :name => "Company", :required => true})
361
360
  CF::Station.create({:line => l, :type => "work"}) do |s|
362
361
  CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
363
362
  CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
@@ -367,9 +366,10 @@ describe CF::Line do
367
366
  end
368
367
  line_details = CF::Line.inspect("line_details")
369
368
  line_input_format_id = line_details['input_formats'].first['id']
369
+ worker_id = line_details['stations'].first['worker']['id']
370
370
  form_field_id = line_details['stations'].first['form_fields'].first['id']
371
371
  station_input_format_id = line_details['stations'].first['input_formats'].first['id']
372
- line_details.should eql({"title"=>"line_details", "description"=>"", "public"=>false, "department"=>{"name"=>"Digitization"}, "app"=>{"name"=>"default", "email"=>"manish.das@sprout-technology.com", "notification_url"=>"http://www.cloudfactory.com"}, "code"=>200, "input_formats"=>[{"id"=>"#{line_input_format_id}", "name"=>"Company", "required"=>true, "valid_type"=>"general", "source_station_index"=>0}], "stations"=>[{"index"=>1, "type"=>"WorkStation", "worker"=>{"number"=>1, "reward"=>20, "type"=>"HumanWorker", "stat_badge"=>{"approval_rating"=>80, "abandonment_rate"=>30, "country"=>nil}}, "form"=>{"title"=>"Enter text from a business card image", "instruction"=>"Describe"}, "form_fields"=>[{"id"=>"#{form_field_id}", "label"=>"First Name", "field_type"=>"short_answer", "hint"=>nil, "required"=>true, "unique"=>nil, "hide_label"=>nil, "value"=>nil}], "input_formats"=>[{"id"=>"#{station_input_format_id}", "name"=>"Company", "required"=>true, "valid_type"=>"general", "source_station_index"=>0}]}]})
372
+ line_details.should eql({"title"=>"line_details", "description"=>"", "department"=>"Digitization", "code"=>200, "input_formats"=>[{"id"=>"#{line_input_format_id}", "name"=>"Company", "required"=>true, "valid_type"=>nil}], "stations"=>[{"index"=>1, "type"=>"WorkStation", "worker"=>{"id"=>"4e679284551127c825000203", "number"=>1, "reward"=>20, "type"=>"HumanWorker", "stat_badge"=>{"abandonment_rate"=>30, "approval_rating"=>80, "country"=>nil, "adult"=>nil}, "skill_badge"=>nil}, "form"=>{"title"=>"Enter text from a business card image", "instruction"=>"Describe"}, "form_fields"=>[{"id"=>"#{form_field_id}", "label"=>"First Name", "field_type"=>"short_answer", "hint"=>nil, "required"=>true, "unique"=>nil, "hide_label"=>nil, "value"=>nil}], "input_formats"=>[{"id"=>"#{station_input_format_id}", "name"=>"Company", "required"=>true, "valid_type"=>nil}]}]})
373
373
  end
374
374
  end
375
375
 
@@ -377,7 +377,7 @@ describe CF::Line do
377
377
  VCR.use_cassette "lines/block/line-details_robot_worker", :record => :new_episodes do
378
378
  # WebMock.allow_net_connect!
379
379
  line = CF::Line.create("line_details_robot","Digitization") do |l|
380
- CF::InputFormat.new({:line => l, :name => "text", :valid_type => "general", :required => "true"})
380
+ CF::InputFormat.new({:line => l, :name => "text", :required => "true"})
381
381
  CF::Station.create({:line => l, :type => "work"}) do |s|
382
382
  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"]}})
383
383
  end
@@ -386,7 +386,7 @@ describe CF::Line do
386
386
  line_input_format_id = line_details['input_formats'].first['id']
387
387
  station_input_format_id = line_details['stations'].first['input_formats'].first['id']
388
388
  worker_id = line_details['stations'].first['worker']['id']
389
- line_details.should eql({"title"=>"line_details_robot", "description"=>"", "department"=>"Digitization", "code"=>200, "input_formats"=>[{"id"=>"#{line_input_format_id}", "name"=>"text", "required"=>true, "valid_type"=>"general"}], "stations"=>[{"index"=>1, "type"=>"WorkStation", "worker"=>{"id"=>"#{worker_id}", "number"=>1, "reward"=>0.5, "type"=>"EntityExtractionRobot"}, "input_formats"=>[{"id"=>"#{station_input_format_id}", "name"=>"text", "required"=>true, "valid_type"=>"general"}]}]})
389
+ line_details.should eql({"title"=>"line_details_robot", "description"=>"", "department"=>"Digitization", "code"=>200, "input_formats"=>[{"id"=>"#{line_input_format_id}", "name"=>"text", "required"=>true, "valid_type"=>nil}], "stations"=>[{"index"=>1, "type"=>"WorkStation", "worker"=>{"id"=>"#{worker_id}", "number"=>1, "reward"=>0.5, "type"=>"EntityExtractionRobot"}, "input_formats"=>[{"id"=>"#{station_input_format_id}", "name"=>"text", "required"=>true, "valid_type"=>nil}]}]})
390
390
  end
391
391
  end
392
392