cloudfactory 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +5 -0
- data/lib/cf/account.rb +3 -6
- data/lib/cf/cli.rb +8 -12
- data/lib/cf/cli/line.rb +13 -13
- data/lib/cf/cli/production.rb +18 -14
- data/lib/cf/client.rb +2 -12
- data/lib/cf/custom_task_form.rb +1 -3
- data/lib/cf/input_format.rb +1 -3
- data/lib/cf/line.rb +63 -66
- data/lib/cf/robot_worker.rb +3 -5
- data/lib/cf/run.rb +21 -58
- data/lib/cf/station.rb +6 -10
- data/lib/cf/task_form.rb +1 -3
- data/lib/cf/version.rb +1 -1
- data/spec/account_spec.rb +3 -5
- data/spec/badge_spec.rb +64 -64
- data/spec/concept_tagging_robot_spec.rb +37 -37
- data/spec/config_spec.rb +0 -1
- data/spec/content_scraping_robot_spec.rb +38 -38
- data/spec/custom_task_form_spec.rb +106 -105
- data/spec/department_spec.rb +5 -6
- data/spec/entity_extraction_robot_spec.rb +39 -39
- data/spec/form_field_spec.rb +148 -148
- data/spec/google_translate_robot_spec.rb +40 -40
- data/spec/human_worker_spec.rb +87 -87
- data/spec/image_processing_robot_spec.rb +37 -37
- data/spec/input_format_spec.rb +97 -97
- data/spec/keyword_matching_and_text_extraction_robot_spec.rb +56 -56
- data/spec/line_spec.rb +442 -416
- data/spec/mailer_robot_spec.rb +39 -39
- data/spec/media_converter_robot_spec.rb +40 -46
- data/spec/media_splitting_robot_spec.rb +41 -41
- data/spec/robot_worker_spec.rb +8 -8
- data/spec/run_spec.rb +424 -432
- data/spec/sentiment_robot_spec.rb +37 -37
- data/spec/station_spec.rb +209 -207
- data/spec/task_form_spec.rb +79 -79
- data/spec/term_extraction_robot_spec.rb +37 -37
- metadata +48 -48
@@ -5,51 +5,51 @@ module CF
|
|
5
5
|
describe CF::RobotWorker do
|
6
6
|
context "create a sentiment robot worker" do
|
7
7
|
it "should create content_scraping_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, :settings => {:document => ["{{url}}"], :sanitize => true}, :type => "sentiment_robot"})
|
15
15
|
end
|
16
|
-
run = CF::Run.create(line, "sentiment_robot_run", [{"url"=> "http://www.thehappyguy.com/happiness-self-help-book.html"}])
|
17
|
-
# sleep 20
|
18
|
-
output = run.final_output
|
19
|
-
output.first['sentiment_of_url'].should eql("positive")
|
20
|
-
output.first['sentiment_relevance_of_url'].should eql(24.0408)
|
21
|
-
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
22
|
-
line.stations.first.worker.reward.should eql(0.5)
|
23
|
-
line.stations.first.worker.number.should eql(1)
|
24
|
-
line.stations.first.worker.settings.should eql({:document => ["{{url}}"], :sanitize => true})
|
25
|
-
line.stations.first.worker.type.should eql("SentimentRobot")
|
26
16
|
end
|
17
|
+
run = CF::Run.create(line, "run-#{title}", [{"url"=> "http://www.thehappyguy.com/happiness-self-help-book.html"}])
|
18
|
+
sleep 10
|
19
|
+
output = run.final_output
|
20
|
+
output.first['sentiment_of_url'].should eql("positive")
|
21
|
+
output.first['sentiment_relevance_of_url'].should eql(25.7649)
|
22
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
23
|
+
line.stations.first.worker.reward.should eql(0.5)
|
24
|
+
line.stations.first.worker.number.should eql(1)
|
25
|
+
line.stations.first.worker.settings.should eql({:document => ["{{url}}"], :sanitize => true})
|
26
|
+
line.stations.first.worker.type.should eql("SentimentRobot")
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should create content_scraping_robot worker for first station in 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.new({:settings => {:document => ["{{url}}"], :sanitize => true}, :type => "sentiment_robot"})
|
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, "run-#{title}", [{"url"=> "http://www.thehappyguy.com/happiness-self-help-book.html"}])
|
44
|
+
sleep 10
|
45
|
+
output = run.final_output
|
46
|
+
output.first['sentiment_of_url'].should eql("positive")
|
47
|
+
output.first['sentiment_relevance_of_url'].should eql(25.7649)
|
48
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
49
|
+
line.stations.first.worker.reward.should eql(0.5)
|
50
|
+
line.stations.first.worker.number.should eql(1)
|
51
|
+
line.stations.first.worker.settings.should eql({:document => ["{{url}}"], :sanitize => true})
|
52
|
+
line.stations.first.worker.type.should eql("SentimentRobot")
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
data/spec/station_spec.rb
CHANGED
@@ -3,284 +3,286 @@ require 'spec_helper'
|
|
3
3
|
describe CF::Station do
|
4
4
|
context "create a station" do
|
5
5
|
it "the plain ruby way" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
+
CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
|
11
|
+
station = CF::Station.new({:type => "work"})
|
12
|
+
line.stations station
|
13
|
+
line.stations.first.type.should eql("WorkStation")
|
14
14
|
end
|
15
15
|
|
16
16
|
it "using the block variable" do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
21
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
22
|
+
CF::Station.create({:line => self, :type => "work"}) do |s|
|
23
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
24
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
25
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
26
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
27
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
28
28
|
end
|
29
29
|
end
|
30
|
-
line.stations.first.type.should eq("WorkStation")
|
31
|
-
line.stations.first.worker.number.should eql(1)
|
32
|
-
line.stations.first.worker.reward.should eql(20)
|
33
|
-
line.stations.first.form.title.should eq("Enter text from a business card image")
|
34
|
-
line.stations.first.form.instruction.should eq("Describe")
|
35
|
-
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
36
|
-
line.stations.first.form.form_fields[1].label.should eq("Middle Name")
|
37
|
-
line.stations.first.form.form_fields[2].label.should eq("Last Name")
|
38
30
|
end
|
31
|
+
line.stations.first.type.should eq("WorkStation")
|
32
|
+
line.stations.first.worker.number.should eql(1)
|
33
|
+
line.stations.first.worker.reward.should eql(20)
|
34
|
+
line.stations.first.form.title.should eq("Enter text from a business card image")
|
35
|
+
line.stations.first.form.instruction.should eq("Describe")
|
36
|
+
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
37
|
+
line.stations.first.form.form_fields[1].label.should eq("Middle Name")
|
38
|
+
line.stations.first.form.form_fields[2].label.should eq("Last Name")
|
39
39
|
end
|
40
40
|
|
41
41
|
it "using without the block variable also creating instruction without block variable" do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
42
|
+
WebMock.allow_net_connect!
|
43
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
44
|
+
sleep 1
|
45
|
+
line = CF::Line.create(title, "Digitization") do
|
46
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
47
|
+
CF::Station.create({:line => self, :type => "work"}) do
|
48
|
+
CF::HumanWorker.new({:station => self, :number => 1, :reward => 20})
|
49
|
+
CF::TaskForm.create({:station => self, :title => "Enter text from a business card image", :instruction => "Describe"}) do
|
50
|
+
CF::FormField.new({:form => self, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
51
|
+
CF::FormField.new({:form => self, :label => "Middle Name", :field_type => "short_answer"})
|
52
|
+
CF::FormField.new({:form => self, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
53
53
|
end
|
54
54
|
end
|
55
|
-
line.stations.first.type.should eq("WorkStation")
|
56
|
-
line.stations.first.worker.number.should eql(1)
|
57
|
-
line.stations.first.worker.reward.should eql(20)
|
58
|
-
line.stations.first.form.title.should eq("Enter text from a business card image")
|
59
|
-
line.stations.first.form.instruction.should eq("Describe")
|
60
|
-
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
61
|
-
line.stations.first.form.form_fields[1].label.should eq("Middle Name")
|
62
|
-
line.stations.first.form.form_fields[2].label.should eq("Last Name")
|
63
55
|
end
|
56
|
+
line.stations.first.type.should eq("WorkStation")
|
57
|
+
line.stations.first.worker.number.should eql(1)
|
58
|
+
line.stations.first.worker.reward.should eql(20)
|
59
|
+
line.stations.first.form.title.should eq("Enter text from a business card image")
|
60
|
+
line.stations.first.form.instruction.should eq("Describe")
|
61
|
+
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
62
|
+
line.stations.first.form.form_fields[1].label.should eq("Middle Name")
|
63
|
+
line.stations.first.form.form_fields[2].label.should eq("Last Name")
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should create a station of Tournament station" do
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
67
|
+
WebMock.allow_net_connect!
|
68
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
69
|
+
sleep 1
|
70
|
+
line = CF::Line.create(title, "Digitization") do
|
71
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
72
|
+
CF::Station.create({:line => self, :type => "tournament", :jury_worker=> {:max_judges => 10, :reward => 5}, :auto_judge => {:enabled => true}}) do |s|
|
73
|
+
CF::HumanWorker.new({:station => s, :number => 3, :reward => 20})
|
74
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
75
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
76
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
77
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
78
78
|
end
|
79
79
|
end
|
80
|
-
line.stations.first.type.should eq("TournamentStation")
|
81
|
-
line.stations.first.jury_worker.should eql({"max_judges"=>10, "confidence_level"=>0.65, "tournament_restarts"=>0, "number"=>2})
|
82
|
-
line.stations.first.auto_judge.should eql({"enabled"=>true, "finalize_percentage"=>51})
|
83
|
-
line.stations.first.worker.number.should eql(3)
|
84
|
-
line.stations.first.worker.reward.should eql(20)
|
85
|
-
line.stations.first.form.title.should eq("Enter text from a business card image")
|
86
|
-
line.stations.first.form.instruction.should eq("Describe")
|
87
|
-
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
88
|
-
line.stations.first.form.form_fields[1].label.should eq("Middle Name")
|
89
|
-
line.stations.first.form.form_fields[2].label.should eq("Last Name")
|
90
80
|
end
|
81
|
+
line.stations.first.type.should eq("TournamentStation")
|
82
|
+
line.stations.first.jury_worker.should eql({"max_judges"=>10, "confidence_level"=>0.65, "tournament_restarts"=>0, "number"=>2})
|
83
|
+
line.stations.first.auto_judge.should eql({"enabled"=>true, "finalize_percentage"=>51})
|
84
|
+
line.stations.first.worker.number.should eql(3)
|
85
|
+
line.stations.first.worker.reward.should eql(20)
|
86
|
+
line.stations.first.form.title.should eq("Enter text from a business card image")
|
87
|
+
line.stations.first.form.instruction.should eq("Describe")
|
88
|
+
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
89
|
+
line.stations.first.form.form_fields[1].label.should eq("Middle Name")
|
90
|
+
line.stations.first.form.form_fields[2].label.should eq("Last Name")
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should create a station of Improve station as first station of line" do
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
94
|
+
WebMock.allow_net_connect!
|
95
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
96
|
+
sleep 1
|
97
|
+
line = CF::Line.new(title, "Digitization")
|
98
|
+
CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
|
99
|
+
station = CF::Station.new({:type => "improve"})
|
100
|
+
expect { line.stations station }.to raise_error(CF::ImproveStationNotAllowed)
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
it "should only display the attributes which are mentioned in to_s method" do
|
104
|
-
|
105
|
-
#
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
104
|
+
WebMock.allow_net_connect!
|
105
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
106
|
+
sleep 1
|
107
|
+
line = CF::Line.create(title, "Digitization") do
|
108
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
109
|
+
CF::Station.create({:line => self, :type => "work"}) do |station|
|
110
|
+
CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
|
111
111
|
end
|
112
|
-
line.stations.first.to_s.should eql("{:type => WorkStation, :index => 1, :line_title => Display_station, :station_input_formats => , :errors => }")
|
113
112
|
end
|
113
|
+
line.stations.first.to_s.should eql("{:type => WorkStation, :index => 1, :line_title => #{title}, :station_input_formats => , :errors => }")
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
it "should only display the attributes which are mentioned in to_s method for tournament station" do
|
117
|
-
|
118
|
-
#
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
117
|
+
WebMock.allow_net_connect!
|
118
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
119
|
+
sleep 1
|
120
|
+
line = CF::Line.create(title, "Digitization") do
|
121
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
122
|
+
CF::Station.create({:line => self, :type => "tournament", :jury_worker=> {:max_judges => 10, :reward => 5}, :auto_judge => {:enabled => true}}) do |s|
|
123
|
+
CF::HumanWorker.new({:station => s, :number => 2, :reward => 20})
|
124
124
|
end
|
125
|
-
line.stations.first.to_s.should eql("{:type => TournamentStation, :index => 1, :line_title => Display_station_tournament, :station_input_formats => , :jury_worker => {\"max_judges\"=>10, \"confidence_level\"=>0.65, \"tournament_restarts\"=>0, \"number\"=>2}, auto_judge => {\"enabled\"=>true, \"finalize_percentage\"=>51}, :errors => }")
|
126
125
|
end
|
126
|
+
line.stations.first.to_s.should eql("{:type => TournamentStation, :index => 1, :line_title => #{title}, :station_input_formats => , :jury_worker => {\"max_judges\"=>10, \"confidence_level\"=>0.65, \"tournament_restarts\"=>0, \"number\"=>2}, auto_judge => {\"enabled\"=>true, \"finalize_percentage\"=>51}, :errors => }")
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
context "get station" do
|
131
131
|
it "should get information about a single station" do
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
132
|
+
WebMock.allow_net_connect!
|
133
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
134
|
+
sleep 1
|
135
|
+
line = CF::Line.new(title,"Digitization")
|
136
|
+
line.title.should eq(title)
|
137
|
+
CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
|
138
|
+
station = CF::Station.new(:type => "Work")
|
139
|
+
line.stations station
|
140
|
+
station.type.should eq("Work")
|
141
|
+
line.stations.first.get['type'].should eq("WorkStation")
|
142
142
|
end
|
143
143
|
|
144
144
|
it "should get all existing stations of a line" do
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
145
|
+
WebMock.allow_net_connect!
|
146
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
147
|
+
sleep 1
|
148
|
+
line = CF::Line.new(title,"Digitization")
|
149
|
+
line.title.should eq(title)
|
150
|
+
CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
|
151
|
+
station = CF::Station.new(:type => "Work")
|
152
|
+
line.stations station
|
153
|
+
stations = CF::Station.all(line)
|
154
|
+
stations.map {|s| s['type']}.join(",").should eq("WorkStation")
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
158
|
context "create multiple station" do
|
159
159
|
it "should create two stations using different input format" do
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
160
|
+
WebMock.allow_net_connect!
|
161
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
162
|
+
sleep 1
|
163
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
164
|
+
CF::InputFormat.new({:line => l, :name => "Company", :required => true})
|
165
|
+
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
166
|
+
CF::Station.create({:line => l, :type => "work", :input_formats=> {:station_0 => [{:name => "Company"},{:name => "Website", :except => true}]}}) do |s|
|
167
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
168
|
+
CF::TaskForm.create({:station => s, :title => "Enter the name of CEO", :instruction => "Describe"}) do |i|
|
169
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
170
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
171
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
172
172
|
end
|
173
173
|
end
|
174
|
+
end
|
174
175
|
|
175
|
-
|
176
|
-
|
177
|
-
|
176
|
+
station = CF::Station.new(
|
177
|
+
{:type => "work", :input_formats => {:station_0 => [{:name => "Website"}], :station_1 => [{:name => "Last Name", :except => true}]}})
|
178
|
+
line.stations station
|
178
179
|
|
179
|
-
|
180
|
-
|
180
|
+
worker = CF::HumanWorker.new({:number => 1, :reward => 10})
|
181
|
+
line.stations.last.worker = worker
|
181
182
|
|
182
|
-
|
183
|
-
|
183
|
+
form = CF::TaskForm.new({:title => "Enter the address of the given Person", :instruction => "Description"})
|
184
|
+
line.stations.last.form = form
|
184
185
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
186
|
+
form_fields_1 = CF::FormField.new({:label => "Street", :field_type => "short_answer", :required => "true"})
|
187
|
+
line.stations.last.form.form_fields form_fields_1
|
188
|
+
form_fields_2 = CF::FormField.new({:label => "City", :field_type => "short_answer", :required => "true"})
|
189
|
+
line.stations.last.form.form_fields form_fields_2
|
190
|
+
form_fields_3 = CF::FormField.new({:label => "Country", :field_type => "short_answer", :required => "true"})
|
191
|
+
line.stations.last.form.form_fields form_fields_3
|
192
|
+
station_1 = line.stations.first.get
|
193
|
+
station_1['input_formats'].count.should eql(1)
|
194
|
+
station_1['input_formats'].first['name'].should eql("Company")
|
195
|
+
station_1['input_formats'].first['required'].should eql(true)
|
196
|
+
station_2 = line.stations.last.get
|
197
|
+
station_2['input_formats'].count.should eql(3)
|
198
|
+
names = station_2['input_formats'].map {|i| i['name']}.join(",")
|
199
|
+
required_states = station_2['input_formats'].map {|i| i['required']}.join(",")
|
200
|
+
names.should include("Website")
|
201
|
+
names.should include("First Name")
|
202
|
+
names.should include("Middle Name")
|
203
|
+
required_states.should include("true")
|
204
|
+
required_states.should include("false") #how to make it true
|
205
|
+
required_states.should include("false")
|
206
|
+
station_2['input_formats'].map {|i| i['valid_type']}.join(",").should include("url")
|
205
207
|
end
|
206
208
|
end
|
207
209
|
|
208
210
|
context "create a station with errors" do
|
209
211
|
it "in plain ruby way and it should display an error message" do
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
212
|
+
WebMock.allow_net_connect!
|
213
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
214
|
+
sleep 1
|
215
|
+
line = CF::Line.new(title, "Digitization")
|
216
|
+
station = CF::Station.new()
|
217
|
+
line.stations station
|
218
|
+
line.stations.first.errors.should eql("The Station type is invalid.")
|
217
219
|
end
|
218
|
-
|
220
|
+
|
219
221
|
it "in block DSL way and it should display an error message" do
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
line.stations.first.errors.should eql("The Station type is invalid.")
|
222
|
+
WebMock.allow_net_connect!
|
223
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
224
|
+
sleep 1
|
225
|
+
line = CF::Line.create(title, "Digitization") do |l|
|
226
|
+
CF::Station.new({:line => l})
|
226
227
|
end
|
228
|
+
line.stations.first.errors.should eql("The Station type is invalid.")
|
227
229
|
end
|
228
|
-
|
230
|
+
|
229
231
|
it "in block DSL way without creating input_format it should display an error message" do
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
line.stations.first.errors.should eql("Input formats not assigned for the line #{line.title.downcase}")
|
232
|
+
WebMock.allow_net_connect!
|
233
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
234
|
+
sleep 1
|
235
|
+
line = CF::Line.create(title, "Digitization") do |l|
|
236
|
+
CF::Station.new({:line => l, :type => "work"})
|
236
237
|
end
|
238
|
+
line.stations.first.errors.should eql("Input formats not assigned for the line #{line.title.downcase}")
|
237
239
|
end
|
238
|
-
|
240
|
+
|
239
241
|
it "Tournament station displaying errors due to invalid settings" do
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
line.stations.first.type.should eq("Tournament")
|
247
|
-
line.stations.first.errors.should eql("[\"Jury worker can't be blank\"]")
|
242
|
+
WebMock.allow_net_connect!
|
243
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
244
|
+
sleep 1
|
245
|
+
line = CF::Line.create(title, "Digitization") do
|
246
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
247
|
+
CF::Station.new({:line => self, :type => "tournament"})
|
248
248
|
end
|
249
|
+
line.stations.first.type.should eq("Tournament")
|
250
|
+
line.stations.first.errors.should eql("[\"Jury worker can't be blank\"]")
|
249
251
|
end
|
250
252
|
end
|
251
|
-
|
253
|
+
|
252
254
|
context "create station with batch size option" do
|
253
255
|
it "for work station in block DSL way" do
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
256
|
+
WebMock.allow_net_connect!
|
257
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
258
|
+
sleep 1
|
259
|
+
line = CF::Line.create(title, "Digitization") do
|
260
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
261
|
+
CF::Station.create({:line => self, :type => "work", :batch_size => 3}) do |s|
|
262
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
263
|
+
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
264
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
265
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
266
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
265
267
|
end
|
266
268
|
end
|
267
|
-
line.stations.first.type.should eql("WorkStation")
|
268
|
-
line.stations.first.batch_size.should eql(3)
|
269
|
-
line.stations.first.worker.number.should eql(1)
|
270
|
-
line.stations.first.worker.reward.should eql(20)
|
271
269
|
end
|
270
|
+
line.stations.first.type.should eql("WorkStation")
|
271
|
+
line.stations.first.batch_size.should eql(3)
|
272
|
+
line.stations.first.worker.number.should eql(1)
|
273
|
+
line.stations.first.worker.reward.should eql(20)
|
272
274
|
end
|
273
|
-
|
275
|
+
|
274
276
|
it "for work station in Plain Ruby way" do
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
277
|
+
WebMock.allow_net_connect!
|
278
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
279
|
+
sleep 1
|
280
|
+
line = CF::Line.new(title, "Digitization")
|
281
|
+
CF::InputFormat.new({:line => line, :name => "image_url", :required => true, :valid_type => "url"})
|
282
|
+
station = CF::Station.new({:type => "work", :batch_size => 3})
|
283
|
+
line.stations station
|
284
|
+
line.stations.first.type.should eql("WorkStation")
|
285
|
+
line.stations.first.batch_size.should eql(3)
|
284
286
|
end
|
285
287
|
end
|
286
288
|
end
|