cloudfactory 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/lib/cf/account.rb +3 -6
- data/lib/cf/cli.rb +8 -12
- data/lib/cf/cli/line.rb +13 -13
- data/lib/cf/cli/production.rb +18 -14
- data/lib/cf/client.rb +2 -12
- data/lib/cf/custom_task_form.rb +1 -3
- data/lib/cf/input_format.rb +1 -3
- data/lib/cf/line.rb +63 -66
- data/lib/cf/robot_worker.rb +3 -5
- data/lib/cf/run.rb +21 -58
- data/lib/cf/station.rb +6 -10
- data/lib/cf/task_form.rb +1 -3
- data/lib/cf/version.rb +1 -1
- data/spec/account_spec.rb +3 -5
- data/spec/badge_spec.rb +64 -64
- data/spec/concept_tagging_robot_spec.rb +37 -37
- data/spec/config_spec.rb +0 -1
- data/spec/content_scraping_robot_spec.rb +38 -38
- data/spec/custom_task_form_spec.rb +106 -105
- data/spec/department_spec.rb +5 -6
- data/spec/entity_extraction_robot_spec.rb +39 -39
- data/spec/form_field_spec.rb +148 -148
- data/spec/google_translate_robot_spec.rb +40 -40
- data/spec/human_worker_spec.rb +87 -87
- data/spec/image_processing_robot_spec.rb +37 -37
- data/spec/input_format_spec.rb +97 -97
- data/spec/keyword_matching_and_text_extraction_robot_spec.rb +56 -56
- data/spec/line_spec.rb +442 -416
- data/spec/mailer_robot_spec.rb +39 -39
- data/spec/media_converter_robot_spec.rb +40 -46
- data/spec/media_splitting_robot_spec.rb +41 -41
- data/spec/robot_worker_spec.rb +8 -8
- data/spec/run_spec.rb +424 -432
- data/spec/sentiment_robot_spec.rb +37 -37
- data/spec/station_spec.rb +209 -207
- data/spec/task_form_spec.rb +79 -79
- data/spec/term_extraction_robot_spec.rb +37 -37
- metadata +48 -48
@@ -5,51 +5,51 @@ module CF
|
|
5
5
|
describe CF::RobotWorker do
|
6
6
|
context "create an image processing robot worker" do
|
7
7
|
it "should create image processing robot worker for first station in Block DSL way" do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
WebMock.allow_net_connect!
|
9
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
10
|
+
sleep 1
|
11
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
12
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
13
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
14
|
+
CF::RobotWorker.create({:station => s, :type => "image_processing_robot", :settings => {:image => ["{{url}}"], :sharpen => {:radius => "10"}}})
|
15
15
|
end
|
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
|
18
|
-
output = run.final_output
|
19
|
-
converted_url = output.first['processed_image_of_url']
|
20
|
-
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
|
21
|
-
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
22
|
-
line.stations.first.worker.reward.should eql(0.01)
|
23
|
-
line.stations.first.worker.number.should eql(1)
|
24
|
-
line.stations.first.worker.settings.should eql({:image => ["{{url}}"], :sharpen => {:radius => "10"}})
|
25
|
-
line.stations.first.worker.type.should eql("ImageProcessingRobot")
|
26
16
|
end
|
17
|
+
run = CF::Run.create(line, "image_processing_robot_run", [{"url"=> "http://wwwdelivery.superstock.com/WI/223/1527/PreviewComp/SuperStock_1527R-020214.jpg"}])
|
18
|
+
sleep 10
|
19
|
+
output = run.final_output
|
20
|
+
converted_url = output.first['processed_image_of_url']
|
21
|
+
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
|
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({:image => ["{{url}}"], :sharpen => {:radius => "10"}})
|
26
|
+
line.stations.first.worker.type.should eql("ImageProcessingRobot")
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should create image processing robot worker for first station in a plain ruby way" do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
WebMock.allow_net_connect!
|
31
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
32
|
+
sleep 1
|
33
|
+
line = CF::Line.new(title,"Digitization")
|
34
|
+
input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
|
35
|
+
line.input_formats input_format
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
station = CF::Station.new({:type => "work"})
|
38
|
+
line.stations station
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
worker = CF::RobotWorker.create({:type => "image_processing_robot", :settings => {:image => ["{{url}}"], :sharpen => {:radius => "10"}}})
|
41
|
+
line.stations.first.worker = worker
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
43
|
+
run = CF::Run.create(line, "image_processing_robot_run_1", [{"url"=> "http://wwwdelivery.superstock.com/WI/223/1527/PreviewComp/SuperStock_1527R-020214.jpg"}])
|
44
|
+
sleep 10
|
45
|
+
output = run.final_output
|
46
|
+
converted_url = output.first['processed_image_of_url']
|
47
|
+
File.exist?("/Users/manish/apps/cloudfactory/public#{converted_url}").should eql(true)
|
48
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
49
|
+
line.stations.first.worker.reward.should eql(0.01)
|
50
|
+
line.stations.first.worker.number.should eql(1)
|
51
|
+
line.stations.first.worker.settings.should eql({:image => ["{{url}}"], :sharpen => {:radius => "10"}})
|
52
|
+
line.stations.first.worker.type.should eql("ImageProcessingRobot")
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
data/spec/input_format_spec.rb
CHANGED
@@ -3,135 +3,135 @@ require 'spec_helper'
|
|
3
3
|
describe CF::InputFormat do
|
4
4
|
context "create an input header" do
|
5
5
|
it "in plain ruby way within line" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
WebMock.allow_net_connect!
|
7
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
8
|
+
sleep 1
|
9
|
+
line = CF::Line.new(title,"Digitization")
|
10
|
+
input_format = CF::InputFormat.new({:name => "Company", :required => true})
|
11
|
+
line.input_formats input_format
|
12
|
+
line.input_formats.first.name.should eql("Company")
|
13
13
|
end
|
14
14
|
|
15
15
|
it "in plain ruby way within station" do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
16
|
+
WebMock.allow_net_connect!
|
17
|
+
attrs = {:name => "image_url",
|
18
|
+
:required => true,
|
19
|
+
:valid_type => "url"
|
20
|
+
}
|
21
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
22
|
+
sleep 1
|
23
|
+
line = CF::Line.new(title,"Digitization")
|
24
|
+
input_format = CF::InputFormat.new(attrs)
|
25
|
+
line.input_formats input_format
|
26
|
+
input_format1 = CF::InputFormat.new({:name => "image", :required => true, :valid_type => "url"})
|
27
|
+
line.input_formats input_format1
|
28
|
+
station = CF::Station.new({:type => "work"})
|
29
|
+
line.stations station
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
31
|
+
line.title.should eq(title)
|
32
|
+
line.input_formats.first.name.should eq("image_url")
|
33
|
+
line.input_formats.first.required.should eq(true)
|
34
|
+
line.input_formats.first.valid_type.should eq("url")
|
35
|
+
line.input_formats.last.name.should eq("image")
|
36
|
+
line.input_formats.last.required.should eq(true)
|
37
|
+
line.input_formats.last.valid_type.should eq("url")
|
39
38
|
end
|
40
39
|
|
41
40
|
it "in block DSL way within line" do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
line.input_formats[0].name.should eq("image_url")
|
49
|
-
line.input_formats[1].name.should eq("image")
|
41
|
+
WebMock.allow_net_connect!
|
42
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
43
|
+
sleep 1
|
44
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
45
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
46
|
+
CF::InputFormat.new({:line => l, :name => "image", :required => true, :valid_type => "url"})
|
50
47
|
end
|
48
|
+
line.input_formats[0].name.should eq("image_url")
|
49
|
+
line.input_formats[1].name.should eq("image")
|
51
50
|
end
|
52
|
-
|
51
|
+
|
53
52
|
it "in block DSL way within line without valid_type" do
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
line.input_formats[0].name.should eq("image_url")
|
61
|
-
line.input_formats[1].name.should eq("image")
|
53
|
+
WebMock.allow_net_connect!
|
54
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
55
|
+
sleep 1
|
56
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
57
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
58
|
+
CF::InputFormat.new({:line => l, :name => "image", :required => true})
|
62
59
|
end
|
60
|
+
line.input_formats[0].name.should eq("image_url")
|
61
|
+
line.input_formats[1].name.should eq("image")
|
63
62
|
end
|
64
63
|
|
65
64
|
it "in block DSL way within station" do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
line.input_formats[0].name.should eq("image_url")
|
74
|
-
line.input_formats[1].name.should eq("image")
|
65
|
+
WebMock.allow_net_connect!
|
66
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
67
|
+
sleep 1
|
68
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
69
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
70
|
+
CF::InputFormat.new({:line => l, :name => "image", :required => true, :valid_type => "url"})
|
71
|
+
CF::Station.new({:line => l, :type => "work"})
|
75
72
|
end
|
73
|
+
line.input_formats[0].name.should eq("image_url")
|
74
|
+
line.input_formats[1].name.should eq("image")
|
76
75
|
end
|
77
|
-
|
76
|
+
|
78
77
|
it "should only display the attributes which are mentioned in to_s method" do
|
79
|
-
|
80
|
-
#
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
78
|
+
WebMock.allow_net_connect!
|
79
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
80
|
+
sleep 1
|
81
|
+
line = CF::Line.create(title, "Digitization") do
|
82
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
83
|
+
CF::Station.create({:line => self, :type => "work"}) do |station|
|
84
|
+
CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
|
86
85
|
end
|
87
|
-
line.input_formats.first.to_s.should eql("{:id => #{line.input_formats.first.id}, :name => image_url, :required => true, :valid_type => url, :errors => }")
|
88
86
|
end
|
87
|
+
line.input_formats.first.to_s.should eql("{:id => #{line.input_formats.first.id}, :name => image_url, :required => true, :valid_type => url, :errors => }")
|
89
88
|
end
|
90
89
|
end
|
91
90
|
|
92
91
|
context "return all the input headers" do
|
93
92
|
it "should return all the input headers of a line " do
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
input_formats_of_line = CF::InputFormat.all(line)
|
102
|
-
# => getting input_formats response need to be modified
|
103
|
-
input_formats_of_line.map(&:name).should include("image_url")
|
104
|
-
input_formats_of_line.map(&:name).should include("image")
|
105
|
-
input_formats_of_line.map(&:valid_type).should include("url")
|
93
|
+
WebMock.allow_net_connect!
|
94
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
95
|
+
sleep 1
|
96
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
97
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
98
|
+
CF::InputFormat.new({:line => l, :name => "image", :required => true, :valid_type => "url"})
|
99
|
+
CF::Station.new({:line => l, :type => "work"})
|
106
100
|
end
|
101
|
+
input_formats_of_line = CF::InputFormat.all(line)
|
102
|
+
# => getting input_formats response need to be modified
|
103
|
+
names = input_formats_of_line.map {|i| i['name']}.join(",")
|
104
|
+
names.should include("image_url")
|
105
|
+
names.should include("image")
|
106
|
+
input_formats_of_line.map {|i| i['valid_type']}.join(",").should include("url")
|
107
107
|
end
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
context "create an input_format" do
|
111
111
|
it "in Block DSL way without name to set the error attribute" do
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
line.input_formats[0].name.should eq("image_url")
|
119
|
-
line.input_formats[1].errors.should eql(["Name can't be blank"])
|
112
|
+
WebMock.allow_net_connect!
|
113
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
114
|
+
sleep 1
|
115
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
116
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
117
|
+
CF::InputFormat.new({:line => l, :required => true, :valid_type => "url"})
|
120
118
|
end
|
119
|
+
line.input_formats[0].name.should eq("image_url")
|
120
|
+
line.input_formats[1].errors.should eql(["Name can't be blank"])
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
it "in plain Ruby way with invalid data to set the error attribute" do
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
124
|
+
WebMock.allow_net_connect!
|
125
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
126
|
+
sleep 1
|
127
|
+
line = CF::Line.new(title,"Digitization")
|
128
|
+
input_format_1 = CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"})
|
129
|
+
line.input_formats input_format_1
|
130
|
+
input_format_2 = CF::InputFormat.new({:required => true, :valid_type => "url"})
|
131
|
+
line.input_formats input_format_2
|
132
|
+
|
133
|
+
line.input_formats[0].name.should eq("image_url")
|
134
|
+
line.input_formats[1].errors.should eql(["Name can't be blank"])
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
@@ -5,70 +5,70 @@ module CF
|
|
5
5
|
describe CF::RobotWorker do
|
6
6
|
context "create a keyword matching robot worker and text extraction robot" do
|
7
7
|
it "should create keyword matching robot worker for first station in Block DSL way" do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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 => "text_extraction_robot", :settings => {:url => ["{{url}}"]}})
|
15
|
+
end
|
16
|
+
CF::Station.create({:line => l, :type => "work"}) do |s1|
|
17
|
+
CF::RobotWorker.create({:station => s1, :type => "keyword_matching_robot", :settings => {:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj"]}})
|
18
18
|
end
|
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
|
21
|
-
output = run.final_output
|
22
|
-
output.first['included_keywords_count_in_contents_of_url'].should eql(["3", "2", "2"])
|
23
|
-
output.first['keyword_included_in_contents_of_url'].should eql(["SaaS", "see", "additional"])
|
24
|
-
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
25
|
-
line.stations.first.worker.reward.should eql(0.5)
|
26
|
-
line.stations.first.worker.number.should eql(1)
|
27
|
-
line.stations.first.worker.settings.should eql({:url => ["{{url}}"]})
|
28
|
-
line.stations.first.worker.type.should eql("TextExtractionRobot")
|
29
|
-
line.stations.last.worker.class.should eql(CF::RobotWorker)
|
30
|
-
line.stations.last.worker.reward.should eql(0.5)
|
31
|
-
line.stations.last.worker.number.should eql(1)
|
32
|
-
line.stations.last.worker.settings.should eql({:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj"]})
|
33
|
-
line.stations.last.worker.type.should eql("KeywordMatchingRobot")
|
34
19
|
end
|
20
|
+
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"}])
|
21
|
+
sleep 30
|
22
|
+
output = run.final_output
|
23
|
+
output.first['included_keywords_count_in_contents_of_url'].should eql(["3", "2", "2"])
|
24
|
+
output.first['keyword_included_in_contents_of_url'].should eql(["SaaS", "see", "additional"])
|
25
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
26
|
+
line.stations.first.worker.reward.should eql(0.5)
|
27
|
+
line.stations.first.worker.number.should eql(1)
|
28
|
+
line.stations.first.worker.settings.should eql({:url => ["{{url}}"]})
|
29
|
+
line.stations.first.worker.type.should eql("TextExtractionRobot")
|
30
|
+
line.stations.last.worker.class.should eql(CF::RobotWorker)
|
31
|
+
line.stations.last.worker.reward.should eql(0.5)
|
32
|
+
line.stations.last.worker.number.should eql(1)
|
33
|
+
line.stations.last.worker.settings.should eql({:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj"]})
|
34
|
+
line.stations.last.worker.type.should eql("KeywordMatchingRobot")
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should create keyword matching robot worker for first station in a plain ruby way" do
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
WebMock.allow_net_connect!
|
39
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
40
|
+
sleep 1
|
41
|
+
line = CF::Line.new(title,"Digitization")
|
42
|
+
input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
|
43
|
+
line.input_formats input_format
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
station = CF::Station.new({:type => "work"})
|
46
|
+
line.stations station
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
station_1 = CF::Station.new({:type => "work"})
|
51
|
-
line.stations station
|
52
|
-
|
53
|
-
worker = CF::RobotWorker.create({:type => "keyword_matching_robot", :settings => {:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj"]}})
|
54
|
-
line.stations.last.worker = worker
|
48
|
+
worker = CF::RobotWorker.create({:type => "text_extraction_robot", :settings => {:url => ["{{url}}"]}})
|
49
|
+
line.stations.first.worker = worker
|
55
50
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
51
|
+
station_1 = CF::Station.new({:type => "work"})
|
52
|
+
line.stations station
|
53
|
+
|
54
|
+
worker = CF::RobotWorker.create({:type => "keyword_matching_robot", :settings => {:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj"]}})
|
55
|
+
line.stations.last.worker = worker
|
56
|
+
|
57
|
+
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"}])
|
58
|
+
sleep 30
|
59
|
+
output = run.final_output
|
60
|
+
output.first['included_keywords_count_in_contents_of_url'].should eql(["3", "2", "2"])
|
61
|
+
output.first['keyword_included_in_contents_of_url'].should eql(["SaaS", "see", "additional"])
|
62
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
63
|
+
line.stations.first.worker.reward.should eql(0.5)
|
64
|
+
line.stations.first.worker.number.should eql(1)
|
65
|
+
line.stations.first.worker.settings.should eql({:url => ["{{url}}"]})
|
66
|
+
line.stations.first.worker.type.should eql("TextExtractionRobot")
|
67
|
+
line.stations.last.worker.class.should eql(CF::RobotWorker)
|
68
|
+
line.stations.last.worker.reward.should eql(0.5)
|
69
|
+
line.stations.last.worker.number.should eql(1)
|
70
|
+
line.stations.last.worker.settings.should eql({:content => ["{{contents_of_url}}"], :keywords => ["SaaS","see","additional","deepak","saroj"]})
|
71
|
+
line.stations.last.worker.type.should eql("KeywordMatchingRobot")
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
data/spec/line_spec.rb
CHANGED
@@ -5,556 +5,582 @@ describe CF::Line do
|
|
5
5
|
|
6
6
|
context "create a line" do
|
7
7
|
it "the plain ruby way" do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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.new(title, "Digitization", {:public => false, :description => "this is description"})
|
12
|
+
line.title.should eq(title)
|
13
|
+
line.department_name.should eq("Digitization")
|
14
14
|
end
|
15
15
|
|
16
16
|
it "using block with variable" do
|
17
|
-
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
line.title.should eq("Digitizecard-10")
|
25
|
-
line.department_name.should eq("Digitization")
|
26
|
-
line.input_formats[0].name.should eql("image_url")
|
27
|
-
line.input_formats[1].name.should eql("image")
|
28
|
-
line.stations.first.type.should eq("WorkStation")
|
17
|
+
WebMock.allow_net_connect!
|
18
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
19
|
+
sleep 1
|
20
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
21
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
22
|
+
CF::InputFormat.new({:line => l, :name => "image", :required => true, :valid_type => "url"})
|
23
|
+
CF::Station.new({:line => l, :type => "work"})
|
29
24
|
end
|
25
|
+
line.title.should eq(title)
|
26
|
+
line.department_name.should eq("Digitization")
|
27
|
+
line.input_formats[0].name.should eql("image_url")
|
28
|
+
line.input_formats[1].name.should eql("image")
|
29
|
+
line.stations.first.type.should eq("WorkStation")
|
30
30
|
end
|
31
31
|
|
32
32
|
it "using block without variable" do
|
33
|
-
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
WebMock.allow_net_connect!
|
34
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
35
|
+
sleep 1
|
36
|
+
line = CF::Line.create(title, "Digitization") do
|
37
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
38
|
+
CF::Station.create({:line => self, :type => "work"}) do |station|
|
39
|
+
CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
|
40
|
+
CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
41
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
42
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
43
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
44
44
|
end
|
45
45
|
end
|
46
|
-
line.title.should eq("Digitizeard")
|
47
|
-
line.department_name.should eq("Digitization")
|
48
|
-
line.input_formats.first.name.should eql("image_url")
|
49
|
-
line.stations.first.type.should eq("WorkStation")
|
50
|
-
line.stations.first.worker.number.should eq(1)
|
51
|
-
line.stations.first.form.instruction.should eq("Describe")
|
52
|
-
line.stations.first.form.form_fields.first.label.should eq("First Name")
|
53
46
|
end
|
47
|
+
line.title.should eq(title)
|
48
|
+
line.department_name.should eq("Digitization")
|
49
|
+
line.input_formats.first.name.should eql("image_url")
|
50
|
+
line.stations.first.type.should eq("WorkStation")
|
51
|
+
line.stations.first.worker.number.should eq(1)
|
52
|
+
line.stations.first.form.instruction.should eq("Describe")
|
53
|
+
line.stations.first.form.form_fields.first.label.should eq("First Name")
|
54
54
|
end
|
55
55
|
|
56
56
|
it "with all the optional params" do
|
57
|
-
|
58
|
-
#
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
57
|
+
WebMock.allow_net_connect!
|
58
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
59
|
+
sleep 1
|
60
|
+
line = CF::Line.new(title, "Digitization", {:public => true, :description => "this is description"})
|
61
|
+
line.title.should eq(title)
|
62
|
+
line.department_name.should eq("Digitization")
|
63
|
+
line.public.should eql(true)
|
64
|
+
line.description.should eq("this is description")
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
context "with 1 station" do
|
69
69
|
it "create with a new station" do
|
70
|
-
|
71
|
-
#
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
70
|
+
WebMock.allow_net_connect!
|
71
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
72
|
+
sleep 1
|
73
|
+
line = CF::Line.create(title, "Digitization") do |l|
|
74
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
75
|
+
CF::Station.create({:line => l, :type => "work"}) do |station|
|
76
|
+
CF::HumanWorker.new({:line => l, :station => station, :number => 1, :reward => 20})
|
77
|
+
CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
78
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
79
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
80
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
81
81
|
end
|
82
82
|
end
|
83
|
-
line.title.should eq("Digitizer1")
|
84
|
-
line.department_name.should eq("Digitization")
|
85
|
-
line.input_formats.first.name.should eql("image_url")
|
86
|
-
line.stations.first.type.should eq("WorkStation")
|
87
|
-
line.stations.first.worker.number.should eq(1)
|
88
|
-
line.stations.first.worker.reward.should eq(20)
|
89
|
-
line.stations.first.form.title.should eq("Enter text from a business card image")
|
90
|
-
line.stations.first.form.instruction.should eq("Describe")
|
91
|
-
line.stations.first.form.form_fields.first.label.should eq("First Name")
|
92
|
-
line.stations.first.form.form_fields.first.field_type.should eq("SA")
|
93
|
-
line.stations.first.form.form_fields.first.required.should eq("true")
|
94
83
|
end
|
84
|
+
line.title.should eq(title)
|
85
|
+
line.department_name.should eq("Digitization")
|
86
|
+
line.input_formats.first.name.should eql("image_url")
|
87
|
+
line.stations.first.type.should eq("WorkStation")
|
88
|
+
line.stations.first.worker.number.should eq(1)
|
89
|
+
line.stations.first.worker.reward.should eq(20)
|
90
|
+
line.stations.first.form.title.should eq("Enter text from a business card image")
|
91
|
+
line.stations.first.form.instruction.should eq("Describe")
|
92
|
+
line.stations.first.form.form_fields.first.label.should eq("First Name")
|
93
|
+
line.stations.first.form.form_fields.first.field_type.should eq("short_answer")
|
94
|
+
line.stations.first.form.form_fields.first.required.should eq(true)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
context "listing lines" do
|
99
99
|
it "should list all the existing lines that belong to particular owner" do
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
lines = CF::Line.all
|
106
|
-
lines.class.should eql(Hash)
|
100
|
+
WebMock.allow_net_connect!
|
101
|
+
5.times do |i|
|
102
|
+
title_i = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
103
|
+
sleep 1
|
104
|
+
CF::Line.new(title_i, "Digitization", {:public => false, :description => "#{i}-this is description"})
|
107
105
|
end
|
106
|
+
lines = CF::Line.all
|
107
|
+
lines.class.should eql(Hash)
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should list all the public lines" do
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
111
|
+
WebMock.allow_net_connect!
|
112
|
+
title_0 = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
113
|
+
sleep 1
|
114
|
+
title_10 = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
115
|
+
sleep 1
|
116
|
+
title_11 = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
117
|
+
sleep 1
|
118
|
+
CF::Line.new(title_0, "Digitization", {:public => false, :description => "this is description"})
|
119
|
+
CF::Line.new(title_10, "Digitization", {:public => true, :description => "this is description"})
|
120
|
+
CF::Line.new(title_11, "Digitization", {:public => true, :description => "this is description"})
|
121
|
+
lines = CF::Line.public_lines(:page => "all")
|
122
|
+
lines.map {|l| l['title'] }.join(",").should include(title_11)
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
126
|
context "an existing line" do
|
127
127
|
it "should get the line info by passing the line object" do
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
128
|
+
WebMock.allow_net_connect!
|
129
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
130
|
+
sleep 1
|
131
|
+
line = CF::Line.new(title, "Digitization", {:public => true, :description => "this is description"})
|
132
|
+
get_line = CF::Line.info(line)
|
133
|
+
get_line['title'].should eql(title)
|
134
|
+
get_line['public'].should eql(true)
|
135
|
+
get_line['description'].should eql("this is description")
|
136
136
|
end
|
137
|
-
|
137
|
+
|
138
138
|
it "should get the line info by passing just the title" do
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
139
|
+
WebMock.allow_net_connect!
|
140
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
141
|
+
sleep 1
|
142
|
+
line = CF::Line.new(title, "Digitization", {:public => true, :description => "this is description"})
|
143
|
+
get_line = CF::Line.info(line.title)
|
144
|
+
get_line['title'].should eql(title)
|
145
|
+
get_line['public'].should eql(true)
|
146
|
+
get_line['description'].should eql("this is description")
|
147
147
|
end
|
148
148
|
|
149
149
|
it "should render the error sent via the API overriding the RestClient one" do
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
get_line.error.message.should match("Line not found for title: non-existing-line-title under your account")
|
155
|
-
end
|
150
|
+
WebMock.allow_net_connect!
|
151
|
+
get_line = CF::Line.info("non-existing-line-title")
|
152
|
+
get_line['code'].should eql(404)
|
153
|
+
get_line['error']['message'].should match("Line not found for title: non-existing-line-title under your account")
|
156
154
|
end
|
157
155
|
|
158
156
|
end
|
159
157
|
|
160
158
|
context "deleting" do
|
161
159
|
it "should delete a line" do
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
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.new(title, "Digitization", {:public => true, :description => "this is description"})
|
164
|
+
resp = line.destroy
|
165
|
+
resp['code'].should eql(200)
|
166
|
+
deleted_resp = CF::Line.info(line)
|
167
|
+
deleted_resp['error']['message'].should eql("Line not found for title: #{title} under your account")
|
170
168
|
end
|
171
|
-
|
169
|
+
|
172
170
|
it "should delete a line" do
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
171
|
+
WebMock.allow_net_connect!
|
172
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
173
|
+
sleep 1
|
174
|
+
line = CF::Line.new(title, "Digitization", {:public => true, :description => "this is description"})
|
175
|
+
resp = CF::Line.destroy(title)
|
176
|
+
resp['code'].should eql(200)
|
177
|
+
deleted_resp = CF::Line.info(line)
|
178
|
+
deleted_resp['error']['message'].should eql("Line not found for title: #{title} under your account")
|
181
179
|
end
|
182
180
|
end
|
183
181
|
|
184
182
|
context "create a basic line" do
|
185
183
|
it "should create a basic line with one station" do
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
184
|
+
WebMock.allow_net_connect!
|
185
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
186
|
+
sleep 1
|
187
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
188
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
189
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
190
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
191
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
192
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
193
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
194
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
197
195
|
end
|
198
196
|
end
|
199
|
-
line.title.should eq("Digiard-11")
|
200
|
-
line.input_formats.first.name.should eql("image_url")
|
201
|
-
line.stations.first.type.should eq("WorkStation")
|
202
|
-
line.stations.first.worker.number.should eq(1)
|
203
|
-
line.stations.first.worker.reward.should eq(20)
|
204
|
-
line.stations.first.form.title.should eq("Enter text from a business card image")
|
205
|
-
line.stations.first.form.instruction.should eq("Describe")
|
206
|
-
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
207
|
-
line.stations.first.form.form_fields[0].field_type.should eq("SA")
|
208
|
-
line.stations.first.form.form_fields[0].required.should eq("true")
|
209
|
-
line.stations.first.form.form_fields[1].label.should eq("Middle Name")
|
210
|
-
line.stations.first.form.form_fields[1].field_type.should eq("SA")
|
211
|
-
line.stations.first.form.form_fields[1].required.should eq(nil)
|
212
|
-
line.stations.first.form.form_fields[2].label.should eq("Last Name")
|
213
|
-
line.stations.first.form.form_fields[2].field_type.should eq("SA")
|
214
|
-
line.stations.first.form.form_fields[2].required.should eq("true")
|
215
197
|
end
|
198
|
+
line.title.should eq(title)
|
199
|
+
line.input_formats.first.name.should eql("image_url")
|
200
|
+
line.stations.first.type.should eq("WorkStation")
|
201
|
+
line.stations.first.worker.number.should eq(1)
|
202
|
+
line.stations.first.worker.reward.should eq(20)
|
203
|
+
line.stations.first.form.title.should eq("Enter text from a business card image")
|
204
|
+
line.stations.first.form.instruction.should eq("Describe")
|
205
|
+
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
206
|
+
line.stations.first.form.form_fields[0].field_type.should eq("short_answer")
|
207
|
+
line.stations.first.form.form_fields[0].required.should eq(true)
|
208
|
+
line.stations.first.form.form_fields[1].label.should eq("Middle Name")
|
209
|
+
line.stations.first.form.form_fields[1].field_type.should eq("short_answer")
|
210
|
+
line.stations.first.form.form_fields[1].required.should eq(nil)
|
211
|
+
line.stations.first.form.form_fields[2].label.should eq("Last Name")
|
212
|
+
line.stations.first.form.form_fields[2].field_type.should eq("short_answer")
|
213
|
+
line.stations.first.form.form_fields[2].required.should eq(true)
|
216
214
|
end
|
217
215
|
end
|
218
216
|
|
219
217
|
context "create line using plain ruby way" do
|
220
218
|
it "should create a station " do
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
219
|
+
WebMock.allow_net_connect!
|
220
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
221
|
+
sleep 1
|
222
|
+
line = CF::Line.new(title, "Digitization")
|
223
|
+
CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
|
224
|
+
station = CF::Station.new({:type => "work"})
|
225
|
+
line.stations station
|
226
|
+
line.stations.first.type.should eql("WorkStation")
|
229
227
|
end
|
230
228
|
|
231
229
|
it "should create a human worker within station" do
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
230
|
+
WebMock.allow_net_connect!
|
231
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
232
|
+
sleep 1
|
233
|
+
line = CF::Line.new(title, "Digitization")
|
234
|
+
CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
|
235
|
+
station = CF::Station.new({:type => "work"})
|
236
|
+
line.stations station
|
237
|
+
worker = CF::HumanWorker.new({:number => 1, :reward => 20})
|
238
|
+
line.stations.first.worker = worker
|
239
|
+
line.stations.first.type.should eql("WorkStation")
|
240
|
+
line.stations.first.worker.number.should eql(1)
|
241
|
+
line.stations.first.worker.reward.should eql(20)
|
244
242
|
end
|
245
243
|
|
246
244
|
it "should create a TaskForm within station" do
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
245
|
+
WebMock.allow_net_connect!
|
246
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
247
|
+
sleep 1
|
248
|
+
line = CF::Line.new(title, "Digitization")
|
249
|
+
CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
|
250
|
+
station = CF::Station.new({:type => "work"})
|
251
|
+
line.stations station
|
252
|
+
|
253
|
+
worker = CF::HumanWorker.new({:number => 1, :reward => 20})
|
254
|
+
line.stations.first.worker = worker
|
255
|
+
|
256
|
+
form = CF::TaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe"})
|
257
|
+
line.stations.first.form = form
|
258
|
+
|
259
|
+
line.stations.first.form.title.should eql("Enter text from a business card image")
|
260
|
+
line.stations.first.form.instruction.should eql("Describe")
|
263
261
|
end
|
264
262
|
|
265
263
|
it "should create an input_format within line" do
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
264
|
+
WebMock.allow_net_connect!
|
265
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
266
|
+
sleep 1
|
267
|
+
line = CF::Line.new(title, "Digitization")
|
268
|
+
input_format = CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"})
|
269
|
+
line.input_formats input_format
|
270
|
+
station = CF::Station.new({:type => "work"})
|
271
|
+
line.stations station
|
272
|
+
line.input_formats.first.name.should eq("image_url")
|
273
|
+
line.input_formats.first.required.should eq(true)
|
274
|
+
line.input_formats.first.valid_type.should eq("url")
|
277
275
|
end
|
278
276
|
|
279
277
|
it "should create form fields within the standard instruction" do
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
278
|
+
WebMock.allow_net_connect!
|
279
|
+
sleep 1
|
280
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
281
|
+
line = CF::Line.new(title, "Digitization")
|
282
|
+
CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
|
283
|
+
station = CF::Station.new({:type => "work"})
|
284
|
+
line.stations station
|
285
|
+
|
286
|
+
worker = CF::HumanWorker.new({:number => 1, :reward => 20})
|
287
|
+
line.stations.first.worker = worker
|
288
|
+
|
289
|
+
form = CF::TaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe"})
|
290
|
+
line.stations.first.form = form
|
291
|
+
|
292
|
+
form_fields_1 = CF::FormField.new({:label => "First Name", :field_type => "short_answer", :required => "true"})
|
293
|
+
line.stations.first.form.form_fields form_fields_1
|
294
|
+
form_fields_2 = CF::FormField.new({:label => "Middle Name", :field_type => "short_answer"})
|
295
|
+
line.stations.first.form.form_fields form_fields_2
|
296
|
+
form_fields_3 = CF::FormField.new({:label => "Last Name", :field_type => "short_answer", :required => "true"})
|
297
|
+
line.stations.first.form.form_fields form_fields_3
|
298
|
+
|
299
|
+
line.stations.first.form.form_fields[0].label.should eql("First Name")
|
300
|
+
line.stations.first.form.form_fields[0].field_type.should eq("short_answer")
|
301
|
+
line.stations.first.form.form_fields[0].required.should eq(true)
|
302
|
+
line.stations.first.form.form_fields[1].label.should eql("Middle Name")
|
303
|
+
line.stations.first.form.form_fields[1].field_type.should eq("short_answer")
|
304
|
+
line.stations.first.form.form_fields[2].label.should eql("Last Name")
|
305
|
+
line.stations.first.form.form_fields[2].field_type.should eq("short_answer")
|
306
|
+
line.stations.first.form.form_fields[2].required.should eq(true)
|
309
307
|
end
|
310
308
|
end
|
311
|
-
|
309
|
+
|
312
310
|
context "create a line" do
|
313
311
|
it "the plain ruby way" do
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
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.new(title, "Digitization")
|
316
|
+
line_1 = CF::Line.new(title, "Digitization")
|
317
|
+
line_1.errors.should eql(["Title is already taken for this account"])
|
320
318
|
end
|
321
319
|
end
|
322
|
-
|
320
|
+
|
323
321
|
context "delete line whose production run is already created" do
|
324
322
|
it "it should throw error and must be deleted if forced true is passed" do
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
323
|
+
WebMock.allow_net_connect!
|
324
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
325
|
+
sleep 1
|
326
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
327
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true})
|
328
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
329
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
330
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
331
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
332
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
333
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
334
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
337
335
|
end
|
338
336
|
end
|
337
|
+
end
|
339
338
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
forced_delete = CF::Line.destroy("delete_line_of_run", :forced => true)
|
339
|
+
run = CF::Run.create(line, "run-#{title}", File.expand_path("../../fixtures/input_data/test.csv", __FILE__))
|
340
|
+
delete = CF::Line.destroy(title)
|
341
|
+
delete['error']['message'].should eql("Cannot delete line. You have production runs using this line. Pass force option to enforce deletion.")
|
342
|
+
delete['code'].should_not eql(200)
|
346
343
|
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
344
|
+
forced_delete = CF::Line.destroy(title, :forced => true)
|
345
|
+
|
346
|
+
search_line = CF::Line.find(title)
|
347
|
+
search_line['code'].should eql(404)
|
348
|
+
search_line['error']['message'].should eql("Line not found for title: #{title} under your account")
|
351
349
|
end
|
352
350
|
end
|
353
|
-
|
351
|
+
|
354
352
|
context "returns all the associated elements of line" do
|
355
353
|
it "it give details of line" do
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
354
|
+
WebMock.allow_net_connect!
|
355
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
356
|
+
sleep 1
|
357
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
358
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true})
|
359
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
360
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
361
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
362
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
365
363
|
end
|
366
364
|
end
|
367
|
-
line_details = CF::Line.inspect("line_details")
|
368
|
-
line_input_format_id = line_details['input_formats'].first['id']
|
369
|
-
worker_id = line_details['stations'].first['worker']['id']
|
370
|
-
form_field_id = line_details['stations'].first['form_fields'].first['id']
|
371
|
-
station_input_format_id = line_details['stations'].first['input_formats'].first['id']
|
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
365
|
end
|
366
|
+
line_details = CF::Line.inspect(title)
|
367
|
+
line_input_format_id = line_details['input_formats'].first['id']
|
368
|
+
worker_id = line_details['stations'].first['worker']['id']
|
369
|
+
form_field_id = line_details['stations'].first['form_fields'].first['id']
|
370
|
+
station_input_format_id = line_details['stations'].first['input_formats'].first['id']
|
371
|
+
line_details.should eql({"title"=>"#{title}", "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"=>"#{worker_id}", "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}]}]})
|
374
372
|
end
|
375
|
-
|
373
|
+
|
376
374
|
it "for robot worker" do
|
377
|
-
|
378
|
-
#
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
375
|
+
WebMock.allow_net_connect!
|
376
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
377
|
+
sleep 1
|
378
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
379
|
+
CF::InputFormat.new({:line => l, :name => "text", :required => "true"})
|
380
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
381
|
+
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"]}})
|
384
382
|
end
|
385
|
-
line_details = CF::Line.inspect("line_details_robot")
|
386
|
-
line_input_format_id = line_details['input_formats'].first['id']
|
387
|
-
station_input_format_id = line_details['stations'].first['input_formats'].first['id']
|
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"=>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
383
|
end
|
384
|
+
line_details = CF::Line.inspect(title)
|
385
|
+
line_input_format_id = line_details['input_formats'].first['id']
|
386
|
+
station_input_format_id = line_details['stations'].first['input_formats'].first['id']
|
387
|
+
worker_id = line_details['stations'].first['worker']['id']
|
388
|
+
line_details.should eql({"title"=>"#{title}", "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}]}]})
|
391
389
|
end
|
392
|
-
|
390
|
+
|
393
391
|
it "with skill test feature" do
|
394
|
-
|
395
|
-
|
396
|
-
|
392
|
+
WebMock.allow_net_connect!
|
393
|
+
badge =
|
394
|
+
{
|
395
|
+
:title => 'Football Fanatic',
|
396
|
+
:description => "This qualification allows you to perform work at stations which have this badge.",
|
397
|
+
:max_badges => 3,
|
398
|
+
:test =>
|
397
399
|
{
|
398
|
-
:
|
399
|
-
:
|
400
|
-
:
|
401
|
-
:test =>
|
402
|
-
{
|
403
|
-
:input => {:name => "Lionel Andres Messi", :country => "Argentina"},
|
404
|
-
:expected_output =>
|
405
|
-
[{:birthplace => "Rosario, Santa Fe, Argentina",:match_options => {:tolerance => 10, :ignore_case => true }},{:position => "CF",:match_options => {:tolerance => 1 }},{:"current-club" => "Barcelona",:match_options => {:tolerance => 1, :ignore_case => false }}]
|
406
|
-
}
|
400
|
+
:input => {:name => "Lionel Andres Messi", :country => "Argentina"},
|
401
|
+
:expected_output =>
|
402
|
+
[{:birthplace => "Rosario, Santa Fe, Argentina",:match_options => {:tolerance => 10, :ignore_case => true }},{:position => "CF",:match_options => {:tolerance => 1 }},{:"current-club" => "Barcelona",:match_options => {:tolerance => 1, :ignore_case => false }}]
|
407
403
|
}
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
404
|
+
}
|
405
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
406
|
+
sleep 2
|
407
|
+
line = CF::Line.create(title, "Digitization") do |l|
|
408
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
409
|
+
CF::Station.create({:line =>l, :type => "work"}) do |s|
|
410
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20, :skill_badge => badge})
|
411
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
412
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
415
413
|
end
|
416
414
|
end
|
417
|
-
line_details = CF::Line.inspect("line_details_skill_test")
|
418
|
-
line_input_format_id = line_details['input_formats'].first['id']
|
419
|
-
station_input_format_id = line_details['stations'].first['input_formats'].first['id']
|
420
|
-
form_field_id = line_details['stations'].first['form_fields'].first['id']
|
421
|
-
worker_id = line_details['stations'].first['worker']['id']
|
422
|
-
line_details.should eql({"title"=>"line_details_skill_test", "description"=>"", "department"=>"Digitization", "code"=>200, "input_formats"=>[{"id"=>"#{line_input_format_id}", "name"=>"image_url", "required"=>true, "valid_type"=>"url"}], "stations"=>[{"index"=>1, "type"=>"WorkStation", "worker"=>{"id"=>"#{worker_id}", "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"=>"image_url", "required"=>true, "valid_type"=>"url"}]}]})
|
423
415
|
end
|
416
|
+
line_details = CF::Line.inspect(title)
|
417
|
+
line_input_format_id = line_details['input_formats'].first['id']
|
418
|
+
station_input_format_id = line_details['stations'].first['input_formats'].first['id']
|
419
|
+
form_field_id = line_details['stations'].first['form_fields'].first['id']
|
420
|
+
worker_id = line_details['stations'].first['worker']['id']
|
421
|
+
line_details.should eql({"title"=>"#{title}", "description"=>"", "department"=>"Digitization", "code"=>200, "input_formats"=>[{"id"=>"#{line_input_format_id}", "name"=>"image_url", "required"=>true, "valid_type"=>"url"}], "stations"=>[{"index"=>1, "type"=>"WorkStation", "worker"=>{"id"=>"#{worker_id}", "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"=>"image_url", "required"=>true, "valid_type"=>"url"}]}]})
|
424
422
|
end
|
425
|
-
|
423
|
+
|
426
424
|
it "should get all lines with pagination" do
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
line.class.should eql(Hash)
|
431
|
-
end
|
425
|
+
WebMock.allow_net_connect!
|
426
|
+
line = CF::Line.all(:page => 1)
|
427
|
+
line.class.should eql(Hash)
|
432
428
|
end
|
433
|
-
|
429
|
+
|
434
430
|
it "should get all lines with pagination all" do
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
line = CF::Line.all(:page => "all")
|
441
|
-
line['total_pages'].should eql(1)
|
442
|
-
line['lines'].class.should eql(Array)
|
431
|
+
WebMock.allow_net_connect!
|
432
|
+
25.times do |i|
|
433
|
+
title_i = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
434
|
+
sleep 1
|
435
|
+
CF::Line.new(title_i, "Digitization", {:public => true, :description => "#{i}-this is description"})
|
443
436
|
end
|
437
|
+
line = CF::Line.all(:page => "all")
|
438
|
+
line['total_pages'].should eql(1)
|
439
|
+
line['lines'].class.should eql(Array)
|
444
440
|
end
|
445
441
|
end
|
446
|
-
|
442
|
+
|
447
443
|
context "get a line of other account" do
|
448
444
|
it "as public line" do
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
445
|
+
WebMock.allow_net_connect!
|
446
|
+
CF.configure do |config|
|
447
|
+
config.api_key = "1d38e382894338beda100736808f5a06083063e2"
|
448
|
+
config.account_name = "hero"
|
449
|
+
end
|
450
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
451
|
+
sleep 1
|
452
|
+
line = CF::Line.create(title, "Digitization") do
|
453
|
+
CF::InputFormat.new({:line => self, :name => "text", :required => true})
|
454
|
+
CF::Station.create({:line => self, :type => "work"}) do |station|
|
455
|
+
CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
|
456
|
+
CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
457
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
458
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
459
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
460
|
+
end
|
461
|
+
end
|
458
462
|
end
|
463
|
+
got_line = CF::Line.find("hero/#{title}")
|
464
|
+
got_line['title'].should eql("#{title}")
|
465
|
+
got_line['public'].should eql(true)
|
466
|
+
CF.configure do |config|
|
467
|
+
config.account_name = API_CONFIG['account_name']
|
468
|
+
config.api_version = API_CONFIG['api_version']
|
469
|
+
config.api_url = API_CONFIG['api_url']
|
470
|
+
config.api_key = API_CONFIG['api_key']
|
471
|
+
end
|
472
|
+
run = CF::Run.create("hero/#{title}", "run-#{title}", [{"text" => "run for public line of another account"}])
|
473
|
+
run.title.should eql("run-#{title}")
|
474
|
+
run.input.should eql([{"text" => "run for public line of another account"}])
|
459
475
|
end
|
460
|
-
|
476
|
+
|
461
477
|
it "as private line" do
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
478
|
+
WebMock.allow_net_connect!
|
479
|
+
CF.configure do |config|
|
480
|
+
config.api_key = "1d38e382894338beda100736808f5a06083063e2"
|
481
|
+
config.account_name = "hero"
|
482
|
+
end
|
483
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
484
|
+
sleep 1
|
485
|
+
line = CF::Line.new(title, "Digitization", {:public => false, :description => "this is description"})
|
486
|
+
CF.configure do |config|
|
487
|
+
config.account_name = API_CONFIG['account_name']
|
488
|
+
config.api_version = API_CONFIG['api_version']
|
489
|
+
config.api_url = API_CONFIG['api_url']
|
490
|
+
config.api_key = API_CONFIG['api_key']
|
467
491
|
end
|
492
|
+
got_line = CF::Line.find("hero/#{title}")
|
493
|
+
got_line['code'].should eql(404)
|
494
|
+
got_line['error']['message'].should eql("Line with title: #{title} under account hero is not public")
|
468
495
|
end
|
469
496
|
end
|
470
|
-
|
497
|
+
|
471
498
|
context "create line with output format" do
|
472
499
|
it "should create in block Dsl way with two stations" do
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
500
|
+
WebMock.allow_net_connect!
|
501
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
502
|
+
sleep 1
|
503
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
504
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
|
505
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
506
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
507
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
|
508
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
509
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
510
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
511
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
485
512
|
end
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
513
|
+
end
|
514
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
515
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
516
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
517
|
+
CF::FormField.new({:form => i, :label => "Address", :field_type => "short_answer", :required => "true"})
|
518
|
+
CF::FormField.new({:form => i, :label => "Mobile", :field_type => "short_answer"})
|
519
|
+
CF::FormField.new({:form => i, :label => "Email", :field_type => "email", :required => "true"})
|
493
520
|
end
|
494
|
-
CF::OutputFormat.new({:line => l, :station_1 => [{:name => "First Name"}],:station_2 => [{:name => "Mobile", :except => true}]})
|
495
521
|
end
|
496
|
-
line
|
497
|
-
line.input_formats.first.name.should eql("Company")
|
498
|
-
line.stations.first.type.should eq("WorkStation")
|
499
|
-
line.stations.first.worker.number.should eq(1)
|
500
|
-
line.stations.first.worker.reward.should eq(10)
|
501
|
-
line.output_formats.settings.should eql({:station_1 => [{:name => "First Name"}],:station_2 => [{:name => "Mobile", :except => true}]})
|
522
|
+
CF::OutputFormat.new({:line => l, :station_1 => [{:name => "First Name"}],:station_2 => [{:name => "Mobile", :except => true}]})
|
502
523
|
end
|
524
|
+
line.title.should eq(title)
|
525
|
+
line.input_formats.first.name.should eql("Company")
|
526
|
+
line.stations.first.type.should eq("WorkStation")
|
527
|
+
line.stations.first.worker.number.should eq(1)
|
528
|
+
line.stations.first.worker.reward.should eq(10)
|
529
|
+
line.output_formats.settings.should eql({:station_1 => [{:name => "First Name"}],:station_2 => [{:name => "Mobile", :except => true}]})
|
503
530
|
end
|
504
|
-
|
531
|
+
|
505
532
|
it "should create in plain ruby way with two stations" do
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
533
|
+
WebMock.allow_net_connect!
|
534
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
535
|
+
sleep 1
|
536
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
537
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
|
538
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
539
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
540
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
|
541
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
542
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
543
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
544
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
518
545
|
end
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
546
|
+
end
|
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 => "Address", :field_type => "short_answer", :required => "true"})
|
551
|
+
CF::FormField.new({:form => i, :label => "Mobile", :field_type => "short_answer"})
|
552
|
+
CF::FormField.new({:form => i, :label => "Email", :field_type => "email", :required => "true"})
|
526
553
|
end
|
527
554
|
end
|
528
|
-
output_format = CF::OutputFormat.new({:station_1 => [{:name => "First Name"}],:station_2 => [{:name => "Mobile", :except => true}]})
|
529
|
-
line.output_formats output_format
|
530
|
-
line.title.should eq("line_with_output_format_1")
|
531
|
-
line.input_formats.first.name.should eql("Company")
|
532
|
-
line.stations.first.type.should eq("WorkStation")
|
533
|
-
line.stations.first.worker.number.should eq(1)
|
534
|
-
line.stations.first.worker.reward.should eq(10)
|
535
|
-
line.output_formats.settings.should eql({:station_1 => [{:name => "First Name"}],:station_2 => [{:name => "Mobile", :except => true}]})
|
536
555
|
end
|
556
|
+
output_format = CF::OutputFormat.new({:station_1 => [{:name => "First Name"}],:station_2 => [{:name => "Mobile", :except => true}]})
|
557
|
+
line.output_formats output_format
|
558
|
+
line.title.should eq(title)
|
559
|
+
line.input_formats.first.name.should eql("Company")
|
560
|
+
line.stations.first.type.should eq("WorkStation")
|
561
|
+
line.stations.first.worker.number.should eq(1)
|
562
|
+
line.stations.first.worker.reward.should eq(10)
|
563
|
+
line.output_formats.settings.should eql({:station_1 => [{:name => "First Name"}],:station_2 => [{:name => "Mobile", :except => true}]})
|
537
564
|
end
|
538
|
-
|
565
|
+
|
539
566
|
it "should through error if line is incomplete" do
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
end
|
549
|
-
CF::OutputFormat.new({:line => l, :station_1 => [{:name => "First Name"}],:station_2 => [{:name => "Mobile", :except => true}]})
|
567
|
+
WebMock.allow_net_connect!
|
568
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
569
|
+
sleep 1
|
570
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
571
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
|
572
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
573
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
574
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
|
550
575
|
end
|
551
|
-
line
|
552
|
-
line.input_formats.first.name.should eql("Company")
|
553
|
-
line.stations.first.type.should eq("WorkStation")
|
554
|
-
line.stations.first.worker.number.should eq(1)
|
555
|
-
line.stations.first.worker.reward.should eq(10)
|
556
|
-
line.output_formats.errors.should eql("Line is not complete or valid")
|
576
|
+
CF::OutputFormat.new({:line => l, :station_1 => [{:name => "First Name"}],:station_2 => [{:name => "Mobile", :except => true}]})
|
557
577
|
end
|
578
|
+
line.title.should eq(title)
|
579
|
+
line.input_formats.first.name.should eql("Company")
|
580
|
+
line.stations.first.type.should eq("WorkStation")
|
581
|
+
line.stations.first.worker.number.should eq(1)
|
582
|
+
line.stations.first.worker.reward.should eq(10)
|
583
|
+
line.output_formats.errors.should eql("Line is not complete or valid")
|
558
584
|
end
|
559
585
|
end
|
560
586
|
end
|