cloudfactory 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,88 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module CF
4
- describe CF::HumanWorker do
5
- context "create badge" do
6
- it "should create multiple badge for worker" do
7
- WebMock.allow_net_connect!
8
- badge =
9
- {
10
- :title => 'Football Fanatic',
11
- :description => "This qualification allows you to perform work at stations which have this badge.",
12
- :max_badges => 3,
13
- :test =>
14
- {
15
- :input => {:name => "Lionel Andres Messi", :country => "Argentina"},
16
- :expected_output =>
17
- [{: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 }}]
18
- }
19
- }
20
- badge_1 =
21
- {
22
- :title => 'Football Fanatic',
23
- :description => "This qualification allows you to perform work at stations which have this badge.",
24
- :max_badges => 3,
25
- :test =>
26
- {
27
- :input => {:name => "Cristiano Ronaldo", :country => "Portugal"},
28
- :expected_output =>
29
- [{:birthplace => "Rosario, Santa Fe, Portugal",:match_options => {:tolerance => 10, :ignore_case => true }},{:position => "CF",:match_options => {:tolerance => 1 }},{:"current-club" => "Real Madrid",:match_options => {:tolerance => 1, :ignore_case => false }}]
30
- }
31
- }
32
- title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
33
- sleep 1
34
- line = CF::Line.create(title, "Digitization") do |l|
35
- CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
36
- CF::Station.create({:line =>l, :type => "work"}) do |s|
37
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20, :skill_badge => badge})
38
- end
39
- end
40
- line.stations.first.worker.badge = badge_1
41
- line.stations.first.type.should eql("WorkStation")
42
- line.stations.first.worker.number.should eql(1)
43
- line.stations.first.worker.reward.should eql(20)
44
- 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}}]}}])
45
- line.stations.first.worker.skill_badges.last.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"=>"Cristiano Ronaldo", "country"=>"Portugal"}, "expected_output"=>[{"birthplace"=>"Rosario, Santa Fe, Portugal", "match_options"=>{"tolerance"=>"1", "ignore_case"=>"false"}, "position"=>"CF", "current-club"=>"Real Madrid"}], "match_options"=>{"tolerance"=>0, "ignore_case"=>false}}]}}])
46
- line.stations.first.worker.stat_badge.should eql({"approval_rating"=>80, "assignment_duration"=>3600, "abandonment_rate"=>30, "country"=>nil})
47
- end
48
-
49
- it "should create stat badge for worker in block DSL way" do
50
- WebMock.allow_net_connect!
51
- stat_badge = {:approval_rating => 40, :assignment_duration => 1800}
52
- title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
53
- sleep 1
54
- line = CF::Line.create(title, "Digitization") do |l|
55
- CF::InputFormat.new({:line => l, :name => "image_url", :required => true, :valid_type => "url"})
56
- CF::Station.create({:line =>l, :type => "work"}) do |s|
57
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20, :stat_badge => stat_badge})
58
- end
59
- end
60
- line.stations.first.type.should eql("WorkStation")
61
- line.stations.first.worker.number.should eql(1)
62
- line.stations.first.worker.reward.should eql(20)
63
- line.stations.first.worker.stat_badge.should eql({"approval_rating"=>40, "assignment_duration"=>1800, "abandonment_rate"=>30, "country"=>nil})
64
- end
65
-
66
- it "should create stat badge for worker in plain ruby way" do
67
- WebMock.allow_net_connect!
68
- stat_badge = {:approval_rating => 40, :assignment_duration => 1800}
69
- title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
70
- sleep 1
71
- line = CF::Line.new(title, "Digitization")
72
- input_format = CF::InputFormat.new({:name => "image_url", :required => true, :valid_type => "url"})
73
- line.input_formats input_format
74
-
75
- station = CF::Station.new({:type => "work"})
76
- line.stations station
77
-
78
- worker = CF::HumanWorker.new({:number => 1, :reward => 20, :stat_badge => stat_badge})
79
- line.stations.first.worker = worker
80
-
81
- line.stations.first.type.should eql("WorkStation")
82
- line.stations.first.worker.number.should eql(1)
83
- line.stations.first.worker.reward.should eql(20)
84
- line.stations.first.worker.stat_badge.should eql({"approval_rating"=>40, "assignment_duration"=>1800, "abandonment_rate"=>30, "country"=>nil})
85
- end
86
- end
87
- end
88
- end