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
data/spec/form_field_spec.rb
CHANGED
@@ -3,176 +3,176 @@ require 'spec_helper'
|
|
3
3
|
describe CF::FormField do
|
4
4
|
context "create an form_field" do
|
5
5
|
it "the plain ruby way" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
+
|
11
|
+
input_format = CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"})
|
12
|
+
line.input_formats input_format
|
13
|
+
|
14
|
+
station = CF::Station.new({:type => "work"})
|
15
|
+
line.stations station
|
16
|
+
|
17
|
+
worker = CF::HumanWorker.new({:number => 1, :reward => 20})
|
18
|
+
line.stations.first.worker = worker
|
19
|
+
|
20
|
+
form = CF::TaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe"})
|
21
|
+
line.stations.first.form = form
|
22
|
+
|
23
|
+
form_fields_1 = CF::FormField.new({:label => "First Name", :field_type => "short_answer", :required => "true"})
|
24
|
+
line.stations.first.form.form_fields form_fields_1
|
25
|
+
form_fields_2 = CF::FormField.new({:label => "Middle Name", :field_type => "short_answer"})
|
26
|
+
line.stations.first.form.form_fields form_fields_2
|
27
|
+
form_fields_3 = CF::FormField.new({:label => "Last Name", :field_type => "short_answer", :required => "true"})
|
28
|
+
line.stations.first.form.form_fields form_fields_3
|
29
|
+
form_fields_3 = CF::FormField.new({:label => "Gender", :field_type => "radio_button", :required => "true", :option_values => ["male","female"]})
|
30
|
+
line.stations.first.form.form_fields form_fields_3
|
31
|
+
|
32
|
+
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
33
|
+
line.stations.first.form.form_fields[0].field_type.should eq("short_answer")
|
34
|
+
line.stations.first.form.form_fields[0].required.should eq(true)
|
35
|
+
line.stations.first.form.form_fields[0].form_field_params.should eql({:label => "First Name", :field_type => "short_answer", :required => "true"})
|
36
|
+
line.stations.first.form.form_fields[1].label.should eq("Middle Name")
|
37
|
+
line.stations.first.form.form_fields[1].field_type.should eq("short_answer")
|
38
|
+
line.stations.first.form.form_fields[1].form_field_params.should eql({:label => "Middle Name", :field_type => "short_answer"})
|
39
|
+
line.stations.first.form.form_fields[2].label.should eq("Last Name")
|
40
|
+
line.stations.first.form.form_fields[2].field_type.should eq("short_answer")
|
41
|
+
line.stations.first.form.form_fields[2].required.should eq(true)
|
42
|
+
line.stations.first.form.form_fields[2].form_field_params.should eql({:label => "Last Name", :field_type => "short_answer", :required => "true"})
|
43
|
+
line.stations.first.form.form_fields[3].label.should eq("Gender")
|
44
|
+
line.stations.first.form.form_fields[3].field_type.should eq("radio_button")
|
45
|
+
line.stations.first.form.form_fields[3].required.should eq(true)
|
46
|
+
line.stations.first.form.form_fields[3].form_field_params.should eql({:label => "Gender", :field_type => "radio_button", :required => "true", :option_values => ["male","female"]})
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
it "in block DSL way" do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
WebMock.allow_net_connect!
|
51
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
52
|
+
sleep 1
|
53
|
+
line = CF::Line.create(title, "Digitization") do
|
54
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
55
|
+
CF::Station.create({:line => self, :type => "work"}) do |station|
|
56
|
+
CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
|
57
|
+
CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
58
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
59
|
+
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
60
|
+
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
61
|
+
CF::FormField.new({:form => i, :label => "Gender", :field_type => "radio_button", :required => "true", :option_values => ["male","female"]})
|
62
62
|
end
|
63
63
|
end
|
64
|
-
line.title.should eq("Digitize-0101111-final")
|
65
|
-
line.department_name.should eq("Digitization")
|
66
|
-
line.input_formats.first.name.should eql("image_url")
|
67
|
-
line.stations.first.type.should eq("WorkStation")
|
68
|
-
line.stations.first.worker.number.should eq(1)
|
69
|
-
line.stations.first.form.instruction.should eq("Describe")
|
70
|
-
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
71
|
-
line.stations.first.form.form_fields[0].field_type.should eq("short_answer")
|
72
|
-
line.stations.first.form.form_fields[0].required.should eq(true)
|
73
|
-
line.stations.first.form.form_fields[0].form_field_params.should eql({:label => "First Name", :field_type => "short_answer", :required => "true"})
|
74
|
-
line.stations.first.form.form_fields[1].label.should eq("Middle Name")
|
75
|
-
line.stations.first.form.form_fields[1].field_type.should eq("short_answer")
|
76
|
-
line.stations.first.form.form_fields[1].form_field_params.should eql({:label => "Middle Name", :field_type => "short_answer"})
|
77
|
-
line.stations.first.form.form_fields[2].label.should eq("Last Name")
|
78
|
-
line.stations.first.form.form_fields[2].field_type.should eq("short_answer")
|
79
|
-
line.stations.first.form.form_fields[2].required.should eq(true)
|
80
|
-
line.stations.first.form.form_fields[2].form_field_params.should eql({:label => "Last Name", :field_type => "short_answer", :required => "true"})
|
81
|
-
line.stations.first.form.form_fields[3].label.should eq("Gender")
|
82
|
-
line.stations.first.form.form_fields[3].field_type.should eq("radio_button")
|
83
|
-
line.stations.first.form.form_fields[3].required.should eq(true)
|
84
|
-
line.stations.first.form.form_fields[3].form_field_params.should eql({:label => "Gender", :field_type => "radio_button", :required => "true", :option_values => ["male","female"]})
|
85
64
|
end
|
65
|
+
line.title.should eq(title)
|
66
|
+
line.department_name.should eq("Digitization")
|
67
|
+
line.input_formats.first.name.should eql("image_url")
|
68
|
+
line.stations.first.type.should eq("WorkStation")
|
69
|
+
line.stations.first.worker.number.should eq(1)
|
70
|
+
line.stations.first.form.instruction.should eq("Describe")
|
71
|
+
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
72
|
+
line.stations.first.form.form_fields[0].field_type.should eq("short_answer")
|
73
|
+
line.stations.first.form.form_fields[0].required.should eq(true)
|
74
|
+
line.stations.first.form.form_fields[0].form_field_params.should eql({:label => "First Name", :field_type => "short_answer", :required => "true"})
|
75
|
+
line.stations.first.form.form_fields[1].label.should eq("Middle Name")
|
76
|
+
line.stations.first.form.form_fields[1].field_type.should eq("short_answer")
|
77
|
+
line.stations.first.form.form_fields[1].form_field_params.should eql({:label => "Middle Name", :field_type => "short_answer"})
|
78
|
+
line.stations.first.form.form_fields[2].label.should eq("Last Name")
|
79
|
+
line.stations.first.form.form_fields[2].field_type.should eq("short_answer")
|
80
|
+
line.stations.first.form.form_fields[2].required.should eq(true)
|
81
|
+
line.stations.first.form.form_fields[2].form_field_params.should eql({:label => "Last Name", :field_type => "short_answer", :required => "true"})
|
82
|
+
line.stations.first.form.form_fields[3].label.should eq("Gender")
|
83
|
+
line.stations.first.form.form_fields[3].field_type.should eq("radio_button")
|
84
|
+
line.stations.first.form.form_fields[3].required.should eq(true)
|
85
|
+
line.stations.first.form.form_fields[3].form_field_params.should eql({:label => "Gender", :field_type => "radio_button", :required => "true", :option_values => ["male","female"]})
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
it "in block DSL way without valid_type and some with valid_type" do
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
89
|
+
WebMock.allow_net_connect!
|
90
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
91
|
+
sleep 1
|
92
|
+
line = CF::Line.create(title, "Digitization") do
|
93
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
94
|
+
CF::Station.create({:line => self, :type => "work"}) do |station|
|
95
|
+
CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
|
96
|
+
CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
97
|
+
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
98
|
+
CF::FormField.new({:form => i, :label => "email", :field_type => "short_answer", :valid_type => "email", :required => "true"})
|
99
99
|
end
|
100
100
|
end
|
101
|
-
line.title.should eq("form_fields_valid_type")
|
102
|
-
line.department_name.should eq("Digitization")
|
103
|
-
line.input_formats.first.name.should eql("image_url")
|
104
|
-
line.stations.first.type.should eq("WorkStation")
|
105
|
-
line.stations.first.worker.number.should eq(1)
|
106
|
-
line.stations.first.form.instruction.should eq("Describe")
|
107
|
-
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
108
|
-
line.stations.first.form.form_fields[0].field_type.should eq("short_answer")
|
109
|
-
line.stations.first.form.form_fields[0].required.should eq(true)
|
110
|
-
line.stations.first.form.form_fields[0].form_field_params.should eql({:label => "First Name", :field_type => "short_answer", :required => "true"})
|
111
|
-
line.stations.first.form.form_fields[1].label.should eq("email")
|
112
|
-
line.stations.first.form.form_fields[1].field_type.should eq("short_answer")
|
113
|
-
line.stations.first.form.form_fields[1].required.should eq(true)
|
114
|
-
line.stations.first.form.form_fields[1].valid_type.should eq("email")
|
115
|
-
line.stations.first.form.form_fields[1].form_field_params.should eql({:label => "email", :field_type => "short_answer", :valid_type => "email", :required => "true"})
|
116
101
|
end
|
102
|
+
line.title.should eq(title)
|
103
|
+
line.department_name.should eq("Digitization")
|
104
|
+
line.input_formats.first.name.should eql("image_url")
|
105
|
+
line.stations.first.type.should eq("WorkStation")
|
106
|
+
line.stations.first.worker.number.should eq(1)
|
107
|
+
line.stations.first.form.instruction.should eq("Describe")
|
108
|
+
line.stations.first.form.form_fields[0].label.should eq("First Name")
|
109
|
+
line.stations.first.form.form_fields[0].field_type.should eq("short_answer")
|
110
|
+
line.stations.first.form.form_fields[0].required.should eq(true)
|
111
|
+
line.stations.first.form.form_fields[0].form_field_params.should eql({:label => "First Name", :field_type => "short_answer", :required => "true"})
|
112
|
+
line.stations.first.form.form_fields[1].label.should eq("email")
|
113
|
+
line.stations.first.form.form_fields[1].field_type.should eq("short_answer")
|
114
|
+
line.stations.first.form.form_fields[1].required.should eq(true)
|
115
|
+
line.stations.first.form.form_fields[1].valid_type.should eq("email")
|
116
|
+
line.stations.first.form.form_fields[1].form_field_params.should eql({:label => "email", :field_type => "short_answer", :valid_type => "email", :required => "true"})
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
it "in block DSL way with invalid form_field data" do
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
120
|
+
WebMock.allow_net_connect!
|
121
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
122
|
+
sleep 1
|
123
|
+
line = CF::Line.create(title, "Digitization") do
|
124
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
125
|
+
CF::Station.create({:line => self, :type => "work"}) do |station|
|
126
|
+
CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
|
127
|
+
CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
128
|
+
CF::FormField.new({:form => i, :field_type => "short_answer", :required => "true"})
|
129
129
|
end
|
130
130
|
end
|
131
|
-
line.stations.first.type.should eql("WorkStation")
|
132
|
-
line.stations.first.form.form_fields.first.errors.should eql(["Label can't be blank"])
|
133
131
|
end
|
132
|
+
line.stations.first.type.should eql("WorkStation")
|
133
|
+
line.stations.first.form.form_fields.first.errors.should eql(["Label can't be blank"])
|
134
134
|
end
|
135
|
-
|
135
|
+
|
136
136
|
it "in plain Ruby way with invalid form_field data" do
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
137
|
+
WebMock.allow_net_connect!
|
138
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
139
|
+
sleep 1
|
140
|
+
line = CF::Line.new(title, "Digitization")
|
141
|
+
input_format = CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"})
|
142
|
+
line.input_formats input_format
|
143
|
+
|
144
|
+
station = CF::Station.new({:type => "work"})
|
145
|
+
line.stations station
|
146
|
+
|
147
|
+
worker = CF::HumanWorker.new({:number => 1, :reward => 20})
|
148
|
+
line.stations.first.worker = worker
|
149
|
+
|
150
|
+
form = CF::TaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe"})
|
151
|
+
line.stations.first.form = form
|
152
|
+
|
153
|
+
form_fields_1 = CF::FormField.new({:field_type => "short_answer", :required => "true"})
|
154
|
+
line.stations.first.form.form_fields form_fields_1
|
155
|
+
|
156
|
+
line.stations.first.type.should eql("WorkStation")
|
157
|
+
line.stations.first.form.form_fields.first.errors.should eql(["Label can't be blank"])
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
it "should only display the attributes which are mentioned in to_s method" do
|
161
|
-
|
162
|
-
#
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
161
|
+
WebMock.allow_net_connect!
|
162
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
163
|
+
sleep 1
|
164
|
+
line = CF::Line.create(title, "Digitization") do
|
165
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
166
|
+
CF::Station.create({:line => self, :type => "work"}) do |station|
|
167
|
+
CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
|
168
|
+
CF::TaskForm.create({:station => station, :title => "Enter text from a business card image", :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
|
-
line.stations.first.form.form_fields.first.to_s.should eql("{:id => => #{line.stations.first.form.form_fields.first.id}, :label => First Name, :field_type => short_answer, :required => true, :errors => }")
|
175
174
|
end
|
175
|
+
line.stations.first.form.form_fields.first.to_s.should eql("{:id => => #{line.stations.first.form.form_fields.first.id}, :label => First Name, :field_type => short_answer, :required => true, :errors => }")
|
176
176
|
end
|
177
177
|
end
|
178
178
|
end
|
@@ -5,54 +5,54 @@ module CF
|
|
5
5
|
describe CF::RobotWorker do
|
6
6
|
context "create a google translator worker" do
|
7
7
|
it "should create google_translate_robot worker for first station in a plain ruby way" do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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")
|
12
|
+
input_format = CF::InputFormat.new({:name => "text", :required => true})
|
13
|
+
line.input_formats input_format
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
station = CF::Station.new({:type => "work"})
|
16
|
+
line.stations station
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
worker = CF::RobotWorker.create({:type => "google_translate_robot", :settings => {:data => ["{{text}}"], :from => "en", :to => "es"}})
|
19
|
+
line.stations.first.worker = worker
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
form = CF::TaskForm.new({:title => "Enter text", :instruction => "Describe"})
|
22
|
+
line.stations.first.form = form
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
24
|
+
line.title.should eql(title)
|
25
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
26
|
+
line.stations.first.worker.number.should eql(1)
|
27
|
+
line.stations.first.worker.settings.should eql({:data => ["{{text}}"], :from => "en", :to => "es"})
|
28
|
+
line.stations.first.worker.type.should eql("GoogleTranslateRobot")
|
29
|
+
run = CF::Run.create(line, "google_translate_robot_run", [{"text"=> "I started loving Monsoon"}])
|
30
|
+
sleep 10
|
31
|
+
@final_output = run.final_output
|
32
|
+
line.stations.first.worker.number.should eq(1)
|
33
|
+
@final_output.first['translation_of_text'].should eql('Empecé a amar a Monzón')
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it "should create google_translate_robot in block DSL way" do
|
37
|
-
|
38
|
-
#
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
WebMock.allow_net_connect!
|
38
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
39
|
+
sleep 1
|
40
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
41
|
+
CF::InputFormat.new({:line => l, :name => "text", :required => true})
|
42
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
43
|
+
CF::RobotWorker.create({:station => s, :type => "google_translate_robot", :settings => {:data => ["{{text}}"], :from => "en", :to => "es"}})
|
44
44
|
end
|
45
|
-
line.title.should eql("google_translate_robot_1")
|
46
|
-
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
47
|
-
line.stations.first.worker.number.should eql(1)
|
48
|
-
line.stations.first.worker.settings.should eql({:data => ["{{text}}"], :from => "en", :to => "es"})
|
49
|
-
line.stations.first.worker.type.should eql("GoogleTranslateRobot")
|
50
|
-
run = CF::Run.create(line, "google_translate_robot_run_1", [{"text"=> "I started loving Monsoon"}])
|
51
|
-
# sleep 20
|
52
|
-
@final_output = run.final_output
|
53
|
-
line.stations.first.worker.number.should eq(1)
|
54
|
-
@final_output.first['translation_of_text'].should eql('Empecé a amar a Monzón')
|
55
45
|
end
|
46
|
+
line.title.should eql(title)
|
47
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
48
|
+
line.stations.first.worker.number.should eql(1)
|
49
|
+
line.stations.first.worker.settings.should eql({:data => ["{{text}}"], :from => "en", :to => "es"})
|
50
|
+
line.stations.first.worker.type.should eql("GoogleTranslateRobot")
|
51
|
+
run = CF::Run.create(line, "google_translate_robot_run_1", [{"text"=> "I started loving Monsoon"}])
|
52
|
+
sleep 10
|
53
|
+
@final_output = run.final_output
|
54
|
+
line.stations.first.worker.number.should eq(1)
|
55
|
+
@final_output.first['translation_of_text'].should eql('Empecé a amar a Monzón')
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
data/spec/human_worker_spec.rb
CHANGED
@@ -4,127 +4,127 @@ module CF
|
|
4
4
|
describe CF::HumanWorker do
|
5
5
|
context "create a worker" do
|
6
6
|
it "the block DSL way" do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
WebMock.allow_net_connect!
|
8
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
9
|
+
sleep 1
|
10
|
+
line = CF::Line.create(title, "Digitization") do |l|
|
11
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
12
|
+
CF::Station.create({:line =>l, :type => "work"}) do |s|
|
13
|
+
@worker = CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
14
14
|
end
|
15
|
-
line.stations.first.type.should eql("WorkStation")
|
16
|
-
line.stations.first.worker.number.should eql(1)
|
17
|
-
line.stations.first.worker.reward.should eql(20)
|
18
15
|
end
|
16
|
+
line.stations.first.type.should eql("WorkStation")
|
17
|
+
line.stations.first.worker.number.should eql(1)
|
18
|
+
line.stations.first.worker.reward.should eql(20)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "in block DSL way with invalid data and should set the error" do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
WebMock.allow_net_connect!
|
23
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
24
|
+
sleep 1
|
25
|
+
line = CF::Line.create(title, "Digitization") do |l|
|
26
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
27
|
+
CF::Station.create({:line =>l, :type => "work"}) do |s|
|
28
|
+
@worker = CF::HumanWorker.new({:station => s})
|
29
29
|
end
|
30
|
-
line.stations.first.type.should eql("WorkStation")
|
31
|
-
line.stations.first.worker.errors.should eql("[\"Reward is not a number\", \"Reward can't be blank\"]")
|
32
30
|
end
|
31
|
+
line.stations.first.type.should eql("WorkStation")
|
32
|
+
line.stations.first.worker.errors.should eql("[\"Reward is not a number\", \"Reward can't be blank\"]")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "in plain ruby way with invalid data and should set the error" do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
WebMock.allow_net_connect!
|
37
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
38
|
+
sleep 1
|
39
|
+
line = CF::Line.new(title, "Digitization")
|
40
|
+
input_format = CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"})
|
41
|
+
line.input_formats input_format
|
41
42
|
|
42
|
-
|
43
|
-
|
43
|
+
station = CF::Station.new({:type => "work"})
|
44
|
+
line.stations station
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
worker = CF::HumanWorker.new()
|
47
|
+
line.stations.first.worker = worker
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
end
|
49
|
+
line.stations.first.type.should eql("WorkStation")
|
50
|
+
line.stations.first.worker.errors.should eql("[\"Reward is not a number\", \"Reward can't be blank\"]")
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it "should only display the attributes which are mentioned in to_s method" do
|
54
|
-
|
55
|
-
#
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
WebMock.allow_net_connect!
|
55
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
56
|
+
sleep 1
|
57
|
+
line = CF::Line.create(title, "Digitization") do
|
58
|
+
CF::InputFormat.new({:line => self, :name => "image_url", :required => true, :valid_type => "url"})
|
59
|
+
CF::Station.create({:line => self, :type => "work"}) do |station|
|
60
|
+
CF::HumanWorker.new({:station => station, :number => 1, :reward => 20})
|
61
61
|
end
|
62
|
-
line.stations.first.worker.to_s.should eql("{:id => => #{line.stations.first.worker.id}, :number => 1, :reward => 20, :stat_badge => {\"approval_rating\"=>80, \"assignment_duration\"=>3600, \"abandonment_rate\"=>30, \"country\"=>nil}, :skill_badges => [nil], :errors => }")
|
63
62
|
end
|
63
|
+
line.stations.first.worker.to_s.should eql("{:id => => #{line.stations.first.worker.id}, :number => 1, :reward => 20, :stat_badge => {\"approval_rating\"=>80, \"assignment_duration\"=>3600, \"abandonment_rate\"=>30, \"country\"=>nil}, :skill_badges => [nil], :errors => }")
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
context "create a worker with skill_badge and skill_test" do
|
68
68
|
it "the Block DSL way" do
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
WebMock.allow_net_connect!
|
70
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
71
|
+
sleep 1
|
72
|
+
badge =
|
73
|
+
{
|
74
|
+
:title => 'Football Fanatic',
|
75
|
+
:description => "This qualification allows you to perform work at stations which have this badge.",
|
76
|
+
:max_badges => 3,
|
77
|
+
:test =>
|
72
78
|
{
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:test =>
|
77
|
-
{
|
78
|
-
:input => {:name => "Lionel Andres Messi", :country => "Argentina"},
|
79
|
-
:expected_output =>
|
80
|
-
[{: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 }}]
|
81
|
-
}
|
79
|
+
:input => {:name => "Lionel Andres Messi", :country => "Argentina"},
|
80
|
+
:expected_output =>
|
81
|
+
[{: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 }}]
|
82
82
|
}
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
}
|
84
|
+
line = CF::Line.create(title, "Digitization") do |l|
|
85
|
+
CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
|
86
|
+
CF::Station.create({:line =>l, :type => "work"}) do |s|
|
87
|
+
@worker = CF::HumanWorker.new({:station => s, :number => 1, :reward => 20, :skill_badge => badge})
|
88
88
|
end
|
89
|
-
line.stations.first.type.should eql("WorkStation")
|
90
|
-
line.stations.first.worker.number.should eql(1)
|
91
|
-
line.stations.first.worker.reward.should eql(20)
|
92
|
-
line.stations.first.worker.skill_badges.first.should eql([{"title"=>"Football Fanatic", "description"=>"This qualification allows you to perform work at stations which have this badge.", "score"=>nil, "quality_rating"=>nil, "max_badges"=>3, "skill_test"=>{"score_after"=>"submit", "manual_scoring"=>false, "display_answers"=>false, "edit_answers"=>true, "retries"=>0, "pass_percentage"=>100, "test_units"=>[{"input"=>{"name"=>"Lionel Andres Messi", "country"=>"Argentina"}, "expected_output"=>[{"birthplace"=>"Rosario, Santa Fe, Argentina", "match_options"=>{"tolerance"=>"1", "ignore_case"=>"false"}, "position"=>"CF", "current-club"=>"Barcelona"}], "match_options"=>{"tolerance"=>0, "ignore_case"=>false}}]}}])
|
93
|
-
line.stations.first.worker.stat_badge.should eql({"approval_rating"=>80, "assignment_duration"=>3600, "abandonment_rate"=>30, "country"=>nil})
|
94
89
|
end
|
90
|
+
line.stations.first.type.should eql("WorkStation")
|
91
|
+
line.stations.first.worker.number.should eql(1)
|
92
|
+
line.stations.first.worker.reward.should eql(20)
|
93
|
+
line.stations.first.worker.skill_badges.first.should eql([{"title"=>"Football Fanatic", "description"=>"This qualification allows you to perform work at stations which have this badge.", "score"=>nil, "quality_rating"=>nil, "max_badges"=>3, "skill_test"=>{"score_after"=>"submit", "manual_scoring"=>false, "display_answers"=>false, "edit_answers"=>true, "retries"=>0, "pass_percentage"=>100, "test_units"=>[{"input"=>{"name"=>"Lionel Andres Messi", "country"=>"Argentina"}, "expected_output"=>[{"birthplace"=>"Rosario, Santa Fe, Argentina", "match_options"=>{"tolerance"=>"1", "ignore_case"=>"false"}, "position"=>"CF", "current-club"=>"Barcelona"}], "match_options"=>{"tolerance"=>0, "ignore_case"=>false}}]}}])
|
94
|
+
line.stations.first.worker.stat_badge.should eql({"approval_rating"=>80, "assignment_duration"=>3600, "abandonment_rate"=>30, "country"=>nil})
|
95
95
|
end
|
96
96
|
|
97
97
|
it "in plain ruby way" do
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
WebMock.allow_net_connect!
|
99
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
100
|
+
sleep 1
|
101
|
+
skill_badge =
|
102
|
+
{
|
103
|
+
:title => 'Football Fanatic',
|
104
|
+
:description => "This qualification allows you to perform work at stations which have this badge.",
|
105
|
+
:max_badges => 3,
|
106
|
+
:test =>
|
101
107
|
{
|
102
|
-
:
|
103
|
-
:
|
104
|
-
:
|
105
|
-
:test =>
|
106
|
-
{
|
107
|
-
:input => {:name => "Lionel Andres Messi", :country => "Argentina"},
|
108
|
-
:expected_output =>
|
109
|
-
[{: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 }}]
|
110
|
-
}
|
108
|
+
:input => {:name => "Lionel Andres Messi", :country => "Argentina"},
|
109
|
+
:expected_output =>
|
110
|
+
[{: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 }}]
|
111
111
|
}
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
}
|
113
|
+
line = CF::Line.new(title, "Digitization")
|
114
|
+
input_format = CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"})
|
115
|
+
line.input_formats input_format
|
115
116
|
|
116
|
-
|
117
|
-
|
117
|
+
station = CF::Station.new({:type => "work"})
|
118
|
+
line.stations station
|
118
119
|
|
119
|
-
|
120
|
-
|
120
|
+
worker = CF::HumanWorker.new({:number => 1, :reward => 20, :skill_badge => skill_badge})
|
121
|
+
line.stations.first.worker = worker
|
121
122
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
end
|
123
|
+
line.stations.first.type.should eql("WorkStation")
|
124
|
+
line.stations.first.worker.number.should eql(1)
|
125
|
+
line.stations.first.worker.reward.should eql(20)
|
126
|
+
line.stations.first.worker.skill_badges.first.should eql([{"title"=>"Football Fanatic", "description"=>"This qualification allows you to perform work at stations which have this badge.", "score"=>nil, "quality_rating"=>nil, "max_badges"=>3, "skill_test"=>{"score_after"=>"submit", "manual_scoring"=>false, "display_answers"=>false, "edit_answers"=>true, "retries"=>0, "pass_percentage"=>100, "test_units"=>[{"input"=>{"name"=>"Lionel Andres Messi", "country"=>"Argentina"}, "expected_output"=>[{"birthplace"=>"Rosario, Santa Fe, Argentina", "match_options"=>{"tolerance"=>"1", "ignore_case"=>"false"}, "position"=>"CF", "current-club"=>"Barcelona"}], "match_options"=>{"tolerance"=>0, "ignore_case"=>false}}]}}])
|
127
|
+
line.stations.first.worker.stat_badge.should eql({"approval_rating"=>80, "assignment_duration"=>3600, "abandonment_rate"=>30, "country"=>nil})
|
128
128
|
end
|
129
129
|
end
|
130
130
|
end
|