ruby-aws 1.6.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.tar.gz.sig +0 -0
- data/.gemtest +0 -0
- data/History.txt +75 -0
- data/LICENSE.txt +202 -0
- data/Manifest.txt +72 -0
- data/NOTICE.txt +4 -0
- data/README.txt +105 -0
- data/Rakefile +33 -0
- data/bin/ruby-aws +9 -0
- data/lib/amazon/util.rb +10 -0
- data/lib/amazon/util/binder.rb +48 -0
- data/lib/amazon/util/data_reader.rb +169 -0
- data/lib/amazon/util/filter_chain.rb +79 -0
- data/lib/amazon/util/hash_nesting.rb +93 -0
- data/lib/amazon/util/lazy_results.rb +59 -0
- data/lib/amazon/util/logging.rb +23 -0
- data/lib/amazon/util/paginated_iterator.rb +70 -0
- data/lib/amazon/util/proactive_results.rb +116 -0
- data/lib/amazon/util/threadpool.rb +129 -0
- data/lib/amazon/util/user_data_store.rb +100 -0
- data/lib/amazon/webservices/mechanical_turk.rb +123 -0
- data/lib/amazon/webservices/mechanical_turk_requester.rb +274 -0
- data/lib/amazon/webservices/mturk/mechanical_turk_error_handler.rb +150 -0
- data/lib/amazon/webservices/mturk/question_generator.rb +58 -0
- data/lib/amazon/webservices/util/amazon_authentication_relay.rb +72 -0
- data/lib/amazon/webservices/util/command_line.rb +157 -0
- data/lib/amazon/webservices/util/convenience_wrapper.rb +90 -0
- data/lib/amazon/webservices/util/filter_proxy.rb +45 -0
- data/lib/amazon/webservices/util/mock_transport.rb +70 -0
- data/lib/amazon/webservices/util/request_signer.rb +42 -0
- data/lib/amazon/webservices/util/rest_transport.rb +120 -0
- data/lib/amazon/webservices/util/soap_simplifier.rb +48 -0
- data/lib/amazon/webservices/util/soap_transport.rb +20 -0
- data/lib/amazon/webservices/util/soap_transport_header_handler.rb +27 -0
- data/lib/amazon/webservices/util/unknown_result_exception.rb +27 -0
- data/lib/amazon/webservices/util/validation_exception.rb +55 -0
- data/lib/amazon/webservices/util/xml_simplifier.rb +61 -0
- data/lib/ruby-aws.rb +19 -0
- data/lib/ruby-aws/version.rb +6 -0
- data/run_rcov.sh +1 -0
- data/samples/mturk/best_image/BestImage.rb +61 -0
- data/samples/mturk/best_image/best_image.properties +39 -0
- data/samples/mturk/best_image/best_image.question +82 -0
- data/samples/mturk/blank_slate/BlankSlate.rb +63 -0
- data/samples/mturk/blank_slate/BlankSlate_multithreaded.rb +67 -0
- data/samples/mturk/helloworld/MTurkHelloWorld.rb +56 -0
- data/samples/mturk/helloworld/mturk.yml +8 -0
- data/samples/mturk/review_policy/ReviewPolicy.rb +139 -0
- data/samples/mturk/review_policy/review_policy.question +30 -0
- data/samples/mturk/reviewer/Reviewer.rb +103 -0
- data/samples/mturk/reviewer/mturk.yml +8 -0
- data/samples/mturk/simple_survey/SimpleSurvey.rb +90 -0
- data/samples/mturk/simple_survey/simple_survey.question +30 -0
- data/samples/mturk/site_category/SiteCategory.rb +87 -0
- data/samples/mturk/site_category/externalpage.htm +71 -0
- data/samples/mturk/site_category/site_category.input +6 -0
- data/samples/mturk/site_category/site_category.properties +45 -0
- data/samples/mturk/site_category/site_category.question +9 -0
- data/test/mturk/test_changehittypeofhit.rb +130 -0
- data/test/mturk/test_error_handler.rb +137 -0
- data/test/mturk/test_mechanical_turk_requester.rb +178 -0
- data/test/mturk/test_mock_mechanical_turk_requester.rb +205 -0
- data/test/test_ruby-aws.rb +24 -0
- data/test/unit/test_binder.rb +89 -0
- data/test/unit/test_data_reader.rb +135 -0
- data/test/unit/test_exceptions.rb +32 -0
- data/test/unit/test_hash_nesting.rb +99 -0
- data/test/unit/test_lazy_results.rb +89 -0
- data/test/unit/test_mock_transport.rb +132 -0
- data/test/unit/test_paginated_iterator.rb +58 -0
- data/test/unit/test_proactive_results.rb +108 -0
- data/test/unit/test_question_generator.rb +55 -0
- data/test/unit/test_threadpool.rb +50 -0
- data/test/unit/test_user_data_store.rb +80 -0
- metadata +238 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<!-- Note the inclusion of the @urls variable which is defined as a field in the input file. ERB is the template engine that is
|
3
|
+
used to perform the merging of variables into template files.
|
4
|
+
-->
|
5
|
+
<% require 'cgi' %>
|
6
|
+
<ExternalQuestion xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd">
|
7
|
+
<ExternalURL>http://s3.amazonaws.com/mturk/samples/sitecategory/externalpage.htm?url=<%= CGI::escape @urls %></ExternalURL>
|
8
|
+
<FrameHeight>400</FrameHeight>
|
9
|
+
</ExternalQuestion>
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
|
4
|
+
require 'test/unit/testcase'
|
5
|
+
require 'ruby-aws'
|
6
|
+
require 'amazon/webservices/mturk/question_generator'
|
7
|
+
require 'amazon/webservices/util/soap_transport'
|
8
|
+
require 'amazon/webservices/util/rest_transport'
|
9
|
+
require 'amazon/webservices/util/mock_transport'
|
10
|
+
|
11
|
+
|
12
|
+
class TestChangeHITTypeOfHIT < Test::Unit::TestCase
|
13
|
+
include Amazon::WebServices
|
14
|
+
|
15
|
+
def setup
|
16
|
+
# Setting up the default requester interface.
|
17
|
+
# This will default to running against Sandbox, but we specify the host explicitly for safety.
|
18
|
+
# Access Key ID and Secret Access Key will be loaded from user preference file
|
19
|
+
# If not found, the user will be interatively queried for their authentication information.
|
20
|
+
@@mturk ||= Amazon::WebServices::MechanicalTurkRequester.new :Host => :Sandbox if ENV['DISABLE_MTURK_SANDBOX_TEST'].nil?
|
21
|
+
|
22
|
+
# set up a mock version of the service
|
23
|
+
@@mock ||= Amazon::WebServices::Util::MockTransport.new
|
24
|
+
@@mockturk ||= Amazon::WebServices::MechanicalTurkRequester.new( :Transport => @@mock, :AWSAccessKey => 'bogus', :AWSAccessKeyId => 'fake' )
|
25
|
+
|
26
|
+
# lets just build this question once
|
27
|
+
@@question ||= MTurk::QuestionGenerator.build { |q| q.ask 'Have you tried changing the description of a HIT?' }
|
28
|
+
end
|
29
|
+
|
30
|
+
def testUpdateHITMock
|
31
|
+
@@mock.listen do |call|
|
32
|
+
case call.name
|
33
|
+
when :GetHIT
|
34
|
+
{:HIT => {:HITId => call.request[:HITId], :Title => "old title", :Description => "foo", :Request => {} } }
|
35
|
+
when :RegisterHITType
|
36
|
+
{:RegisterHITTypeResult => {:HITTypeId => 'mockHITType', :Request => {} } }
|
37
|
+
else
|
38
|
+
{}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
@@mockturk.updateHIT( 'mockHIT', { :Title => 'new title' } )
|
43
|
+
assert_equal :GetHIT, @@mock.next.name
|
44
|
+
|
45
|
+
ht = @@mock.next
|
46
|
+
assert_equal :RegisterHITType, ht.name
|
47
|
+
assert_equal "new title", ht.request[:Title]
|
48
|
+
assert_equal "foo", ht.request[:Description]
|
49
|
+
|
50
|
+
update = @@mock.next
|
51
|
+
assert_equal :ChangeHITTypeOfHIT, update.name
|
52
|
+
assert_equal 'mockHIT', update.request[:HITId]
|
53
|
+
assert_equal 'mockHITType', update.request[:HITTypeId]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Allow user to skip these tests by setting the DISABLE_MTURK_SANDBOX_TEST environment variable
|
57
|
+
if ENV['DISABLE_MTURK_SANDBOX_TEST'].nil?
|
58
|
+
|
59
|
+
def testHappyCase
|
60
|
+
hit_result = @@mturk.createHIT :Title => 'Ruby SDK Test Hit (ChangeHITTypeOfHIT)',
|
61
|
+
:Description => 'Autogenerated ruby-aws test case description1',
|
62
|
+
:Keywords => 'Ruby, test, SDK, changehittypeofhit, description1',
|
63
|
+
:Reward => { :Amount => 0.01, :CurrencyCode => 'USD' },
|
64
|
+
:Question => @@question
|
65
|
+
new_hit_type = @@mturk.registerHITType :Title => 'Ruby SDK Test Hit (ChangeHITTypeOfHIT) - Updated',
|
66
|
+
:Description => 'Autogenerated ruby-aws test case description2',
|
67
|
+
:Keywords => 'Ruby, test, SDK, changehittypeofhit, description2',
|
68
|
+
:Reward => { :Amount => 0.01, :CurrencyCode => 'USD' }
|
69
|
+
@@mturk.changeHITTypeOfHIT :HITId => hit_result[:HITId],
|
70
|
+
:HITTypeId => new_hit_type[:HITTypeId]
|
71
|
+
updated_hit = @@mturk.getHIT :HITId => hit_result[:HITId]
|
72
|
+
assert_equal new_hit_type[:HITTypeId], updated_hit[:HITTypeId], 'HITTypeId of ' + hit_result[:HITId] + ' not updated'
|
73
|
+
@@mturk.forceExpireHIT :HITId => hit_result[:HITId]
|
74
|
+
@@mturk.disposeHIT :HITId => hit_result[:HITId]
|
75
|
+
end
|
76
|
+
|
77
|
+
def testUpdateHIT
|
78
|
+
hit_result = @@mturk.createHIT :Title => 'Ruby SDK Test Hit (ChangeHITTypeOfHIT)',
|
79
|
+
:Description => 'Autogenerated ruby-aws test case description1',
|
80
|
+
:Keywords => 'Ruby, test, SDK, changehittypeofhit, description1',
|
81
|
+
:Reward => { :Amount => 0.01, :CurrencyCode => 'USD' },
|
82
|
+
:Question => @@question
|
83
|
+
new_template = { :Title => 'Ruby SDK Test Hit (ChangeHITTypeOfHIT) - Updated',
|
84
|
+
:Description => 'Autogenerated ruby-aws test case description2',
|
85
|
+
:Keywords => 'Ruby, test, SDK, changehittypeofhit, description2',
|
86
|
+
:Reward => { :Amount => 0.01, :CurrencyCode => 'USD' } }
|
87
|
+
@@mturk.updateHIT(hit_result[:HITId], new_template)
|
88
|
+
assert_not_equal hit_result[:HITTypeId], @@mturk.getHIT(:HITId=>hit_result[:HITId])[:HITTypeId], 'HITTypeId not changed'
|
89
|
+
@@mturk.forceExpireHIT :HITId => hit_result[:HITId]
|
90
|
+
@@mturk.disposeHIT :HITId => hit_result[:HITId]
|
91
|
+
end
|
92
|
+
|
93
|
+
def testUpdateHITs
|
94
|
+
hit_result1 = @@mturk.createHIT :Title => 'Ruby SDK Test Hit (ChangeHITTypeOfHIT)',
|
95
|
+
:Description => 'Autogenerated ruby-aws test case description1',
|
96
|
+
:Keywords => 'Ruby, test, SDK, changehittypeofhit, description1',
|
97
|
+
:Reward => { :Amount => 0.01, :CurrencyCode => 'USD' },
|
98
|
+
:Question => @@question
|
99
|
+
hit_result2 = @@mturk.createHIT :Title => 'Ruby SDK Test Hit (ChangeHITTypeOfHIT)',
|
100
|
+
:Description => 'Autogenerated ruby-aws test case description1',
|
101
|
+
:Keywords => 'Ruby, test, SDK, changehittypeofhit, description1',
|
102
|
+
:Reward => { :Amount => 0.01, :CurrencyCode => 'USD' },
|
103
|
+
:Question => @@question
|
104
|
+
hit_result3 = @@mturk.createHIT :Title => 'Ruby SDK Test Hit (ChangeHITTypeOfHIT)',
|
105
|
+
:Description => 'Autogenerated ruby-aws test case description1',
|
106
|
+
:Keywords => 'Ruby, test, SDK, changehittypeofhit, description1',
|
107
|
+
:Reward => { :Amount => 0.01, :CurrencyCode => 'USD' },
|
108
|
+
:Question => @@question
|
109
|
+
new_template = { :Title => 'Ruby SDK Test Hit (ChangeHITTypeOfHIT) - Updated',
|
110
|
+
:Description => 'Autogenerated ruby-aws test case description2',
|
111
|
+
:Keywords => 'Ruby, test, SDK, changehittypeofhit, description2',
|
112
|
+
:Reward => { :Amount => 0.01, :CurrencyCode => 'USD' } }
|
113
|
+
|
114
|
+
@@mturk.updateHITs(new_template, [hit_result1[:HITId], hit_result2[:HITId], hit_result3[:HITId]])
|
115
|
+
|
116
|
+
assert_not_equal hit_result1[:HITTypeId], @@mturk.getHIT(:HITId=>hit_result1[:HITId])[:HITTypeId], 'HITTypeId not changed'
|
117
|
+
assert_not_equal hit_result2[:HITTypeId], @@mturk.getHIT(:HITId=>hit_result2[:HITId])[:HITTypeId], 'HITTypeId not changed'
|
118
|
+
assert_not_equal hit_result3[:HITTypeId], @@mturk.getHIT(:HITId=>hit_result3[:HITId])[:HITTypeId], 'HITTypeId not changed'
|
119
|
+
@@mturk.forceExpireHIT :HITId => hit_result1[:HITId]
|
120
|
+
@@mturk.disposeHIT :HITId => hit_result1[:HITId]
|
121
|
+
@@mturk.forceExpireHIT :HITId => hit_result2[:HITId]
|
122
|
+
@@mturk.disposeHIT :HITId => hit_result2[:HITId]
|
123
|
+
@@mturk.forceExpireHIT :HITId => hit_result3[:HITId]
|
124
|
+
@@mturk.disposeHIT :HITId => hit_result3[:HITId]
|
125
|
+
end
|
126
|
+
|
127
|
+
end # if not DISABLE_MTURK_SANDBOX_TEST
|
128
|
+
|
129
|
+
end
|
130
|
+
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
|
4
|
+
require 'test/unit/testcase'
|
5
|
+
require 'ruby-aws'
|
6
|
+
require 'amazon/webservices/util/mock_transport'
|
7
|
+
require 'timeout'
|
8
|
+
|
9
|
+
class TestErrorHandler < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@mock = Amazon::WebServices::Util::MockTransport.new
|
13
|
+
@mturk = Amazon::WebServices::MechanicalTurkRequester.new( :Transport => @mock, :AWSAccessKey => 'bogus', :AWSAccessKeyId => 'fake' )
|
14
|
+
end
|
15
|
+
|
16
|
+
def testTimeoutOnce
|
17
|
+
|
18
|
+
# mock will timeout first time, return success on second call
|
19
|
+
toggle = false
|
20
|
+
@mock.listen do |call|
|
21
|
+
Timeout.timeout(1) do
|
22
|
+
if toggle
|
23
|
+
toggle = !toggle
|
24
|
+
else
|
25
|
+
toggle = !toggle
|
26
|
+
sleep(5)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
assert_equal false, toggle
|
33
|
+
# invoke a retryable call once, should auto-retry and return success
|
34
|
+
@mturk.getAccountBalance
|
35
|
+
assert_equal 2, @mock.call_buffer.size, "Should have retried once"
|
36
|
+
@mock.each {|call| assert_equal :GetAccountBalance, call.name, "Should have been a GetAccountBalance call" }
|
37
|
+
|
38
|
+
@mock.flush
|
39
|
+
assert_equal false, toggle
|
40
|
+
# but invoking a non-retryable call will throw an exception
|
41
|
+
begin
|
42
|
+
@mturk.grantBonus
|
43
|
+
fail "Should have thrown an exception"
|
44
|
+
rescue Timeout::Error
|
45
|
+
# expect this exception
|
46
|
+
end
|
47
|
+
assert_equal true, toggle
|
48
|
+
assert_equal :GrantBonus, @mock.next.name
|
49
|
+
assert_nil @mock.next
|
50
|
+
end
|
51
|
+
|
52
|
+
def testTimeoutAlways
|
53
|
+
|
54
|
+
#mock will always timeout
|
55
|
+
@mock.listen do |call|
|
56
|
+
Timeout.timeout(1) { sleep(2) }
|
57
|
+
end
|
58
|
+
|
59
|
+
begin
|
60
|
+
@mturk.searchHITs
|
61
|
+
fail "Should have thrown an exception"
|
62
|
+
rescue Timeout::Error
|
63
|
+
# expect this exception
|
64
|
+
end
|
65
|
+
|
66
|
+
7.times do
|
67
|
+
assert_equal :SearchHITs, @mock.next.name
|
68
|
+
end
|
69
|
+
assert_nil @mock.next
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def testRuntimeError
|
74
|
+
@mock.listen do |call|
|
75
|
+
raise "Blah"
|
76
|
+
end
|
77
|
+
|
78
|
+
begin
|
79
|
+
@mturk.searchHITs
|
80
|
+
fail "Should have thrown an exception"
|
81
|
+
rescue RuntimeError => e
|
82
|
+
assert_equal "Blah", e.to_s
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def testRuntimeErrorThrottled
|
87
|
+
@mock.listen do |call|
|
88
|
+
raise "Throttled"
|
89
|
+
end
|
90
|
+
|
91
|
+
begin
|
92
|
+
@mturk.searchHITs
|
93
|
+
fail "Should have thrown an exception"
|
94
|
+
rescue RuntimeError => e
|
95
|
+
assert_equal "Throttled", e.to_s
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
if Amazon::WebServices::Util::SOAPTransport.canSOAP?
|
100
|
+
def testSOAPFaultError
|
101
|
+
arg = (Struct.new :faultcode, :faultstring, :faultactor, :detail).new
|
102
|
+
arg.faultcode = (Struct.new :data).new 'aws:blarg'
|
103
|
+
arg.faultstring = (Struct.new :data).new 'blarg blarg blarg'
|
104
|
+
s = SOAP::FaultError.new( arg )
|
105
|
+
|
106
|
+
@mock.listen do |call|
|
107
|
+
raise s
|
108
|
+
end
|
109
|
+
|
110
|
+
begin
|
111
|
+
@mturk.searchHITs
|
112
|
+
fail "Should have thrown an exception"
|
113
|
+
rescue SOAP::FaultError => e
|
114
|
+
assert_equal s, e
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def testSOAPFaultErrorThrottled
|
119
|
+
arg = (Struct.new :faultcode, :faultstring, :faultactor, :detail).new
|
120
|
+
arg.faultcode = (Struct.new :data).new 'aws:Server.ServiceUnavailable'
|
121
|
+
arg.faultstring = (Struct.new :data).new 'Hey, give us a break!'
|
122
|
+
s = SOAP::FaultError.new( arg )
|
123
|
+
|
124
|
+
@mock.listen do |call|
|
125
|
+
raise s
|
126
|
+
end
|
127
|
+
|
128
|
+
begin
|
129
|
+
@mturk.searchHITs
|
130
|
+
fail "Should have thrown an exception"
|
131
|
+
rescue SOAP::FaultError => e
|
132
|
+
assert_equal s, e
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end # canSOAP?
|
136
|
+
|
137
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
|
4
|
+
require 'test/unit/testcase'
|
5
|
+
require 'ruby-aws'
|
6
|
+
require 'amazon/webservices/mturk/question_generator'
|
7
|
+
require 'amazon/webservices/util/soap_transport'
|
8
|
+
require 'amazon/webservices/util/rest_transport'
|
9
|
+
|
10
|
+
# Allow user to skip these tests by setting the DISABLE_MTURK_SANDBOX_TEST environment variable
|
11
|
+
if ENV['DISABLE_MTURK_SANDBOX_TEST'].nil?
|
12
|
+
|
13
|
+
class TestMechanicalTurkRequester < Test::Unit::TestCase
|
14
|
+
include Amazon::WebServices
|
15
|
+
|
16
|
+
def setup
|
17
|
+
# Setting up the default requester interface.
|
18
|
+
# This will default to running against Sandbox, but we'll the host explicitly for safety.
|
19
|
+
# Access Key ID and Secret Access Key will be loaded from user preference file
|
20
|
+
# If not found, the user will be interatively queried for their authentication information.
|
21
|
+
@@mturk ||= MechanicalTurkRequester.new( :Host => :Sandbox )
|
22
|
+
|
23
|
+
# utilize the SOAP transport, if we can
|
24
|
+
@@mturk_soap ||= MechanicalTurkRequester.new( :Host => :Sandbox, :Transport => :SOAP ) if Util::SOAPTransport.canSOAP?
|
25
|
+
# utilize the REST transport with default HTTP method
|
26
|
+
@@mturk_rest ||= MechanicalTurkRequester.new( :Host => :Sandbox, :Transport => :REST )
|
27
|
+
# utilize the REST transport via Get
|
28
|
+
@@mturk_rest_get ||= MechanicalTurkRequester.new( :Host => :Sandbox, :Transport => :REST, :RestStyle => :Get )
|
29
|
+
# utilize the REST transport via Post, if we can
|
30
|
+
@@mturk_rest_post ||= MechanicalTurkRequester.new( :Host => :Sandbox, :Transport => :REST, :RestStyle => :Post ) if Util::RESTTransport.canPost?
|
31
|
+
end
|
32
|
+
|
33
|
+
def testAvailableFunds
|
34
|
+
funds = @@mturk.availableFunds
|
35
|
+
assert_equal 10000.0, funds, "Sandbox should always show 10k available funds"
|
36
|
+
end
|
37
|
+
|
38
|
+
def testCreateHIT
|
39
|
+
question = MTurk::QuestionGenerator.build { |q| q.ask 'Have you tried Ruby?' }
|
40
|
+
result = @@mturk.createHIT :Title => 'Ruby SDK Test Hit',
|
41
|
+
:Description => 'Autogenerated hit from ruby-aws test cases',
|
42
|
+
:Keywords => 'Ruby, test, SDK',
|
43
|
+
:Reward => { :Amount => 23.44, :CurrencyCode => 'USD' },
|
44
|
+
:Question => question
|
45
|
+
assert_not_nil( result[:HITId] )
|
46
|
+
@@mturk.forceExpireHIT( :HITId => result[:HITId] )
|
47
|
+
@@mturk.disposeHIT( :HITId => result[:HITId] )
|
48
|
+
end
|
49
|
+
|
50
|
+
def testCreateHITFailure
|
51
|
+
begin
|
52
|
+
@@mturk.createHIT :Title => 'Ruby SDK Test Hit',
|
53
|
+
:Description => 'Autogenerated hit from ruby-aws test cases',
|
54
|
+
:Keywords => 'Ruby, test, SDK',
|
55
|
+
:Reward => { :Amount => 23.44, :CurrencyCode => 'USD' },
|
56
|
+
:Question => "Invalid Question"
|
57
|
+
fail "Mechanical Turk should have thrown an exception"
|
58
|
+
rescue => e
|
59
|
+
raise e unless e.is_a?( Util::ValidationException )
|
60
|
+
assert_equal "AWS.MechanicalTurk.XMLParseError", e.message
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if Util::SOAPTransport.canSOAP?
|
65
|
+
|
66
|
+
def testSOAPCreateHIT
|
67
|
+
question = MTurk::QuestionGenerator.build { |q| q.ask 'Have you tried Ruby?' }
|
68
|
+
result = @@mturk_soap.createHIT :Title => 'Ruby SDK Test Hit',
|
69
|
+
:Description => 'Autogenerated hit from ruby-aws test cases',
|
70
|
+
:Keywords => 'Ruby, test, SDK',
|
71
|
+
:Reward => { :Amount => 23.44, :CurrencyCode => 'USD' },
|
72
|
+
:Question => question
|
73
|
+
assert_not_nil( result[:HITId] )
|
74
|
+
@@mturk_soap.forceExpireHIT( :HITId => result[:HITId] )
|
75
|
+
@@mturk_soap.disposeHIT( :HITId => result[:HITId] )
|
76
|
+
end
|
77
|
+
|
78
|
+
def testSOAPCreateHITFailure
|
79
|
+
begin
|
80
|
+
@@mturk_soap.createHIT :Title => 'Ruby SDK Test Hit',
|
81
|
+
:Description => 'Autogenerated hit from ruby-aws test cases',
|
82
|
+
:Keywords => 'Ruby, test, SDK',
|
83
|
+
:Reward => { :Amount => 23.44, :CurrencyCode => 'USD' },
|
84
|
+
:Question => "Invalid Question"
|
85
|
+
fail "Mechanical Turk should have thrown an exception"
|
86
|
+
rescue => e
|
87
|
+
raise e unless e.is_a?( Util::ValidationException )
|
88
|
+
assert_equal "AWS.MechanicalTurk.XMLParseError", e.message
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end # if Util::SOAPTransport.canSOAP?
|
93
|
+
|
94
|
+
def testRESTCreateHIT
|
95
|
+
question = MTurk::QuestionGenerator.build { |q| q.ask 'Have you tried Ruby?' }
|
96
|
+
result = @@mturk_rest.createHIT :Title => 'Ruby SDK Test Hit',
|
97
|
+
:Description => 'Autogenerated hit from ruby-aws test cases',
|
98
|
+
:Keywords => 'Ruby, test, SDK',
|
99
|
+
:Reward => { :Amount => 23.44, :CurrencyCode => 'USD' },
|
100
|
+
:Question => question
|
101
|
+
assert_not_nil( result[:HITId] )
|
102
|
+
@@mturk_rest.forceExpireHIT( :HITId => result[:HITId] )
|
103
|
+
@@mturk_rest.disposeHIT( :HITId => result[:HITId] )
|
104
|
+
end
|
105
|
+
|
106
|
+
def testRESTCreateHITFailure
|
107
|
+
begin
|
108
|
+
@@mturk_rest.createHIT :Title => 'Ruby SDK Test Hit',
|
109
|
+
:Description => 'Autogenerated hit from ruby-aws test cases',
|
110
|
+
:Keywords => 'Ruby, test, SDK',
|
111
|
+
:Reward => { :Amount => 23.44, :CurrencyCode => 'USD' },
|
112
|
+
:Question => "Invalid Question"
|
113
|
+
fail "Mechanical Turk should have thrown an exception"
|
114
|
+
rescue => e
|
115
|
+
raise e unless e.is_a?( Util::ValidationException )
|
116
|
+
assert_equal "AWS.MechanicalTurk.XMLParseError", e.message
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def testGetRESTCreateHIT
|
121
|
+
question = MTurk::QuestionGenerator.build { |q| q.ask 'Have you tried Ruby?' }
|
122
|
+
result = @@mturk_rest_get.createHIT :Title => 'Ruby SDK Test Hit',
|
123
|
+
:Description => 'Autogenerated hit from ruby-aws test cases',
|
124
|
+
:Keywords => 'Ruby, test, SDK',
|
125
|
+
:Reward => { :Amount => 23.44, :CurrencyCode => 'USD' },
|
126
|
+
:Question => question
|
127
|
+
assert_not_nil( result[:HITId] )
|
128
|
+
@@mturk_rest_get.forceExpireHIT( :HITId => result[:HITId] )
|
129
|
+
@@mturk_rest_get.disposeHIT( :HITId => result[:HITId] )
|
130
|
+
end
|
131
|
+
|
132
|
+
def testGetRESTCreateHITFailure
|
133
|
+
begin
|
134
|
+
@@mturk_rest_get.createHIT :Title => 'Ruby SDK Test Hit',
|
135
|
+
:Description => 'Autogenerated hit from ruby-aws test cases',
|
136
|
+
:Keywords => 'Ruby, test, SDK',
|
137
|
+
:Reward => { :Amount => 23.44, :CurrencyCode => 'USD' },
|
138
|
+
:Question => "Invalid Question"
|
139
|
+
fail "Mechanical Turk should have thrown an exception"
|
140
|
+
rescue => e
|
141
|
+
raise e unless e.is_a?( Util::ValidationException )
|
142
|
+
assert_equal "AWS.MechanicalTurk.XMLParseError", e.message
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
if Util::RESTTransport.canPost?
|
147
|
+
|
148
|
+
def testPostRESTCreateHIT
|
149
|
+
question = MTurk::QuestionGenerator.build { |q| q.ask 'Have you tried Ruby?' }
|
150
|
+
result = @@mturk_rest_post.createHIT :Title => 'Ruby SDK Test Hit',
|
151
|
+
:Description => 'Autogenerated hit from ruby-aws test cases',
|
152
|
+
:Keywords => 'Ruby, test, SDK',
|
153
|
+
:Reward => { :Amount => 23.44, :CurrencyCode => 'USD' },
|
154
|
+
:Question => question
|
155
|
+
assert_not_nil( result[:HITId] )
|
156
|
+
@@mturk_rest_post.forceExpireHIT( :HITId => result[:HITId] )
|
157
|
+
@@mturk_rest_post.disposeHIT( :HITId => result[:HITId] )
|
158
|
+
end
|
159
|
+
|
160
|
+
def testPostRESTCreateHITFailure
|
161
|
+
begin
|
162
|
+
@@mturk_rest_post.createHIT :Title => 'Ruby SDK Test Hit',
|
163
|
+
:Description => 'Autogenerated hit from ruby-aws test cases',
|
164
|
+
:Keywords => 'Ruby, test, SDK',
|
165
|
+
:Reward => { :Amount => 23.44, :CurrencyCode => 'USD' },
|
166
|
+
:Question => "Invalid Question"
|
167
|
+
fail "Mechanical Turk should have thrown an exception"
|
168
|
+
rescue => e
|
169
|
+
raise e unless e.is_a?( Util::ValidationException )
|
170
|
+
assert_equal "AWS.MechanicalTurk.XMLParseError", e.message
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
end # if Util::RESTTransport.canPost?
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
end # if not DISABLE_MTURK_SANDBOX_TEST
|